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): prompt-size measures the provider-facing belt, not the registry
M3gA-Mind6e94e3b4e186
diff --git a/crates/openhuman-core/src/agent/debug/mod.rs b/crates/openhuman-core/src/agent/debug/mod.rsindex bcde344a46..6f32101717 100644--- a/crates/openhuman-core/src/agent/debug/mod.rs+++ b/crates/openhuman-core/src/agent/debug/mod.rs@@ -97,8 +97,10 @@ pub struct DumpedPrompt {pub tool_names: Vec<String>,/// Number of `ToolCategory::Workflow` tools in the dump.pub skill_tool_count: usize,- /// One `{name, description, parameters}` entry per tool the agent- /// exposes, in the same order as [`Self::tool_names`].+ /// One `{name, description, parameters}` entry per tool schema the+ /// provider receives. On the session path this is the visible set, which+ /// is narrower than [`Self::tool_names`]; on the per-toolkit path the two+ /// match, in the same order.////// The system prompt is only half of a turn's fixed cost: the tool/// schemas ride alongside it in every request, and for an agent with a@@ -107,12 +109,7 @@ pub struct DumpedPrompt {pub tool_specs: Vec<serde_json::Value>,}-// The `+ 'a` is load-bearing: a bare `dyn Tool` here means `dyn Tool +-// 'static`, which `Box<dyn Tool>` satisfies but a borrowed `&'a dyn Tool` (what-// `Agent::all_tool_refs` yields) does not.-fn tool_specs_of<'a, T: std::ops::Deref<Target = dyn crate::tools::Tool + 'a>>(- tools: &[T],-) -> Vec<serde_json::Value> {+fn tool_specs_of(tools: &[Box<dyn Tool>]) -> Vec<serde_json::Value> {tools.iter().map(|t| {@@ -282,17 +279,29 @@ async fn render_via_session(config: &Config, agent_id: &str) -> Result<DumpedPro.build_system_prompt(LearnedContextData::default()).with_context(|| format!("rendering system prompt for `{agent_id}`"))?;+ Ok(session_dump(&agent, agent_id, text))+}++/// Package a built session agent's rendered prompt and tool surface.+fn session_dump(agent: &Agent, agent_id: &str, text: String) -> DumpedPrompt {// The whole callable surface, so the dump shows the `delegate_*` tools// the refresh above just synthesised alongside the durable registry.let tools = agent.all_tool_refs();let tool_names: Vec<String> = tools.iter().map(|t| t.name().to_string()).collect();- let tool_specs = tool_specs_of(&tools);let skill_tool_count = tools.iter().filter(|t| t.category() == ToolCategory::Workflow).count();+ // Schemas are what the provider is actually sent: the visible,+ // policy-filtered set, not the registry above. Measuring+ // `all_tool_refs()` here (d149ab0f0) reported ~200 tools for every agent.+ let tool_specs = agent+ .visible_tool_specs_arc()+ .iter()+ .map(|spec| serde_json::to_value(spec.as_ref()).unwrap_or_default())+ .collect();- Ok(DumpedPrompt {+ DumpedPrompt {agent_id: agent_id.to_string(),toolkit: None,mode: "session",@@ -302,7 +311,7 @@ async fn render_via_session(config: &Config, agent_id: &str) -> Result<DumpedProtool_names,skill_tool_count,tool_specs,- })+ }}/// Render the integrations_agent prompt bound to a single Composiodiff --git a/crates/openhuman-core/src/agent/debug/prompt_size.rs b/crates/openhuman-core/src/agent/debug/prompt_size.rsindex 56a098240a..576407af08 100644--- a/crates/openhuman-core/src/agent/debug/prompt_size.rs+++ b/crates/openhuman-core/src/agent/debug/prompt_size.rs@@ -78,9 +78,10 @@ pub struct PromptSizeReport {pub tool_bytes: usize,/// `prompt_bytes + tool_bytes` — the fixed cost of every turn.pub fixed_prefix_bytes: usize,- /// Number of tools whose schemas reach the provider. This is the- /// *advertised* set, already narrowed by the agent's `ToolScope` belt and- /// by toolpack withholding.+ /// Number of entries in [`DumpedPrompt::tool_specs`]. For a session agent+ /// that is the provider-facing visible set (belt, policy and toolpack+ /// withholding applied); for an `integrations_agent` toolkit dump it is+ /// that toolkit's rendered tools.pub tool_count: usize,pub sections: Vec<SectionSize>,pub tools: Vec<ToolSize>,diff --git a/crates/openhuman-core/src/agent/debug/prompt_size_tests.rs b/crates/openhuman-core/src/agent/debug/prompt_size_tests.rsindex 8c571187b3..24bbf91ad7 100644--- a/crates/openhuman-core/src/agent/debug/prompt_size_tests.rs+++ b/crates/openhuman-core/src/agent/debug/prompt_size_tests.rs@@ -71,3 +71,45 @@ fn tools_are_ranked_by_cost_not_registration_order() {);assert!(report.tools[1].parameters_bytes > 0, "`{{}}` is two bytes");}++/// The report must measure the tool schemas the provider receives — the+/// agent's visible set — not the whole registry. d149ab0f0 switched the+/// session dump to `all_tool_refs()`, and every agent then reported the same+/// ~200 tools, so every `tool_bytes` budget described a belt no agent carries.+#[test]+fn session_report_measures_the_visible_belt_not_the_registry() {+ crate::agent::harness::AgentDefinitionRegistry::init_global_builtins().unwrap();+ let tmp = tempfile::TempDir::new().unwrap();+ let config = crate::config::Config {+ workspace_dir: tmp.path().join("workspace"),+ action_dir: tmp.path().join("workspace"),+ config_path: tmp.path().join("config.toml"),+ ..crate::config::Config::default()+ };+ std::fs::create_dir_all(&config.workspace_dir).unwrap();+ let agent = crate::agent::Agent::from_config_for_agent(&config, "critic")+ .expect("critic session build");++ let dumped = crate::agent::debug::session_dump(&agent, "critic", String::new());+ let report = PromptSizeReport::from_dump(&dumped);++ let mut visible: Vec<String> = agent+ .visible_tool_specs_arc()+ .iter()+ .map(|s| s.name.clone())+ .collect();+ visible.sort();+ let mut reported: Vec<String> = report.tools.iter().map(|t| t.name.clone()).collect();+ reported.sort();+ assert_eq!(+ reported, visible,+ "prompt-size must report the provider-facing visible tool set"+ );+ assert!(+ report.tool_count < dumped.tool_names.len(),+ "critic's belt ({}) must be narrower than its registry ({}), or this test \+ cannot tell the two apart",+ report.tool_count,+ dumped.tool_names.len()+ );+}diff --git a/scripts/prompt-budget.limits b/scripts/prompt-budget.limitsindex 96f99ed163..75392b50a4 100644--- a/scripts/prompt-budget.limits+++ b/scripts/prompt-budget.limits@@ -203,39 +203,39 @@# fleet tools. Deleting the section wholesale would have removed# a known bug's fix along with the redundancy.-morning_briefing:14279:82986-trigger_triage:9214:0-workflow_builder:46405:30259-summarizer:8783:0-tools_agent:8260:82986-orchestrator:33629:29821-code_executor:13327:12338-crypto_agent:12049:12357-task_manager_agent:7104:15601-planner:9927:5664-skill_creator:7311:12411-flow_discovery:10111:9503-profile_memory_agent:7202:11815-settings_agent:7065:11220-context_scout:10427:7652-skill_executor:9613:8090-scheduler_agent:9635:7008-agent_memory:9761:6698-mcp_setup:10368:5078-skill_setup:7272:7973-trigger_reactor:7966:6423-mcp_agent:8927:4472-flow_memory_agent:9026:3809-tool_maker:6273:6087-presentation_agent:6547:5678-video_agent:6973:2266-help:8469:2365-image_agent:7017:2266-goals_agent:6725:3124-vision_agent:6885:2266-archivist:5985:3133+morning_briefing:15295:76791+trigger_triage:9207:0+workflow_builder:79094:30397+summarizer:9021:0+tools_agent:9285:76791+orchestrator:30809:30812+code_executor:13320:12591+crypto_agent:12986:12357+task_manager_agent:7097:15834+planner:9920:5917+skill_creator:7304:12664+flow_discovery:10780:9641+profile_memory_agent:7554:12132+settings_agent:7040:11065+context_scout:11076:7343+skill_executor:9594:7505+scheduler_agent:9628:7227+agent_memory:10422:6836+mcp_setup:10361:5078+skill_setup:7253:7598+trigger_reactor:8264:6740+mcp_agent:8920:4472+flow_memory_agent:9687:3947+tool_maker:6266:6087+presentation_agent:6540:5678+video_agent:6966:2519+help:8462:2365+image_agent:7010:2519+goals_agent:7356:2604+vision_agent:6878:2519+archivist:6283:3450researcher:6855:2229-critic:6222:1855+critic:6215:2108# ── Per-tool schema ratchet ──────────────────────────────────────────────#@@ -298,13 +298,14 @@ critic:6222:1855# Discovery tools. Both are the recovery path for a withheld surface, so# their descriptions carry the "here is what you can still reach" copy.#-tool:memory:3788-tool:delegate_to:5302+# `memory`, `delegate_to` and `cron` were dropped 2026-09-18: no agent at+# 93e9938f3 advertises them (nor does the default-features registry), so+# the lookup below failed before any number was compared. The prose above+# describes them as they were on 2026-09-01.tool:spawn_subagent:3554-tool:cron:3228tool:propose_workflow:3170tool:memory_tree:3008-tool:cron_add:3003+tool:cron_add:3222tool:edit_workflow:2721tool:generate_presentation:2662tool:suggest_workflows:2445@@ -313,4 +314,4 @@ tool:save_workflow:1957tool:spawn_parallel_agents:1851tool:todo:1831tool:search_tool_catalog:1695-tool:use_skill:1627+tool:use_skill:2090