Skip to content

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

refactor(session-host): build system prompt from session prompt builder

Steven Enamakel4dfb3f25a55c
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 b1e024b2e5..dbf81d0402 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/setters.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
@@ -164,10 +164,8 @@ impl SessionHostBuilder {
self
}
- /// Sets the global context-management configuration. Threaded
- /// into the [`ContextManager`] constructed in [`Self::build`]. If
- /// not set the manager is constructed with
- /// [`ContextConfig::default`].
+ /// Sets the context middleware configuration used by this session. If
+ /// unset, [`ContextConfig::default`] applies.
pub fn context_config(mut self, context_config: ContextConfig) -> Self {
self.context_config = Some(context_config);
self
diff --git a/crates/openhuman-core/src/agent/session_host/turn/context.rs b/crates/openhuman-core/src/agent/session_host/turn/context.rs
index 8d5d486578..2d642835a8 100644
--- a/crates/openhuman-core/src/agent/session_host/turn/context.rs
+++ b/crates/openhuman-core/src/agent/session_host/turn/context.rs
@@ -66,14 +66,7 @@ impl OpenHumanSessionHost {
agents_md_global: agents_md.global,
agents_md_local: agents_md.local,
};
- // Route through the global context manager so every
- // prompt-building call-site — main agent, sub-agent runner,
- // channel runtimes — shares one builder configuration.
- let prompt = self
- .context
- .lock()
- .unwrap_or_else(std::sync::PoisonError::into_inner)
- .build_system_prompt(&ctx)?;
+ let prompt = self.prompt_builder.build(&ctx)?;
// Appended, not prepended (#5704). Every line of this block is
// session-scoped — agent id, channel, entry point, risk level, the
// allowed-tool list — so putting it first moves the prompt's first
diff --git a/crates/openhuman-core/src/agent/session_host/turn/graph.rs b/crates/openhuman-core/src/agent/session_host/turn/graph.rs
index d3cafda3ae..6da5dc18d5 100644
--- a/crates/openhuman-core/src/agent/session_host/turn/graph.rs
+++ b/crates/openhuman-core/src/agent/session_host/turn/graph.rs
@@ -76,7 +76,7 @@ pub(crate) struct ChatTurnGraph {
/// Session run queue for mid-flight steering.
pub run_queue: Option<Arc<RunQueue<crate::agent::queued_turn::QueuedTurn>>>,
/// openhuman context middlewares (cache-align, microcompact, tool-output
- /// budget + payload summarizer) sourced from the session's `ContextManager`.
+ /// budget + payload summarizer) sourced from the session's context config.
pub context_mw: TurnContextMiddleware,
/// The agent's builder-configured tool policy + session context, enforced at
/// the tool boundary. `None` when the session has no explicit policy.
@@ -160,7 +160,7 @@ pub(crate) async fn run_chat_turn_graph(graph: ChatTurnGraph) -> Result<Tinyagen
// Bound the main agent's per-call output (legacy parity — the engine
// capped every turn at `AGENT_TURN_MAX_OUTPUT_TOKENS`).
max_output_tokens: Some(AGENT_TURN_MAX_OUTPUT_TOKENS),
- // Context middlewares sourced from the session's ContextManager.
+ // Context middlewares sourced from the session's context config.
context_mw: graph.context_mw,
// Builder-configured tool policy enforcement (session chat path).
tool_policy: graph.tool_policy,