- turn_loop: a mid-stream chunk-timeout now counts toward the stream-error budget (stall with nothing streamed retries transparently; an exhausted budget fails the turn with the real reason instead of ending Completed over a frozen block). - idle engine: a finished background shell task wakes and starts an ordinary runtime turn even without an active goal; a dead provider route claims the completion once and reports where the output lives. - subagent: over-budget final reports spill to a session artifact and the truncation footer names the retrieve_tool_result ref; write failures degrade to the honest no-ref footer. Test-only wrappers marked cfg(test). - waits: agents/wait and agent action=wait default to 30 s and cap at 120 s (blocked waits deafen the session; settled children report back as sentinels). Bash action=wait honors timeout_secs/timeout aliases and block; result metadata reports the real wait_timeout_ms. - todo_write canonical naming: constructor is new(); work_update/TodoWrite/ todo stay hidden compat aliases; user-visible copy and docs updated. - behavioral tips: DurableStateWritten fires on successful remember calls; enum allow removed. voice.rs and work_surface model use let-chains. - test: Windows path-separator tolerant artifact footer assertion. - changelog: 0.9.4 additions (Agent Plugins v1.0.0, send_later, /advisor, quiet mode, automation forms, resume_from, transport resilience, durability, zh-Hant, update chip, RLM groundwork, stall/wake/truncation/ wait fixes). Dead-code budget re-baselined to 452.
5.8 KiB
Codewhale Runtime Simplification Design
Status: Pre-implementation design record for the v0.9.1 cutover, kept for its "Rejected alternatives" provenance. It is not current runtime documentation and it shipped differently in two ways:
- Goal 3 below ("keeping every legacy tool name registered but hidden") was
reversed. The per-action file/git/run/web and
exec_shell*names were removed, not hidden —crates/tui/src/tools/registry.rs:2066-2088and:2290-2304assert they must stay unregistered. Onlyapply_patchand thetask_*/github_*/automation_*/rlm_*/checklist_*families survive as hidden aliases. - The default-active policy is nine names, not ten.
update_planandWebare not inDEFAULT_ACTIVE_NATIVE_TOOLS(crates/tui/src/core/engine/tool_catalog.rs:44-58).
For the current contract see TOOL_SURFACE.md.
Goal
Make the model-facing runtime smaller, calmer, and easier for models to use by:
- Collapsing the long tail of single-purpose file, git, run, and web tools into a few canonical action-based tools.
- Shrinking the system prompt to durable behavioral invariants and per-turn permission deltas.
- Keeping every legacy tool name registered but hidden so old transcripts, saved sessions, and recorded automation replay without migration.
Target model-facing surface (default active)
| Tool | Actions / Niche |
|---|---|
Bash |
run, wait, interact, cancel (existing) |
File |
read, list, search_name, search_content, write, edit, patch |
Git |
status, diff, log, show, blame |
Run |
tests, verifiers |
Web |
search, fetch, wait (deferred unless network is enabled; hidden aliases for legacy names) |
tasks |
durable task family (existing action-based surface) |
github |
durable GitHub family (existing; deferred by default) |
automation |
durable automation family (existing; deferred by default) |
rlm |
durable RLM family (existing; deferred by default) |
agent |
sub-agent dispatch |
remember |
opt-in durable user-memory capture; eager whenever registered |
todo_write |
progress / plan-of-work updates |
update_plan |
plan artifact updates |
tool_search |
on-demand discovery of deferred tools |
Default-active policy: 10 names (vs. ~18 before the simplification), with
remember registered only for built-in-memory users and the durable families
and Web discoverable via tool_search when needed. tool_search itself is a
synthetic always-active catalog entry.
Rejected alternatives
- Keep every tool but defer the rare ones. This only changes what is advertised, not how many distinct schemas the model must learn. It also leaves duplicated guidance in the prompt.
- Route search and git through
Bash.grep_files,file_search, and the git tools return structured, workspace-aware output and respect sandbox,.gitignore, and network policy. Shell would force the model to re-parse free-form text and lose those guarantees, so dedicated tools win. - One mega
Filetool plus a separateEdittool. A singleFiletool is only slightly larger than a read/edit pair and keeps the boundary the model already understands (readis cheap,editrequires prior read). Splitting would re-introduce a two-tool alias for the same underlying operations. - Delete legacy tools. Saved transcripts and replay tests rely on the old names. Removing them would require a config migration and break reproducibility. Hidden aliases avoid both.
Compatibility
- Legacy names (
read_file,write_file,edit_file,list_dir,file_search,grep_files,apply_patch,git_status,git_diff,git_log,git_show,git_blame,run_tests,run_verifiers,web_search,fetch_url,wait_for_dev_server) stay registered withmodel_visible = false. - The engine resolves calls by name, so old transcripts replay without changes.
DEFAULT_ACTIVE_NATIVE_TOOLSis updated to list the new canonical names only; hidden legacy tools are ignored by catalog construction.
Prompt simplification
- Replace the tool-calling recipe sections in
AGENT_MODEandSUBAGENT_OUTPUT_FORMATwith short references to the canonical tools. - Reduce mode deltas to permission statements (Act = write requires approval, Plan = no writes or shell, Full Access = auto-approved, Operate = coordinate from ordinary messages).
- Keep the
BASE_PROMPTbehavioral invariants,LANGUAGE_PROMPT, andOUTPUT_PROMPTintact. - Move detailed templates (
COMPACT_TEMPLATE, sub-agent brief format, planning artifact template) out of the stable prefix and into tool schemas or conditional blocks.
Validation
- Provider-free:
scripts/measure-runtime-contract.pyreports active tool count and prompt bytes before and after. - Behavior-preserving: targeted unit tests for
File,Git,Run, andWebdispatch against legacy inputs. - Regression:
cargo fmt,cargo clippy --workspace --all-targets --locked,cargo test -p codewhale-tui --bin codewhale-tui --locked, andcargo test --workspace.
v0.9.1 receipt
The source contract and provider-free metric now exercise the complete policy,
including opt-in remember:
| Contract | Before | After |
|---|---|---|
| Default active tools | 18 | 10 |
| Agent-mode instruction bytes | 4,064 | 663 |
| Full system-prompt bytes | 15,842 | 15,368 |
The final active names are Bash, File, Git, Run, agent, remember,
tasks, update_plan, todo_write, and tool_search. remember is present
only when built-in memory is enabled; it is eager whenever registered. File
advertises only read actions in Plan mode, and its patch action appears only
when the existing apply-patch feature is enabled. Hidden aliases remain
executable for transcript replay but are absent from the model catalog.