Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(session_host): remove unused session factory and api modules

Steven Enamakel8a1dd301f491
diff --git a/crates/openhuman-core/src/agent/session_host/README.md b/crates/openhuman-core/src/agent/session_host/README.md
index eaa0dee6d7..68647103b0 100644
--- a/crates/openhuman-core/src/agent/session_host/README.md
+++ b/crates/openhuman-core/src/agent/session_host/README.md
@@ -15,15 +15,11 @@ run after each turn commits.
| --- | --- |
| [`types.rs`](./types.rs) | `OpenHumanSessionHost` and `SessionHostBuilder` struct definitions, no logic |
| `builder/` | `SessionHostBuilder` fluent API and the `from_config` factory |
-| [`factory.rs`](./factory.rs) | `OpenHumanSessionFactory` |
| [`runtime_session.rs`](./runtime_session.rs) | Runtime session composition and the public `turn()` |
| `runtime/` | Public accessors, `run_single` |
-| [`session_api.rs`](./session_api.rs) | Start, read back, and list the generations of a durable session |
| [`driver.rs`](./driver.rs) | The OpenHuman `SessionDriver` that runs the model and tools |
| [`hooks.rs`](./hooks.rs) | Product prepare, commit, and terminal hooks |
| [`codec.rs`](./codec.rs) | `OpenHumanTranscriptCodec`, the product transcript dialect |
-| [`policy.rs`](./policy.rs) | Prompt and turn policy applied before dispatch |
-| [`prefix_snapshot.rs`](./prefix_snapshot.rs) | Cache-prefix bookkeeping across resumes |
| [`recorded_tools.rs`](./recorded_tools.rs) | Rebuilds recorded Composio actions as deferred executors on resume |
| [`prelude_integrations.rs`](./prelude_integrations.rs) | Fetches connected integrations on the first turn of a session instance |
| [`announcement_notes.rs`](./announcement_notes.rs) | Smaller product wiring pulled out of the builder |
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
index 9bab2badd1..2fd3269fb2 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
@@ -1,12 +1,12 @@
//! `OpenHumanSessionHost::from_config` factory methods and internal `build_session_agent_inner` constructor.
use super::should_synthesize_delegation_tools;
-use crate::agent_registry::host_definition::{
- AgentDefinitionExt, AgentDefinitionRegistry, NO_TOOLS_SENTINEL,
-};
use crate::agent::host_runtime;
use crate::agent::prompts::SystemPromptBuilder;
use crate::agent::session_host::types::OpenHumanSessionHost;
+use crate::agent_registry::host_definition::{
+ AgentDefinitionExt, AgentDefinitionRegistry, NO_TOOLS_SENTINEL,
+};
use crate::config::Config;
use crate::core::runtime::DispatchCtx;
use crate::security::SecurityPolicy;
@@ -889,9 +889,9 @@ pub(super) fn resolve_target_definition(
real tool belt instead of persona-only / erroring",
agent_id
);
- return Ok(Some(
- crate::agent_registry::definition_from_registry_entry(&entry),
- ));
+ return Ok(Some(crate::agent_registry::definition_from_registry_entry(
+ &entry,
+ )));
}
if agent_id == "orchestrator" {
diff --git a/crates/openhuman-core/src/agent/session_host/builder/host_only.rs b/crates/openhuman-core/src/agent/session_host/builder/host_only.rs
index 4dbafa2fdb..198c4ca82b 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/host_only.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/host_only.rs
@@ -29,8 +29,8 @@ use tinyagents_harness::context::RunContext;
use tinyagents_harness::middleware::{PolicyDecision, ToolCallPolicy};
use tinyinference_llm::tool::ToolCall;
-use crate::agent::OpenHumanSessionHost;
use crate::agent::tinyagents::host::OpenHumanRunContext;
+use crate::agent::OpenHumanSessionHost;
use crate::config::Config;
use anyhow::Result;
use tinyagents_definition::{SandboxMode, ToolScope};
@@ -45,8 +45,8 @@ pub struct HostOnlyToolPolicy {
host: Option<
Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
>,
}
@@ -59,8 +59,8 @@ impl HostOnlyToolPolicy {
host: Option<
Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
>,
) -> Self {
@@ -112,15 +112,15 @@ pub(super) fn session_policy(
host: Option<
Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
>,
) -> Option<
Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
> {
if !host_only {
diff --git a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs
index e544c03186..583c1eb887 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs
@@ -64,8 +64,8 @@ pub struct HostTurnTools {
pub policy: Option<
Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
>,
}
@@ -180,8 +180,8 @@ impl HostTurnTools {
mut self,
policy: Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
) -> Self {
self.policy = Some(policy);
@@ -205,8 +205,8 @@ pub(super) struct MergedHostTurnTools {
pub policy: Option<
Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
>,
pub withheld: HashSet<String>,
diff --git a/crates/openhuman-core/src/agent/session_host/builder/setters.rs b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
index 6a8089972e..301a98859d 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/setters.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
@@ -378,8 +378,8 @@ impl SessionHostBuilder {
mut self,
policy: Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
) -> Self {
self.tool_policy = Some(policy);
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rs
index 81469fa52c..c08f041458 100644
--- a/crates/openhuman-core/src/agent/session_host/driver.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver.rs
@@ -18,7 +18,7 @@ use tinytools_agent::dialect::ToolDialect;
use crate::agent::{
session_host::turn::graph::{self, ChatTurnGraph},
- tinyagents::{TurnModelSource, host::OpenHumanHostBase, host::OpenHumanRunContext},
+ tinyagents::{host::OpenHumanHostBase, host::OpenHumanRunContext, TurnModelSource},
};
/// Immutable host composition consumed by [`OpenHumanSessionDriver`].
diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
index e1b848003c..b49b402d7a 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
@@ -17,14 +17,14 @@ use tinyagents_harness::middleware::wrap_harness_instruction;
use crate::agent::{
message_convert::dialect_response_from_provider,
session_host::turn_checkpoint::{
- self, CloseVerdict, CloseViolation, build_deterministic_checkpoint,
- build_deterministic_final_summary, close_repair_instruction, close_verification_prompt,
- final_answer_instruction, parse_close_verdict, quotes_harness_instruction,
- render_tool_results, results_from_tool_outcomes,
+ self, build_deterministic_checkpoint, build_deterministic_final_summary,
+ close_repair_instruction, close_verification_prompt, final_answer_instruction,
+ parse_close_verdict, quotes_harness_instruction, render_tool_results,
+ results_from_tool_outcomes, CloseVerdict, CloseViolation,
},
tinyagents::{TinyagentsTurnOutcome, TurnModelSource},
};
-use crate::inference::provider::{AGENT_TURN_MAX_OUTPUT_TOKENS, BilledUsage, ChatResponse};
+use crate::inference::provider::{BilledUsage, ChatResponse, AGENT_TURN_MAX_OUTPUT_TOKENS};
/// Accounting from model calls performed after the harness loop has ended.
#[derive(Default)]
diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
index 02c42de7c5..1b4c474420 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
@@ -311,14 +311,12 @@ async fn timed_out_repair_keeps_the_usage_of_its_answered_call() {
};
// A full channel whose receiver is alive: the correction's send blocks.
let (progress, _receiver) = tokio::sync::mpsc::channel(1);
- assert!(
- progress
- .try_send(AgentProgress::TextDelta {
- delta: "earlier".into(),
- iteration: 1,
- })
- .is_ok()
- );
+ assert!(progress
+ .try_send(AgentProgress::TextDelta {
+ delta: "earlier".into(),
+ iteration: 1,
+ })
+ .is_ok());
let mut usage = RepairUsage::for_model("test-model");
let repaired = tokio::time::timeout(
diff --git a/crates/openhuman-core/src/agent/session_host/driver_tests.rs b/crates/openhuman-core/src/agent/session_host/driver_tests.rs
index 03b7151aa9..f73ebc09ce 100644
--- a/crates/openhuman-core/src/agent/session_host/driver_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver_tests.rs
@@ -1,7 +1,7 @@
use super::*;
-fn sidecar()
--> std::sync::Arc<std::sync::Mutex<crate::agent::tinyagents::host::run_context::SessionTurnSidecar>>
+fn sidecar(
+) -> std::sync::Arc<std::sync::Mutex<crate::agent::tinyagents::host::run_context::SessionTurnSidecar>>
{
crate::agent::tinyagents::host::OpenHumanRunContext::new()
.session_sidecar
@@ -32,13 +32,11 @@ fn graph_failure_persists_only_accepted_snapshot_history() {
assert_eq!(partial.history.len(), 2);
assert_eq!(partial.history[0].text(), "stable prefix");
assert_eq!(partial.history[1].text(), "request");
- assert!(
- partial
- .partial
- .expect("display partial")
- .content
- .contains("provider rejected follow-up")
- );
+ assert!(partial
+ .partial
+ .expect("display partial")
+ .content
+ .contains("provider rejected follow-up"));
}
#[test]
diff --git a/crates/openhuman-core/src/agent/session_host/factory.rs b/crates/openhuman-core/src/agent/session_host/factory.rs
deleted file mode 100644
index c42736a7d3..0000000000
--- a/crates/openhuman-core/src/agent/session_host/factory.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-//! Composition factory for OpenHuman-owned TinyAgents sessions.
-
-use std::sync::Arc;
-use tinyagents_runtime::{
- PrefixSnapshot, RuntimeError, Session, SessionBuilder, SessionDriver, ToolSnapshot,
-};
-use tinyagents_session::transcript::{TranscriptLocator, TranscriptMeta};
-
-use crate::agent::tinyagents::host::OpenHumanRunContext;
-
-use super::{OpenHumanSessionHooks, OpenHumanTranscriptCodec};
-
-/// Builds the neutral runtime from OpenHuman's resolved policy and adapters.
-///
-/// No stateful history, transcript delta or prefix implementation belongs in
-/// this type; those remain directly owned by `tinyagents_runtime::Session`.
-pub struct OpenHumanSessionFactory;
-
-impl OpenHumanSessionFactory {
- pub fn build(
- driver: Arc<dyn SessionDriver<OpenHumanRunContext>>,
- hooks: Arc<OpenHumanSessionHooks>,
- prefix: PrefixSnapshot,
- tools: ToolSnapshot,
- locator: Arc<dyn TranscriptLocator>,
- stem: impl Into<String>,
- meta: TranscriptMeta,
- ) -> Result<Session<OpenHumanRunContext>, RuntimeError> {
- SessionBuilder::new(driver)
- .codec(Arc::new(OpenHumanTranscriptCodec))
- .hooks(hooks)
- .prefix(prefix)
- .tool_snapshot(tools)
- .transcript(locator, stem, meta)
- .build()
- }
-}
diff --git a/crates/openhuman-core/src/agent/session_host/hooks.rs b/crates/openhuman-core/src/agent/session_host/hooks.rs
index ca38c0be01..ffa7d2bf97 100644
--- a/crates/openhuman-core/src/agent/session_host/hooks.rs
+++ b/crates/openhuman-core/src/agent/session_host/hooks.rs
@@ -56,32 +56,32 @@ impl OpenHumanSessionHooks {
/// it cannot relabel an already durable turn.
pub fn new(
before_resume: impl for<'a> Fn(
- &'a mut SessionTurnRequest,
- &'a mut TurnOptions<OpenHumanRunContext>,
- SessionStateView<'a>,
- ) -> HookFuture<'a, ResumePreparation>
- + Send
- + Sync
- + 'static,
+ &'a mut SessionTurnRequest,
+ &'a mut TurnOptions<OpenHumanRunContext>,
+ SessionStateView<'a>,
+ ) -> HookFuture<'a, ResumePreparation>
+ + Send
+ + Sync
+ + 'static,
before: impl for<'a> Fn(
- &'a mut SessionTurnRequest,
- &'a mut TurnOptions<OpenHumanRunContext>,
- SessionStateView<'a>,
- ) -> HookFuture<'a, TurnPreparation>
- + Send
- + Sync
- + 'static,
+ &'a mut SessionTurnRequest,
+ &'a mut TurnOptions<OpenHumanRunContext>,
+ SessionStateView<'a>,
+ ) -> HookFuture<'a, TurnPreparation>
+ + Send
+ + Sync
+ + 'static,
before_commit: impl for<'a> Fn(
- &'a SessionTurnOutcome,
- &'a TranscriptTurnOptions<OpenHumanRunContext>,
- ) -> HookFuture<'a, ()>
- + Send
- + Sync
- + 'static,
+ &'a SessionTurnOutcome,
+ &'a TranscriptTurnOptions<OpenHumanRunContext>,
+ ) -> HookFuture<'a, ()>
+ + Send
+ + Sync
+ + 'static,
committed: impl Fn(CommitReceipt<OpenHumanRunContext>) -> HookFuture<'static, ()>
- + Send
- + Sync
- + 'static,
+ + Send
+ + Sync
+ + 'static,
terminal: impl Fn(SessionTerminal) -> HookFuture<'static, ()> + Send + Sync + 'static,
) -> Self {
Self {
diff --git a/crates/openhuman-core/src/agent/session_host/live_tools.rs b/crates/openhuman-core/src/agent/session_host/live_tools.rs
index 4fdcb5c298..16f51e511d 100644
--- a/crates/openhuman-core/src/agent/session_host/live_tools.rs
+++ b/crates/openhuman-core/src/agent/session_host/live_tools.rs
@@ -8,8 +8,8 @@
use std::sync::Arc;
use crate::agent::session_host::types::OpenHumanSessionHost;
-use crate::agent::tinyagents::ToolPolicyEnforcement;
use crate::agent::tinyagents::live_harness::LiveToolSurface;
+use crate::agent::tinyagents::ToolPolicyEnforcement;
impl OpenHumanSessionHost {
/// The durable tools, the visible names and the tool policy of this
diff --git a/crates/openhuman-core/src/agent/session_host/mod.rs b/crates/openhuman-core/src/agent/session_host/mod.rs
index 1b61d9e6ef..dac67f41c2 100644
--- a/crates/openhuman-core/src/agent/session_host/mod.rs
+++ b/crates/openhuman-core/src/agent/session_host/mod.rs
@@ -21,7 +21,6 @@
//! | [`types`] | `OpenHumanSessionHost` and `SessionHostBuilder` struct definitions (no logic). |
//! | [`builder`] | `SessionHostBuilder` fluent API + `OpenHumanSessionHost::from_config` factory. |
//! | [`runtime_session`] | Runtime session composition and public `turn()`. |
-//! | [`session_api`] | Start / read / list the durable session. |
//! | [`driver`] | OpenHuman model/harness `SessionDriver`. |
//! | [`hooks`] | Product preparation/commit/terminal hooks. |
//! | [`runtime`] | Public accessors and `run_single` / `run_interactive`. |
@@ -37,15 +36,16 @@ pub use builder::{HostOnlyToolPolicy, HostTools, HostTurnTools, TurnContext};
mod builder;
mod codec;
mod driver;
-mod factory;
mod hooks;
// Tool surface for live voice sessions (`voice::live`).
#[cfg(feature = "voice")]
mod live_tools;
mod recorded_tools;
+#[cfg(test)]
+#[path = "resume_bound_session_tests.rs"]
+mod resume_bound_session_tests;
mod runtime;
mod runtime_session;
-mod session_api;
pub(crate) mod stop_summary;
mod turn;
// `pub(crate)` since issue #6014: the tool-call-cap instruction is now appended
@@ -58,7 +58,6 @@ pub(crate) mod turn_checkpoint;
mod types;
pub use codec::OpenHumanTranscriptCodec;
-pub use factory::OpenHumanSessionFactory;
pub use hooks::OpenHumanSessionHooks;
pub use types::{OpenHumanSessionHost, SessionHostBuilder, TurnOverrides};
diff --git a/crates/openhuman-core/src/agent/session_host/orphaned_head_resume_tests.rs b/crates/openhuman-core/src/agent/session_host/orphaned_head_resume_tests.rs
index 97b42fde37..9e8754c50c 100644
--- a/crates/openhuman-core/src/agent/session_host/orphaned_head_resume_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/orphaned_head_resume_tests.rs
@@ -176,9 +176,7 @@ async fn resumed_orphaned_tool_head_is_repaired_before_the_request() {
!matches!(first_non_system, Message::Tool(_)),
"the request must not open on an orphaned tool result, got {first_non_system:?}"
);
- assert!(
- !sent
- .iter()
- .any(|m| matches!(m, Message::Tool(t) if t.tool_call_id.starts_with("call_orphan")))
- );
+ assert!(!sent
+ .iter()
+ .any(|m| matches!(m, Message::Tool(t) if t.tool_call_id.starts_with("call_orphan"))));
}
diff --git a/crates/openhuman-core/src/agent/session_host/response_shape_turn_tests.rs b/crates/openhuman-core/src/agent/session_host/response_shape_turn_tests.rs
index d55c86bfd3..d4f8cc2ebd 100644
--- a/crates/openhuman-core/src/agent/session_host/response_shape_turn_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/response_shape_turn_tests.rs
@@ -9,11 +9,9 @@ fn a_response_shape_applies_to_exactly_the_next_turn() {
state.pending_response_shape = Some(Arc::clone(&scope));
let first = state.take_turn_inputs();
- assert!(
- first
- .response_shape
- .as_ref()
- .is_some_and(|taken| Arc::ptr_eq(taken, &scope))
- );
+ assert!(first
+ .response_shape
+ .as_ref()
+ .is_some_and(|taken| Arc::ptr_eq(taken, &scope)));
assert!(state.take_turn_inputs().response_shape.is_none());
}
diff --git a/crates/openhuman-core/src/agent/session_host/session_api.rs b/crates/openhuman-core/src/agent/session_host/resume_bound_session_tests.rs
similarity index 76%
rename from crates/openhuman-core/src/agent/session_host/session_api.rs
rename to crates/openhuman-core/src/agent/session_host/resume_bound_session_tests.rs
index 7ddb4b8257..4c6b1789c5 100644
--- a/crates/openhuman-core/src/agent/session_host/session_api.rs
+++ b/crates/openhuman-core/src/agent/session_host/resume_bound_session_tests.rs
@@ -1,19 +1,10 @@
-//! The host's session surface: start one, read it back, list its generations.
-//!
-//! OpenHuman does not own session mechanics. Identity, resume, transcript
-//! binding, compaction generations and persistence all live in
-//! `tinyagents-session` / `tinyagents-runtime`. What remains here is the small
-//! product-facing surface over them — starting a session (binding a thread's
-//! identity, [`super::runtime::accessors`]), reading one back, and listing the
-//! generations a long conversation has accumulated.
+use super::*;
use anyhow::Result;
use tinyagents_runtime::{ResumeMode, TurnOptions};
use crate::agent::tinyagents::host::OpenHumanRunContext;
-use super::OpenHumanSessionHost;
-
impl OpenHumanSessionHost {
/// Load this session's durable history now, before any turn runs.
///
diff --git a/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs b/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs
index cd1b990c2c..5b0a20e592 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs
@@ -6,7 +6,7 @@ use super::super::types::OpenHumanSessionHost;
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
use crate::security::prompt_injection::{
- PromptEnforcementAction, PromptEnforcementContext, enforce_prompt_input,
+ enforce_prompt_input, PromptEnforcementAction, PromptEnforcementContext,
};
use anyhow::Result;
use tinyagents_harness::agent_error::AgentError;
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_adapter_session_state_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_session_state_tests.rs
index 305aeec07f..7381a734b4 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_session_state_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_session_state_tests.rs
@@ -1,5 +1,5 @@
+use super::runtime_session::{begin_turn_resume, OpenHumanSessionState};
use super::TurnOverrides;
-use super::runtime_session::{OpenHumanSessionState, begin_turn_resume};
use tinyagents_runtime::ResumeMode;
#[test]
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
index d4726336bf..e6f7e4e8cd 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
@@ -2,9 +2,9 @@ use std::sync::{Arc, Mutex};
use async_trait::async_trait;
use tinyagents_runtime::{
- DriverFailure, DriverOutcome, DriverRequest, PrefixSnapshot, ResumeMode, SessionDriver,
- SessionTerminal, SessionTurnRequest, ToolSnapshot, TranscriptCodec, TranscriptTurnOptions,
- TurnOptions,
+ DriverFailure, DriverOutcome, DriverRequest, PrefixSnapshot, ResumeMode, SessionBuilder,
+ SessionDriver, SessionTerminal, SessionTurnRequest, ToolSnapshot, TranscriptCodec,
+ TranscriptTurnOptions, TurnOptions,
};
use tinyagents_session::port::{InMemorySessionStores, SessionStoreProvider};
use tinyagents_session::transcript::TranscriptMeta;
@@ -15,7 +15,7 @@ use super::announcement_notes::{
};
use super::runtime_session::tool_surface::reconcile_synthesized_visibility;
use super::runtime_session::{account_committed_turn_against_goal, holistic_last_turn_usage};
-use super::{OpenHumanSessionFactory, OpenHumanSessionHooks, OpenHumanTranscriptCodec};
+use super::{OpenHumanSessionHooks, OpenHumanTranscriptCodec};
use crate::agent::tinyagents::host::OpenHumanRunContext;
struct RecordingDriver(Arc<Mutex<Vec<OpenHumanRunContext>>>);
@@ -69,12 +69,10 @@ fn codec_marks_failed_tool_rows_from_the_explicit_turn_sidecar() {
},
)
.unwrap();
- assert!(
- rows[0]
- .tool_failure
- .as_ref()
- .is_some_and(|failure| failure.failed)
- );
+ assert!(rows[0]
+ .tool_failure
+ .as_ref()
+ .is_some_and(|failure| failure.failed));
}
/// The durable record is the parent's OWN spend.
@@ -384,16 +382,14 @@ async fn runtime_adapter_passes_host_context_commits_before_finalize_and_emits_o
.transcripts;
let context = OpenHumanRunContext::new();
let cancellation = context.cancellation.clone();
- let mut session = OpenHumanSessionFactory::build(
- Arc::new(RecordingDriver(Arc::clone(&seen_context))),
- hooks,
- PrefixSnapshot::default(),
- ToolSnapshot::default(),
- Arc::clone(&locator),
- "adapter-test",
- meta(),
- )
- .unwrap();
+ let mut session = SessionBuilder::new(Arc::new(RecordingDriver(Arc::clone(&seen_context))))
+ .codec(Arc::new(OpenHumanTranscriptCodec))
+ .hooks(hooks)
+ .prefix(PrefixSnapshot::default())
+ .tool_snapshot(ToolSnapshot::default())
+ .transcript(Arc::clone(&locator), "adapter-test", meta())
+ .build()
+ .unwrap();
session
.turn(
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index e3a47ebeab..44aadbe0c4 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -32,7 +32,7 @@ use super::types::OpenHumanSessionHost;
use crate::agent::{
message_convert::{user_message_from_text, user_text_with_markers},
session_host::{
- OpenHumanSessionHooks, OpenHumanTranscriptCodec, driver::OpenHumanSessionDriver,
+ driver::OpenHumanSessionDriver, OpenHumanSessionHooks, OpenHumanTranscriptCodec,
},
tinyagents::{host::OpenHumanRunContext, middleware::turn_context::TurnContextMiddleware},
};
@@ -75,8 +75,8 @@ struct OpenHumanTurnPrelude {
context_config: crate::config::ContextConfig,
tool_policy: Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
tool_dispatcher: Arc<dyn tinytools_agent::dialect::ToolDialect>,
workspace_dir: std::path::PathBuf,
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest_tests.rs
index 5ded847bfa..b0cb9e3e6c 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/memory_ingest_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use tinyagents_harness::summarization::{SummaryPlacement, checkpoint_message};
+use tinyagents_harness::summarization::{checkpoint_message, SummaryPlacement};
use tinyinference_llm::ToolCall;
fn assistant_with_call(id: &str, name: &str) -> Message {
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/permanent_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/permanent_tests.rs
index 54fe438700..2137af49b0 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/permanent_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/permanent_tests.rs
@@ -1,6 +1,6 @@
use super::*;
use std::{collections::HashSet, sync::Arc};
-use tinyagents_session::transcript::{SessionRef, session_stem};
+use tinyagents_session::transcript::{session_stem, SessionRef};
use tinyinference_llm::message::Message;
use tinytools::ToolSpec;
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
index 4fa74e3d08..47a0ce7450 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
@@ -265,14 +265,12 @@ fn connected_mcp_actions_enter_search_and_leave_on_disconnect() {
.clear();
prelude.refresh_delegation_tool_surface().unwrap();
assert!(!synthesized_tool_names(&prelude).contains(&action));
- assert!(
- !prelude
- .tool_surface
- .lock()
- .expect("tool surface")
- .deferred_tool_names
- .contains(&action)
- );
+ assert!(!prelude
+ .tool_surface
+ .lock()
+ .expect("tool surface")
+ .deferred_tool_names
+ .contains(&action));
}
#[cfg(feature = "mcp")]
@@ -398,12 +396,10 @@ async fn desktop_browser_setting_keeps_deferred_tools_in_fresh_and_resumed_surfa
.expect("desktop orchestrator");
for name in ["browser", "browser_open"] {
assert!(host.deferred_tool_names.contains(name), "{name}");
- assert!(
- !host
- .visible_tool_specs_arc()
- .iter()
- .any(|spec| spec.name == name)
- );
+ assert!(!host
+ .visible_tool_specs_arc()
+ .iter()
+ .any(|spec| spec.name == name));
}
host.ensure_runtime_session().expect("runtime session");
let prelude = host
@@ -712,18 +708,14 @@ async fn newly_connected_action_cannot_shadow_a_permanent_source() {
mutable.connected_integrations_authoritative = true;
}
let error = prelude.refresh_delegation_tool_surface().unwrap_err();
- assert!(
- error
- .to_string()
- .contains("collision with synthesized tool")
- );
+ assert!(error
+ .to_string()
+ .contains("collision with synthesized tool"));
let surface = prelude.tool_surface.lock().unwrap();
assert!(Arc::ptr_eq(&surface.visible_tool_specs, &before));
assert_eq!(surface.tools[0].description(), "host-owned action");
- assert!(
- !surface
- .synthesized_tools
- .iter()
- .any(|tool| tool.name() == "GMAIL_SEND_EMAIL")
- );
+ assert!(!surface
+ .synthesized_tools
+ .iter()
+ .any(|tool| tool.name() == "GMAIL_SEND_EMAIL"));
}
diff --git a/crates/openhuman-core/src/agent/session_host/stop_summary_tests.rs b/crates/openhuman-core/src/agent/session_host/stop_summary_tests.rs
index 4587673232..874b40ca9f 100644
--- a/crates/openhuman-core/src/agent/session_host/stop_summary_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/stop_summary_tests.rs
@@ -1,6 +1,6 @@
use super::*;
use crate::agent::session_host::turn_checkpoint::{
- CheckpointToolResult, build_deterministic_final_summary,
+ build_deterministic_final_summary, CheckpointToolResult,
};
fn result(name: &str, success: bool, content: &str) -> CheckpointToolResult {
diff --git a/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs b/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs
index 0dc7b76a26..68150cb200 100644
--- a/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs
@@ -22,7 +22,7 @@ use std::collections::{BTreeMap, HashMap};
use std::path::{Path, PathBuf};
use std::sync::{Arc, LazyLock, Mutex};
-use serde_json::{Value, json};
+use serde_json::{json, Value};
use tinyagents_harness::testkit::ScriptedModel;
use tinyagents_session::transcript::{SessionRef, TranscriptLocator};
use tinyinference_llm::message::{AssistantMessage, ContentBlock};
@@ -479,16 +479,14 @@ fn assert_retired_tool_replay(identity_bound: bool) {
&store_locator(root.path()),
"retired-audio-thread",
);
- assert!(
- archived
- .tools
- .as_ref()
- .expect("recorded declarations")
- .as_array()
- .expect("declarations array")
- .iter()
- .any(|spec| spec["name"] == RETIRED)
- );
+ assert!(archived
+ .tools
+ .as_ref()
+ .expect("recorded declarations")
+ .as_array()
+ .expect("declarations array")
+ .iter()
+ .any(|spec| spec["name"] == RETIRED));
let archived_rows = to_json(&archived.messages);
drop(first);
@@ -514,12 +512,10 @@ fn assert_retired_tool_replay(identity_bound: bool) {
.expect("unthreaded session build")
};
if identity_bound {
- assert!(
- resumed
- .resume_bound_session()
- .await
- .expect("resume archive")
- );
+ assert!(resumed
+ .resume_bound_session()
+ .await
+ .expect("resume archive"));
} else {
resumed
.ensure_runtime_session()
diff --git a/crates/openhuman-core/src/agent/session_host/transcript_resume_stable_tests.rs b/crates/openhuman-core/src/agent/session_host/transcript_resume_stable_tests.rs
index 74b228e49d..f22e5913d6 100644
--- a/crates/openhuman-core/src/agent/session_host/transcript_resume_stable_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/transcript_resume_stable_tests.rs
@@ -9,8 +9,8 @@ use serde_json::Value;
use tinyinference_llm::model::ModelResponse;
use super::transcript_compat_tests::{
- Layout, SCENARIOS, build_host, model, place_fixture, run_async, store_locator, store_tree,
- thread_id,
+ build_host, model, place_fixture, run_async, store_locator, store_tree, thread_id, Layout,
+ SCENARIOS,
};
fn tree(
@@ -83,11 +83,9 @@ fn a_legacy_workspace_is_adopted_once_and_the_next_process_resumes_in_place() {
let stem = host.session_id().expect("bound session id");
place_fixture(root.path(), scenario, &stem, "");
imported = legacy_rows(root.path());
- assert!(
- imported
- .iter()
- .all(|rows| !rows.as_array().unwrap().is_empty())
- );
+ assert!(imported
+ .iter()
+ .all(|rows| !rows.as_array().unwrap().is_empty()));
assert!(host.resume_bound_session().await.expect("first resume"));
after_first = tree(root.path(), &thread, &host);
}
diff --git a/crates/openhuman-core/src/agent/session_host/turn_backstop_tests.rs b/crates/openhuman-core/src/agent/session_host/turn_backstop_tests.rs
index 522119c17e..ec76bd6a6a 100644
--- a/crates/openhuman-core/src/agent/session_host/turn_backstop_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/turn_backstop_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use tinyagents_harness::turn_deadline::{TurnDeadline, parse_backstop};
+use tinyagents_harness::turn_deadline::{parse_backstop, TurnDeadline};
#[test]
fn parse_backstop_defaults_and_disables() {
diff --git a/crates/openhuman-core/src/agent/session_host/typed_transcript_compat_tests.rs b/crates/openhuman-core/src/agent/session_host/typed_transcript_compat_tests.rs
index 168aa721fa..3e4c58fba5 100644
--- a/crates/openhuman-core/src/agent/session_host/typed_transcript_compat_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/typed_transcript_compat_tests.rs
@@ -17,13 +17,13 @@
//! committed corpus now.
use crate::agent::session_store::splice_fixture_tests::head_of;
-use serde_json::{Value, json};
+use serde_json::{json, Value};
use tinyinference_llm::message::ContentBlock;
use tinyinference_llm::model::ModelResponse;
use super::transcript_compat_tests::{
- SCENARIOS, Scenario, build_host, call, classic_path, fixture, golden, import_placed, model,
- response, run_async, snapshot_with, store_locator, thread_id,
+ build_host, call, classic_path, fixture, golden, import_placed, model, response, run_async,
+ snapshot_with, store_locator, thread_id, Scenario, SCENARIOS,
};
/// Head fixtures that have a typed re-write (the chain and legacy layouts are
@@ -224,12 +224,10 @@ fn an_old_session_continued_by_this_binary_reloads_identically() {
continued_history
);
let transcript = head_of(&locator, &thread);
- assert!(
- transcript
- .messages
- .iter()
- .any(|row| row.tool_calls.iter().any(|call| call.id == "call_new"))
- );
+ assert!(transcript
+ .messages
+ .iter()
+ .any(|row| row.tool_calls.iter().any(|call| call.id == "call_new")));
});
}
@@ -288,11 +286,9 @@ fn a_live_image_turn_persists_typed_image_parts_and_resumes_identically() {
);
assert!(!raw.contains("[IMAGE:"), "no text marker is persisted");
- assert!(
- serde_json::to_string(&vision.0.requests())
- .unwrap()
- .contains(png)
- );
+ assert!(serde_json::to_string(&vision.0.requests())
+ .unwrap()
+ .contains(png));
let mut second = build_live_image_host(root.path(), live_image_model("unused"), &thread);
assert!(second.resume_bound_session().await.expect("resume"));
diff --git a/crates/openhuman-core/src/agent/session_host/types.rs b/crates/openhuman-core/src/agent/session_host/types.rs
index 589ee430a0..a1a71393a2 100644
--- a/crates/openhuman-core/src/agent/session_host/types.rs
+++ b/crates/openhuman-core/src/agent/session_host/types.rs
@@ -442,8 +442,8 @@ pub struct OpenHumanSessionHost {
/// behaviour unless a caller opts into stricter policy.
pub(super) tool_policy: Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
/// Hash of the Composio connection set this OpenHumanSessionHost last reconciled
/// against. Compared at top-of-turn to a fresh hash computed from
@@ -632,8 +632,8 @@ pub struct SessionHostBuilder {
pub(super) tool_policy: Option<
Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
>,
}