Skip to content

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

feat(agent): honor TurnOverrides in turn() — skip goal/tools/memory\n\nturn() now takes the pending overrides at its top (resetting them, so\nthey apply to one turn only) and:\n\n- suppress_active_goal: skips loading, auto-resuming, injecting, and\n budget-arming this thread's goal, so a prior task's uncompleted goal\n cannot steer an unrelated chat turn;\n- suppress_tools: sends an EMPTY tool schema for this turn (durable\n self.tools untouched), so the model cannot enter the tool loop;\n- suppress_memory_agent: skips the pre-turn agent_memory retrieval even\n when the agent's policy is Always.\n\nRefs tinyhumansai/opencompany#1725.\n\n

oxoxDev6df31394f27b
diff --git a/src/openhuman/agent/harness/session/turn/core.rs b/src/openhuman/agent/harness/session/turn/core.rs
index 9d793fa1a8..df745b6c60 100644
--- a/src/openhuman/agent/harness/session/turn/core.rs
+++ b/src/openhuman/agent/harness/session/turn/core.rs
@@ -180,6 +180,21 @@ impl Agent {
/// 6. **Background Tasks**: Triggers episodic memory indexing and facts
/// extraction asynchronously.
pub async fn turn(&mut self, user_message: &str) -> Result<String> {
+ // Consume any per-turn overrides the caller set for THIS turn (#1725).
+ // Taking them resets the field to the default, so they apply to exactly
+ // one turn — a chat/small-talk turn runs tool-less, memory-less and
+ // goal-less without permanently altering the agent, and the following
+ // turn is back to full-agentic behaviour. Callers that never opt in get
+ // `TurnOverrides::default()` (all-false) and the unchanged path.
+ let turn_overrides = std::mem::take(&mut self.pending_turn_overrides);
+ if turn_overrides != super::super::types::TurnOverrides::default() {
+ log::info!(
+ "[agent_loop] per-turn overrides active: suppress_active_goal={} suppress_tools={} suppress_memory_agent={}",
+ turn_overrides.suppress_active_goal,
+ turn_overrides.suppress_tools,
+ turn_overrides.suppress_memory_agent
+ );
+ }
self.emit_progress(AgentProgress::TurnStarted).await;
log::info!("[agent] turn started — awaiting user message processing");
log::info!(
@@ -516,7 +531,16 @@ impl Agent {
// Capture the workspace path for the budget stop hook built after the
// `turn_body` coroutine (which borrows `&mut self`) is constructed.
let goal_workspace_dir = self.workspace_dir.clone();
- let active_goal = {
+ let active_goal = if turn_overrides.suppress_active_goal {
+ // Chat / small-talk turn: do NOT load, auto-resume, inject, or
+ // budget-arm this thread's goal. A goal an earlier task left
+ // uncompleted must not steer an unrelated greeting (#1725, the
+ // "stale goal replays every turn" half of the context leak).
+ log::debug!(
+ "[thread_goals] active_goal suppressed for this turn (chat/small-talk override)"
+ );
+ None
+ } else {
let loaded = crate::openhuman::threads::goals::runtime::load_for_current_thread(
&self.workspace_dir,
)
@@ -681,7 +705,12 @@ impl Agent {
// turn and finishes in the background if the work runs long. So the recall
// path is byte-for-byte identical across voice and chat.
let (enriched, memory_agent_context_injected) = self
- .inject_triggered_memory_agent_context(user_message, enriched, &parent_context)
+ .inject_triggered_memory_agent_context(
+ user_message,
+ enriched,
+ &parent_context,
+ turn_overrides.suppress_memory_agent,
+ )
.await;
if memory_agent_context_injected {
agent_context_prepared_sources.push(harness::AgentContextPreparedSource {
@@ -748,6 +777,7 @@ impl Agent {
temperature,
max_iterations,
artifact_store,
+ turn_overrides.suppress_tools,
))
.await
}; // end of `turn_body` async block
@@ -868,6 +898,7 @@ impl Agent {
artifact_store: Option<
crate::openhuman::agent::harness::tool_result_artifacts::ToolResultArtifactStore,
>,
+ suppress_tools: bool,
) -> Result<String> {
let turn_started = std::time::Instant::now();
// This turn's stamped user message is already the last entry in
@@ -933,10 +964,25 @@ impl Agent {
.map(|prepared| prepared.messages)
.unwrap_or(messages);
+ // Per-turn tool scope (#1725). A chat / small-talk turn runs with an
+ // EMPTY tool set: the provider request carries no tool schema, so the
+ // model cannot enter the tool loop and answers in a single call. The
+ // agent's durable `self.tools` / `self.visible_tool_names` are left
+ // untouched — the next un-overridden turn gets the full toolbelt back.
+ let (turn_tools, turn_visible_tool_names) = if suppress_tools {
+ (
+ std::sync::Arc::new(Vec::new()),
+ std::collections::HashSet::new(),
+ )
+ } else {
+ (self.tools.clone(), self.visible_tool_names.clone())
+ };
+
tracing::info!(
model = %effective_model,
max_iterations,
- tools = self.tools.len(),
+ tools = turn_tools.len(),
+ suppress_tools,
"[agent_loop] routing chat turn through the tinyagents harness"
);
@@ -990,8 +1036,8 @@ impl Agent {
turn_models,
model: effective_model.to_string(),
messages,
- tools: self.tools.clone(),
- visible_tool_names: self.visible_tool_names.clone(),
+ tools: turn_tools,
+ visible_tool_names: turn_visible_tool_names,
max_iterations,
on_progress: self.on_progress.clone(),
context_window,
@@ -1429,10 +1475,23 @@ impl Agent {
user_message: &str,
enriched: String,
parent_context: &ParentExecutionContext,
+ force_skip: bool,
) -> (String, bool) {
const MEMORY_AGENT_ID: &str = "agent_memory";
const MAX_MEMORY_AGENT_BLOCK_CHARS: usize = 8000;
+ if force_skip {
+ // Per-turn override (#1725): a chat / small-talk turn skips the
+ // pre-turn memory-agent retrieval even when this agent's policy is
+ // `Always`, so a greeting never pulls a prior task's remembered
+ // context into an unrelated reply.
+ log::debug!(
+ "[agent_memory:trigger] skipped agent_id={} (per-turn suppress_memory_agent override)",
+ self.agent_definition_id
+ );
+ return (enriched, false);
+ }
+
if self.trigger_memory_agent != TriggerMemoryAgent::Always {
log::debug!(
"[agent_memory:trigger] skipped agent_id={} policy={:?}",