feat(runtime): route large tool outputs through workshop to protect parent context (closes #548)#658
Merged
Conversation
All system prompts were English-only, causing DeepSeek V4 to reason and respond in English even when users wrote in Chinese or other languages. Add a Language Mirror section to base.md and base.txt that instructs the model to detect the user's primary language and use it for both reasoning (thinking tokens) and the final reply.
base.txt is not referenced via include_str! in prompts.rs. Only base.md is loaded (BASE_PROMPT). Remove the redundant change to base.txt as noted by Gemini Code Assist review.
…arent context (closes Hmbown#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>
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
谁家PR机器人 |
Hmbown
added a commit
that referenced
this pull request
May 5, 2026
47 fmt drifts had accumulated from the squash-merged community PRs on this branch (#653, #654, #655, #645, #658, #668, #659, #661, #660, #667, #656). Pure formatting — no behavioural changes — applied via `cargo fmt --all` to satisfy CI's `cargo fmt --all -- --check` gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
7 tasks
MMMarcinho
pushed a commit
to MMMarcinho/DeepSeek-TUI
that referenced
this pull request
May 6, 2026
MMMarcinho
pushed a commit
to MMMarcinho/DeepSeek-TUI
that referenced
this pull request
May 6, 2026
47 fmt drifts had accumulated from the squash-merged community PRs on this branch (Hmbown#653, Hmbown#654, Hmbown#655, Hmbown#645, Hmbown#658, Hmbown#668, Hmbown#659, Hmbown#661, Hmbown#660, Hmbown#667, Hmbown#656). Pure formatting — no behavioural changes — applied via `cargo fmt --all` to satisfy CI's `cargo fmt --all -- --check` gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LargeOutputRouterthat intercepts tool results exceeding a token threshold (default 4 096 tokens) before they enter the parent contextlast_tool_resultfor laterpromote_to_contextretrievalraw = trueto bypass routing for that invocation[workshop.per_tool_thresholds]inconfig.tomlChanges
crates/tui/src/tools/large_output_router.rsLargeOutputRouter,WorkshopConfig,WorkshopVariables,RouteDecision, token estimator, synthesis-prompt builder, 14 unit testscrates/tui/src/tools/spec.rsToolContextgainslarge_output_router+workshop_varsfields andwith_large_output_routerbuildercrates/tui/src/tools/registry.rsexecute_full_with_contextapplies routing after every tool callcrates/tui/src/core/engine.rsEngineConfig.workshop,Engine.workshop_vars, wired inbuild_tool_contextcrates/tui/src/config.rsConfig.workshopdeserialization +merge_configpropagationcrates/tui/src/main.rs,runtime_threads.rs,tui/ui.rsworkshopfield throughEngineConfiginitializersconfig.example.toml[workshop]table with threshold and per-tool override examplesDesign notes
ToolContext.large_output_router = Noneby default: sub-agents and test contexts see no routing (prevents recursive synthesis calls)WorkshopVariablesis anArc<Mutex<…>>shared across all tool calls in the session solast_tool_resultpersists until explicitly consumedTest plan
cargo check— zero errors, zero warnings (verified in CI pre-push)[workshop] large_output_threshold_tokens = 512in local config → small grep results pass through, large file reads get the synthesis headerread_file path="bigfile.rs" raw=true→ bypass confirmed, full content returned[workshop.per_tool_thresholds] exec_shell = 256→ shell output synthesised at tighter limit while other tools use the global thresholdspawn_agentinherits no router → no recursive synthesis🤖 Generated with Claude Code