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
fix(agent): a turn that suppresses the thread goal gets no run-state block
sanil-23b9519a702d56
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rsindex 680a5e99cb..ea50fae664 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs@@ -241,6 +241,7 @@ impl OpenHumanTurnPrelude {// replaces or leaves it with the goal tools. Turns with the run-state// block see the goal there, current on every call, so it is not also// prepended to the user's message.+ run_context.goal_suppressed = turn.overrides.suppress_active_goal;let active_goal = if turn.overrides.suppress_active_goal {None} else {diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_goal_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_goal_tests.rsindex 921d288bad..642028aef6 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session_goal_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_goal_tests.rs@@ -106,3 +106,35 @@ async fn a_turn_without_the_state_block_still_carries_the_active_goal() {"{message}");}++/// A turn that suppresses the thread goal tells the run context, so the+/// run-state block (which reads the goal from the store) stays off that turn.+#[tokio::test]+async fn a_suppressed_goal_reaches_the_run_context() {+ let (host, tmp) = host_for("orchestrator");+ goal_store::set(&store(&tmp), THREAD, "Migrate the auth schema", None)+ .await+ .unwrap();+ let prelude = host+ .runtime_state+ .lock()+ .unwrap_or_else(|poisoned| poisoned.into_inner())+ .prelude+ .clone()+ .expect("prelude");+ for suppress in [false, true] {+ let inputs = crate::agent::session_host::types::TurnInputs {+ overrides: crate::agent::session_host::types::TurnOverrides {+ suppress_active_goal: suppress,+ ..Default::default()+ },+ ..Default::default()+ };+ let mut run_context = OpenHumanRunContext::new();+ let message = prelude+ .enrich_request("hey", &inputs, &mut run_context)+ .await;+ assert_eq!(run_context.goal_suppressed, suppress);+ assert!(!message.contains("Migrate the auth schema"), "{message}");+ }+}diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rsindex 8c05862c23..319a36f34b 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs@@ -184,6 +184,10 @@ pub struct OpenHumanRunContext {pub progress: Option<Sender<AgentProgress>>,/// Stop policies evaluated after each model call.pub stop_hooks: Vec<Arc<dyn StopHook<tinyagents_harness::cost::TurnCost>>>,+ /// The turn runs with `TurnOverrides::suppress_active_goal`: the thread+ /// goal must not reach the model this turn. Set by the turn prelude; the+ /// run-state block (which reads the goal from the store) follows it.+ pub goal_suppressed: bool,/// Agent/turn tool callbacks, registered after the runtime's global ones.pub tool_hooks: Vec<Arc<dyn tinyagents_hooks::tool::ToolHook<OpenHumanRunContext>>>,/// Host cap on real tool invocations for this turn tree; `None` leaves the@@ -339,6 +343,7 @@ impl OpenHumanRunContext {approval: Default::default(),progress: None,stop_hooks: Vec::new(),+ goal_suppressed: false,tool_hooks: Vec::new(),tool_call_limit: None,untrusted_input_turn: false,diff --git a/crates/openhuman-core/src/agent/tinyagents/state_block.rs b/crates/openhuman-core/src/agent/tinyagents/state_block.rsindex 1fd16a0b05..a4eb9ade1c 100644--- a/crates/openhuman-core/src/agent/tinyagents/state_block.rs+++ b/crates/openhuman-core/src/agent/tinyagents/state_block.rs@@ -34,12 +34,26 @@ pub(crate) fn applies(is_subagent: bool, agent_definition_id: Option<&str>) -> b/// Installs the block for a turn in scope that has the session store the goal/// and `todo` tools write, with the key the `todo` tool falls back to when the/// turn has no thread (the session id).+///+/// A turn that suppresses the thread goal (`goal_suppressed`, from+/// `TurnOverrides::suppress_active_goal`: a conversational reply, a flow or a+/// cron run) gets no block: the block reads the goal from the store, and the+/// goal must not reach that turn. Until TinyAgents' `hide_goal` is pinned, the+/// plan and notes are left out with it, as on a turn without the block.pub(super) fn install<C: Send + Sync + 'static>(harness: &mut AgentHarness<(), C>,source: Option<(Arc<dyn Store>, String)>,is_subagent: bool,agent_definition_id: Option<&str>,+ goal_suppressed: bool,) {+ if goal_suppressed {+ tracing::debug!(+ agent = agent_definition_id.unwrap_or("<none>"),+ "[state_block] not installed: this turn suppresses the thread goal"+ );+ return;+ }match source {Some((store, fallback_thread)) if applies(is_subagent, agent_definition_id) => {harness.push_middleware(Arc::new(diff --git a/crates/openhuman-core/src/agent/tinyagents/state_block_tests.rs b/crates/openhuman-core/src/agent/tinyagents/state_block_tests.rsindex 206013c7dd..3254e9ce5f 100644--- a/crates/openhuman-core/src/agent/tinyagents/state_block_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/state_block_tests.rs@@ -21,6 +21,7 @@ fn install_needs_the_scope_and_a_store() {store.map(|store| (store, "standalone".to_string())),is_subagent,agent,+ false,);harness.middleware().len() - before};@@ -36,6 +37,27 @@ fn install_needs_the_scope_and_a_store() {assert_eq!(installed(Some(store), false, Some("planner")), 0);}+/// A turn that suppresses the thread goal (`suppress_active_goal`) gets no+/// block: the block would show the goal it must not see.+#[test]+fn a_turn_that_suppresses_the_goal_gets_no_block() {+ let store: Arc<dyn Store> = Arc::new(InMemoryStore::default());+ let installed = |goal_suppressed: bool| {+ let mut harness = AgentHarness::<(), ()>::new();+ let before = harness.middleware().len();+ install(+ &mut harness,+ Some((store.clone(), "standalone".to_string())),+ false,+ Some("orchestrator"),+ goal_suppressed,+ );+ harness.middleware().len() - before+ };+ assert_eq!(installed(false), 1);+ assert_eq!(installed(true), 0);+}+#[tokio::test]async fn a_finished_plan_hands_its_notes_over_at_the_end_of_the_turn() {use tinyagents_harness_tools::scratchpad::ScratchpadUpdate;diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rsindex 6f20a53d30..31d3bd3a93 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs@@ -592,6 +592,7 @@ async fn drive_turn(parent.session_id.clone(),)}),+ goal_suppressed: run_context.goal_suppressed,},);if let Some(scope) = run_context.response_shape.clone() {diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rsindex f8c8d6423d..64ce426c8a 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs@@ -110,6 +110,8 @@ pub(super) struct TurnMiddlewareInputs {/// With the scope the `todo` tool uses on a turn without a thread (the/// session id), so a headless turn's block still finds its plan.pub(super) state_store: Option<(Arc<dyn tinyagents_harness::store::Store>, String)>,+ /// The turn suppresses the thread goal (`TurnOverrides::suppress_active_goal`).+ pub(super) goal_suppressed: bool,}/// The handles the run loop reads after the drive returns.@@ -163,6 +165,7 @@ pub(super) fn install_turn_middleware(todo_store,compaction_notice,state_store,+ goal_suppressed,} = inputs;let super::host::HarnessHostPolicy {stop_hooks,@@ -531,7 +534,7 @@ pub(super) fn install_turn_middleware(// The goal, the plan and the turn's tool-call facts on every model call,// request-only. On these turns the goal is not prepended to the user's// message (see `state_block`).- super::state_block::install(harness, state_store, is_subagent, agent_id);+ super::state_block::install(harness, state_store, is_subagent, agent_id, goal_suppressed);// Direct web lookup is bounded. Once enough search/fetch results have// returned, the web tools leave the request so the run works with what it