Skip to content

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

fix(subagent): remove context_scout special-casing and simplify context-prep messages

Steven Enamakelec884cc4f597
diff --git a/crates/openhuman-core/src/agent/harness/fork_context.rs b/crates/openhuman-core/src/agent/harness/fork_context.rs
index 7ff9125ed9..3ad06b8cd3 100644
--- a/crates/openhuman-core/src/agent/harness/fork_context.rs
+++ b/crates/openhuman-core/src/agent/harness/fork_context.rs
@@ -174,9 +174,9 @@ tokio::task_local! {
/// direct tool calls); `spawn_subagent` rejects in that case.
pub static PARENT_CONTEXT: ParentExecutionContext;
- /// Context-preparation sources that already ran for this parent turn.
- /// Tools such as `agent_prepare_context` use this to avoid spawning a
- /// second context scout after the harness has already prepared context.
+ /// Context-preparation sources that already ran for this parent turn,
+ /// so downstream code can tell the harness has already prepared context
+ /// and avoid gathering it a second time.
///
pub static AGENT_CONTEXT_PREPARED_SOURCES: Arc<Vec<AgentContextPreparedSource>>;
}
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 0523fb0304..eb72d37b52 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -1214,8 +1214,7 @@ fn render_agent_context_status_note(
};
format!(
"## Agent context status\n\nAgent context retrieval/preparation has already run once \
- for this turn in code via {sources}. Do not call `agent_prepare_context` again for \
- general context preparation. Use the prepared context below, and call only specific \
+ for this turn in code via {sources}. Do not gather general context again. Use the prepared context below, and call only specific \
follow-up tools if a concrete missing detail is required."
)
}
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs b/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
index 9f6748a2cc..ddaef49512 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
@@ -39,21 +39,6 @@ Do not include facts in Answer that are not supported by Evidence used or Action
If a tool result was truncated, partial, or too large to inspect fully, say so under Open uncertainties and do not treat it as complete.\n";
pub(crate) fn append_subagent_role_contract(base_prompt: String, agent_id: &str) -> String {
- // `context_scout` defines its own strict output contract (emit a single
- // `[context_bundle]` and nothing else). The generic Result Contract here
- // (Answer / Evidence used / Actions taken / …) directly conflicts with
- // that and can make the scout emit the generic headings instead of the
- // bundle — leaving the orchestrator without `has_enough_context` /
- // `recommended_tool_calls`. Skip the suffix for the scout; its prompt.md
- // already carries the sub-agent framing it needs.
- if agent_id == "context_scout" {
- tracing::debug!(
- agent_id = %agent_id,
- "[subagent_host] skipping role-contract suffix — agent defines its own output contract"
- );
- return base_prompt;
- }
-
if base_prompt.contains(SUBAGENT_ROLE_CONTRACT_SUFFIX.trim()) {
tracing::debug!(
agent_id = %agent_id,
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/prompt_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/prompt_tests.rs
index 9ceab5f562..c0499f3f32 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/prompt_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/prompt_tests.rs
@@ -1,15 +1,5 @@
use super::*;
-#[test]
-fn context_scout_skips_role_contract_suffix() {
- // The scout owns its own [context_bundle] output contract; the generic
- // result contract must not be appended (it conflicts).
- let base = "scout prompt body".to_string();
- let out = append_subagent_role_contract(base.clone(), "context_scout");
- assert_eq!(out, base);
- assert!(!out.contains("Sub-agent Result Contract"));
-}
-
#[test]
fn other_agents_get_role_contract_suffix() {
let out = append_subagent_role_contract("body".to_string(), "researcher");
diff --git a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
index 819ccbc7f9..a0ccdecbb5 100644
--- a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
@@ -225,12 +225,6 @@ pub(crate) fn subagent_prompt_protocol(
/// * every synthesised per-archetype `delegate_*` tool
/// ([`crate::tools::orchestrator_tools::collect_orchestrator_tools`]
/// emits `delegate_code_executor`, `delegate_planner`, …).
-/// * `agent_prepare_context` — the context-scout entry point. It reads the
-/// *parent's* visible catalog/session via `current_parent()`, which inside a
-/// nested run is still the top-level orchestrator (the runner does not
-/// install a child-scoped parent context). A wildcard or named sub-agent
-/// calling it would therefore scout against the orchestrator's surface, not
-/// its own. Context preparation is a top-level concern only.
///
/// Kept as a tight prefix/exact match rather than a registry lookup so
/// the strip is cheap to run inside [`super::ops::run_typed_mode`]'s
@@ -238,8 +232,7 @@ pub(crate) fn subagent_prompt_protocol(
/// this function and the corresponding generator in
/// `orchestrator_tools.rs` together.
pub(super) fn is_subagent_spawn_tool(name: &str) -> bool {
- if name == "spawn_subagent" || name.starts_with("delegate_") || name == "agent_prepare_context"
- {
+ if name == "spawn_subagent" || name.starts_with("delegate_") {
return true;
}
// Synthesised delegation tools are named by the target agent's