Skip to content

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

feat(agent): add runtime session host and subagent graph dispatch

Steven Enamakelb4cc60beb8a9
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 65b0f496a8..8474ba212d 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -735,9 +735,16 @@ impl OpenHumanSessionHost {
&self.event_session_id,
);
+ // `[components] juice = false`: tool output is truncated only, never
+ // compacted or summarized, and the module is never called for it.
+ let juice_on = self
+ .runtime_config
+ .as_ref()
+ .map_or(true, |config| crate::inference::tokenjuice::enabled(config));
+ let tokenjuice_compaction_enabled = tokenjuice_compaction_enabled && juice_on;
let context_mw = TurnContextMiddleware {
tool_result_budget_bytes,
- payload_summarizer: self.payload_summarizer.clone(),
+ payload_summarizer: self.payload_summarizer.clone().filter(|_| juice_on),
// Rooted outside the project; see `artifact_wiring` (#6408, #6483).
artifact_store: Some(artifact_store),
tokenjuice_compaction_enabled,
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
index f61196e07b..235cb2f089 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs
@@ -539,7 +539,8 @@ fn build_subagent_context_mw(
// TokenJuice content-aware compaction gates on the same master
// `[context].compaction_enabled` the chat path reads
// (`ContextManager::compaction_enabled`).
- mw.tokenjuice_compaction_enabled = ctx.compaction_enabled;
+ mw.tokenjuice_compaction_enabled =
+ ctx.compaction_enabled && crate::inference::tokenjuice::enabled(config);
mw.tool_result_budget_bytes = ctx.tool_result_budget_bytes;
// Microcompact keep-recent is `0` (disabled) unless microcompact is on.
mw.microcompact_keep_recent = if ctx.microcompact_enabled {
diff --git a/crates/openhuman-core/src/modules/host.rs b/crates/openhuman-core/src/modules/host.rs
index c4c9ab414f..a60447476f 100644
--- a/crates/openhuman-core/src/modules/host.rs
+++ b/crates/openhuman-core/src/modules/host.rs
@@ -185,7 +185,15 @@ async fn build_runtime() -> tinybus::Result<ModuleRuntime> {
let host = ModuleHost::new(broker);
let connection = Connection::connect(transport.connect().await?).await?;
- super::tokenjuice_host::install(&connection).await?;
+ // The summary callback exists for the module alone; with the component off
+ // the module never loads, so nothing would call it.
+ let juice_on = crate::core::runtime::context::CoreContext::current()
+ .map_or(true, |ctx| ctx.components().juice);
+ if juice_on {
+ super::tokenjuice_host::install(&connection).await?;
+ } else {
+ tracing::debug!("[modules] juice component off; MlHost not served");
+ }
super::storage_host::install(&connection).await?;
#[cfg(feature = "web3")]
super::wallet_host::install(&connection).await?;
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index 2aadced35c..73a29c9114 100644
--- a/crates/openhuman-core/src/tools/ops.rs
+++ b/crates/openhuman-core/src/tools/ops.rs
@@ -121,14 +121,6 @@ pub fn all_tools_with_runtime(
));
tools.append(&mut vec![
Box::new(CurrentTimeTool::new()),
- // Reversibility for native tool-output compaction (Stage 1a): when a
- // large result is compacted with a `retrieve_tool_output("<hash>")`
- // marker, this hands the original back from the CCR store on demand.
- Box::new(retrieve_tool_output_tool()),
- // TokenJuice 2.0 content-router retrieval: fetches the original (full or
- // by byte/line range) for a `⟦tj:<hash>⟧` marker from the CCR cache.
- // Supersedes `retrieve_tool_output`; both are kept live during migration.
- Box::new(crate::inference::tokenjuice::TokenjuiceRetrieveTool::new()),
// Deterministic time-expression → timestamp resolver. `current_time`
// only returns *now*, leaving the model to do epoch arithmetic by hand
// (a real incident had an agent compute "24h ago" ~10 months off, then
@@ -248,6 +240,19 @@ pub fn all_tools_with_runtime(
tracing::debug!("[tools::ops] memory off; memory tool not registered");
}
+ // Recovery tools for compacted output (`retrieve_tool_output` for the
+ // Stage 1a marker, `juice_retrieve` for `⟦tj:<hash>⟧`; both live during
+ // migration): only while `[components] juice` is on, since with it off
+ // nothing is compacted and nothing can hand out a marker.
+ if crate::inference::tokenjuice::enabled(root_config) {
+ tools.push(Box::new(retrieve_tool_output_tool()));
+ tools.push(Box::new(
+ crate::inference::tokenjuice::TokenjuiceRetrieveTool::new(),
+ ));
+ } else {
+ tracing::debug!("[tools::ops] juice component off; recovery tools not registered");
+ }
+
// `juice_find` / `juice_extract` / `juice_summarize`: only while a handle can name them.
tools.extend(crate::inference::tokenjuice::repl_tools_for(root_config));