feat(runtime): route large tool outputs through workshop to protect parent context (closes #548)
Tool outputs (read_file, grep_files, exec_shell, fetch_url, web_search) that exceed a configurable token threshold are now intercepted before they reach the parent context. A structured synthesis header replaces the raw blob; the full content is stored in the workshop variable `last_tool_result` for later `promote_to_context` retrieval. Key changes: - New `crates/tui/src/tools/large_output_router.rs`: `LargeOutputRouter`, `WorkshopConfig`, `WorkshopVariables`, `RouteDecision`, token estimator, synthesis-prompt builder, and wrap_synthesis helper. Full unit-test suite. - `ToolContext` gains `large_output_router` and `workshop_vars` fields plus the `with_large_output_router` builder; constructor defaults are `None` so sub-agents and test contexts are unaffected. - `ToolRegistry::execute_full_with_context` applies routing after every tool call; `raw=true` in the tool input bypasses routing for that invocation. - `EngineConfig` gains a `workshop` field; `Engine::new` creates the shared `WorkshopVariables` Arc when the field is present and wires it into every `build_tool_context` call. - `Config` gains `[workshop]` table deserialization; `merge_config` propagates it like other optional tables. - `config.example.toml` documents `[workshop]`, `large_output_threshold_tokens` (default 4096), and per-tool threshold overrides. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -240,6 +240,26 @@ l3_threshold = 576000
|
||||
cycle_threshold = 768000
|
||||
seam_model = "deepseek-v4-flash"
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────────
|
||||
# Workshop / Large-Output Routing (#548)
|
||||
# ─────────────────────────────────────────────────────────────────────────────────
|
||||
# Tool outputs exceeding `large_output_threshold_tokens` are routed through a
|
||||
# V4-Flash synthesis sub-agent. Only the synthesis reaches the parent context;
|
||||
# the raw text is stored in the workshop variable `last_tool_result` so the
|
||||
# parent can call `promote_to_context` later if it needs the full content.
|
||||
#
|
||||
# Per-tool overrides let high-volume tools (e.g. exec_shell) use tighter
|
||||
# thresholds without changing the global default.
|
||||
#
|
||||
# Add `raw = true` to any tool call to bypass routing for that invocation.
|
||||
#
|
||||
# [workshop]
|
||||
# large_output_threshold_tokens = 4096
|
||||
# [workshop.per_tool_thresholds]
|
||||
# exec_shell = 2048 # shell output synthesised aggressively
|
||||
# grep_files = 2048
|
||||
# web_search = 8192 # web results can be large; give them more room
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────────
|
||||
# Capacity Controller (runtime pressure guardrails)
|
||||
# ─────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user