Skip to content

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

refactor(tinyagents): source tool result budget from harness config

Steven Enamakeldab9b91ef2c0
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
index dc8ac4899a..fced765e86 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
@@ -23,11 +23,6 @@ use tinyjuice_bus::types::AgentTokenjuiceCompression;
use super::tool_output::ToolOutputMiddleware;
-/// Default per-tool-result byte cap for the channel / sub-agent paths, which do
-/// not carry session-specific context settings to source the configured budget from.
-/// Mirrors the `ContextConfig::tool_result_budget_bytes` default (16 KiB).
-pub(crate) const DEFAULT_TOOL_RESULT_BUDGET_BYTES: usize = 16 * 1024;
-
/// Config bundle for the openhuman context middlewares installed on a turn.
///
/// Cheap to clone (the summarizer is an `Arc`). An all-default value installs
@@ -348,7 +343,8 @@ impl TurnContextMiddleware {
/// microcompact.
pub(crate) fn defaults() -> Self {
Self {
- tool_result_budget_bytes: DEFAULT_TOOL_RESULT_BUDGET_BYTES,
+ tool_result_budget_bytes: tinyagents_harness::config::ToolRuntimeConfig::default()
+ .tool_result_budget_bytes,
payload_summarizer: None,
// Deliberately `None` on the channel / sub-agent path (#6408).
//
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_loop_guard_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_loop_guard_tests.rs
index f970ec98a3..40efb1b792 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_loop_guard_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_loop_guard_tests.rs
@@ -25,7 +25,7 @@ async fn sampling_tool_output_still_hits_the_byte_budget_backstop() {
let mw = truncation_probe_mw();
let payload = large_sample_response_json(400);
assert!(
- payload.len() > DEFAULT_TOOL_RESULT_BUDGET_BYTES,
+ payload.len() > tinyagents_harness::config::ToolRuntimeConfig::default().tool_result_budget_bytes,
"test payload must exceed the shared byte budget: {} bytes",
payload.len()
);
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rs
index 45758f4ce1..96798290e8 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tests.rs
@@ -3,7 +3,7 @@ use super::repeated_failure::{is_body_level_failure, user_actionable_escalation}
use super::tool_output::{
is_compaction_exempt, is_truncation_exempt, COMPACTION_EXEMPT_TOOLS, SAMPLING_TOOLS,
};
-use super::turn_context::DEFAULT_TOOL_RESULT_BUDGET_BYTES;
+use tinyagents_harness::config::ToolRuntimeConfig;
use crate::agent::tinyagents::middleware::embedder_hooks::EmbedderToolHooksMiddleware;
use crate::agent::tinyagents::middleware::repeated_failure::RepeatedToolFailureMiddleware;
use crate::agent::tinyagents::middleware::tool_outcome_capture::ToolOutcomeCaptureMiddleware;
@@ -264,7 +264,7 @@ fn oversized_workflow_proposal_json(node_count: usize) -> String {
/// of being persisted — deterministic to assert on).
fn truncation_probe_mw() -> ToolOutputMiddleware {
ToolOutputMiddleware {
- budget_bytes: DEFAULT_TOOL_RESULT_BUDGET_BYTES,
+ budget_bytes: ToolRuntimeConfig::default().tool_result_budget_bytes,
payload_summarizer: None,
artifact_store: None,
tokenjuice_compaction_enabled: false,
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_compaction_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_compaction_tests.rs
index 7ba35e49d2..bbbec00d3f 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_compaction_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_compaction_tests.rs
@@ -118,7 +118,7 @@ async fn tool_output_leaves_an_oversized_propose_workflow_byte_for_byte_intact()
let mw = truncation_probe_mw();
let payload = oversized_workflow_proposal_json(30);
assert!(
- payload.len() > DEFAULT_TOOL_RESULT_BUDGET_BYTES,
+ payload.len() > tinyagents_harness::config::ToolRuntimeConfig::default().tool_result_budget_bytes,
"test payload must exceed the shared byte budget to exercise step 4: {} bytes",
payload.len()
);
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs
index 8c9e035364..64cbba56c3 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs
@@ -169,7 +169,7 @@ fn defaults_enable_the_byte_cap_only() {
let mw = TurnContextMiddleware::defaults();
assert_eq!(
mw.tool_result_budget_bytes,
- DEFAULT_TOOL_RESULT_BUDGET_BYTES
+ tinyagents_harness::config::ToolRuntimeConfig::default().tool_result_budget_bytes
);
assert!(mw.payload_summarizer.is_none());
assert_eq!(mw.microcompact_keep_recent, 0);
@@ -512,7 +512,7 @@ async fn tool_output_honors_a_tools_own_cap() {
/// moving the ladder into the harness must not change it.
#[test]
fn shared_tool_result_byte_budget_stays_16_kib() {
- assert_eq!(DEFAULT_TOOL_RESULT_BUDGET_BYTES, 16 * 1024);
+ assert_eq!(tinyagents_harness::config::ToolRuntimeConfig::default().tool_result_budget_bytes, 16 * 1024);
}
#[path = "middleware_tool_output_compaction_tests.rs"]