Collapsing N tool round-trips into one
tool_code_mode is one Amplifier tool. Instead of dispatching tools individually and drowning its own context, the LLM writes a single program that orchestrates them.
And this isn't a sketch — it already ships.
Built in kenotron-ms/amplifier-code-mode — 16 commits, sole author Ken Chau, and the tool test suite passes clean.
So what does it actually fix?
Each call is a full LLM round-trip, and every raw result lands in the context window permanently. Left to explore, an agent can run away.
The fix is to stop prompting tools — and start programming them.
.md in a vault for 17 minutes.The LLM writes one Python program. Each tool call is await tool_obj.execute(kwargs) — a real method call, not a network hop.
Real method calls mean they can also run at the same time.
exec(compile(...)).await hits tool_obj.execute() directly.Independent tools run at once. gather_limited(coros, limit=N) gives controlled concurrency in one line instead of 8+ lines of Semaphore boilerplate.
Speed handled — now the context flood itself.
The program runs with contextlib.redirect_stdout(buf); the captured stdout is the sole tool result. What you don't print, the model never sees.
Put those together and the message count collapses.
Parallel tool calls dump 20 tool_use + 20 tool_result = 40 messages. One program returns 1 + 1 = 2. N round-trips and their data flood collapse to a single call and summary.
Illustrative figures from announcement.md (Ken's own framing), not a measured benchmark.
No orchestrator swap required. Suggest tool_code_mode via its tool description, or lock it with /code-mode — which blocks every tool but tool_code_mode at the execution layer.
From optional nudge to enforced discipline: one program, not a prompt.
/code-mode blocks all direct tool calls (safe: tool_code_mode, todo, mode).Primary source: kenotron-ms/amplifier-code-mode (branch main, 16 commits). Independently re-verified in a fresh session — every commit hash, source line, test count, and quote re-derived from actual command output.
Feature status: Working and tested; distributable Amplifier bundle (d9844c5 · 2026-04-09 → 99a8c15 · 2026-04-18).
Research performed:
gh repo view kenotron-ms/amplifier-code-mode; gh repo clone kenotron-ms/amplifier-code-modegit log --oneline; git show c4bb641 506501f 2c1215b 58acd33 d9844c5grep -n 'name = "tool_code_mode"' modules/tool-code-mode/.../__init__.py; read_file lines 205-243, 365-414, 431-469cat modes/code-mode.md; grep -n timeout bundle.mduv run --with pytest --with pytest-asyncio python -m pytest tests/test_mount.py -q → 67 passed in 1.07sgit shortlog -sne HEAD → 16 commits, sole author Ken Chau <kchau@outlook.com>Gaps: The "40 messages → 2" and "17-minute vault run" figures come from announcement.md (Ken's own claims), not from a measured benchmark in the repo — treated as illustrative. L3 loop-code orchestrator is "(coming)" and not present.
Primary contributor: Ken Chau — 16 of 16 commits (100%).