The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(session_host): extract chat turn spec construction
Steven Enamakel30d125652539
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rsindex aaf0548a73..bc97281b62 100644--- a/crates/openhuman-core/src/agent/session_host/driver.rs+++ b/crates/openhuman-core/src/agent/session_host/driver.rs@@ -8,7 +8,6 @@ mod grounded_close;use std::{collections::HashSet, sync::Arc, time::Instant};-use crate::agent::tinyagents::TurnSpec;use async_trait::async_trait;use tinyagents_runtime::{DriverFailure, DriverOutcome, DriverRequest, RuntimeError, SessionDriver, TranscriptPartial,@@ -17,6 +16,7 @@ use tinyagents_session::transcript::TranscriptMessage;use tinyinference_llm::message::Message;use tinytools_agent::dialect::ToolDialect;+use crate::agent::session_host::turn::chat_spec::build_chat_turn_spec;use crate::agent::tinyagents::{host::OpenHumanHostBase, host::OpenHumanRunContext, TurnModelSource,};@@ -194,36 +194,23 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {"hosted root invocation is unavailable because the session has no hosted authority")})?;- let provider_id = turn_models.provider_id().to_string();let mut run_context = run_context;run_context.workspace = self.workspace.clone().or(run_context.workspace);run_context.sandbox_mode = Some(self.sandbox_mode);- TurnSpec {+ build_chat_turn_spec(run_context,turn_models,- provider_id,- model: &self.model_name,- history: messages,- // Keep durable and synthesized registrations in the same order- // as the runtime snapshot, so each advertised name resolves to- // the executable instance that owns it.- tool_sets: vec![tools, synthesized_tools],- // `Some(empty)` is authoritative deny-all; `None` would expose- // the construction-time registry.- allowed: Some(visible_tool_names),- max_iterations: self.max_iterations,- subagent_scope: None,+ &self.model_name,+ messages,+ tools,+ synthesized_tools,+ visible_tool_names,+ self.max_iterations,context_window,- run_queue: self.run_queue.clone(),- message_run_queue: None,- early_exit_tools: &["ask_user_clarification"],- pause_at_cap: true,- max_output_tokens: Some(crate::inference::provider::AGENT_TURN_MAX_OUTPUT_TOKENS),+ self.run_queue.clone(),context_mw,- tool_policy: Some(tool_policy),- deterministic_cacheable: false,- defer_turn_completed_to_caller: true,- }+ tool_policy,+ ).run_hosted(hosted_base, self.agent_id.clone()).await});diff --git a/crates/openhuman-core/src/agent/session_host/turn/chat_spec.rs b/crates/openhuman-core/src/agent/session_host/turn/chat_spec.rsnew file mode 100644index 0000000000..c24cff733e--- /dev/null+++ b/crates/openhuman-core/src/agent/session_host/turn/chat_spec.rs@@ -0,0 +1,56 @@+//! Product-to-harness configuration for one hosted chat turn.++use std::{collections::HashSet, sync::Arc};++use tinyagents_session::transcript::TranscriptMessage;+use tinytools::Tool;++use crate::agent::tinyagents::{host::OpenHumanRunContext, TurnModels, TurnSpec};++/// Map the session's request-scoped execution inputs onto TinyAgents' one+/// hosted turn specification. The driver still owns authority validation and+/// invokes `run_hosted` inside its cancellation and snapshot boundary.+#[allow(clippy::too_many_arguments)]+pub(super) fn build_chat_turn_spec<'a>(+ run_context: OpenHumanRunContext,+ turn_models: TurnModels,+ model: &'a str,+ messages: Vec<TranscriptMessage>,+ tools: Arc<Vec<Box<dyn Tool>>>,+ synthesized_tools: Arc<Vec<Box<dyn Tool>>>,+ visible_tool_names: HashSet<String>,+ max_iterations: usize,+ context_window: Option<u64>,+ run_queue: Option<+ Arc<tinyagents_harness::run_queue::RunQueue<crate::agent::queued_turn::QueuedTurn>>,+ >,+ context_mw: crate::agent::tinyagents::middleware::turn_context::TurnContextMiddleware,+ tool_policy: crate::agent::tinyagents::ToolPolicyEnforcement,+) -> TurnSpec<'a> {+ let provider_id = turn_models.provider_id().to_string();+ TurnSpec {+ run_context,+ turn_models,+ provider_id,+ model,+ history: messages,+ // Durable and synthesized registrations follow the same order as the+ // runtime snapshot, so advertised names resolve to matching instances.+ tool_sets: vec![tools, synthesized_tools],+ // `Some(empty)` is authoritative deny-all; `None` exposes the+ // construction-time registry.+ allowed: Some(visible_tool_names),+ max_iterations,+ subagent_scope: None,+ context_window,+ run_queue,+ message_run_queue: None,+ early_exit_tools: &["ask_user_clarification"],+ pause_at_cap: true,+ max_output_tokens: Some(crate::inference::provider::AGENT_TURN_MAX_OUTPUT_TOKENS),+ context_mw,+ tool_policy: Some(tool_policy),+ deterministic_cacheable: false,+ defer_turn_completed_to_caller: true,+ }+}diff --git a/crates/openhuman-core/src/agent/session_host/turn/mod.rs b/crates/openhuman-core/src/agent/session_host/turn/mod.rsindex e01ca7d84a..4ea89d0c2c 100644--- a/crates/openhuman-core/src/agent/session_host/turn/mod.rs+++ b/crates/openhuman-core/src/agent/session_host/turn/mod.rs@@ -3,4 +3,5 @@//! Generic turn lifecycle is intentionally absent: it is owned by//! `tinyagents_runtime::Session` in `runtime_session`.+pub(super) mod chat_spec;mod context;