A Program,
Not a Prompt

Collapsing N tool round-trips into one

Let the LLM write a program to run its tools — not prompt them one call at a time

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.

# Instead of N separate prompted calls… one program, one result: results = await asyncio.gather( read_file(path), web_fetch(url), ) print(summary(results))

A working, tested, distributable Amplifier bundle

Built in kenotron-ms/amplifier-code-mode — 16 commits, sole author Ken Chau, and the tool test suite passes clean.

Working and tested · distributable bundle

So what does it actually fix?

16
commits, sole author Ken Chau
67
tests, all passing (1.07s)
1
tool: tool_code_mode

Dispatching tools individually floods context — and runs can wander

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.

Every mounted tool becomes an async function, run in-process via exec()

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.

asyncio and gather_limited are pre-injected — parallelism in one line

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.

# asyncio is pre-injected — no imports needed rows = await gather_limited( [fetch(u) for u in urls], limit=8, ) print(len(rows), "fetched")

Only the print()ed stdout is returned — intermediate data never enters context

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.

# captured stdout = the only tool output with contextlib.redirect_stdout(buf): ... run the program ... return buf.getvalue().strip() # raw results stay out of context

"A program doesn't do that"

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.

40
messages — 20 tool_use + 20 tool_result
2
messages — 1 call + 1 result

Drop in the bundle — nudge it at L1, hard-enforce it at L2

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.

L1
Suggest. Offer it through the tool description and context.
L2
Enforce. /code-mode blocks all direct tool calls (safe: tool_code_mode, todo, mode).
L3
Coming. A loop-code orchestrator, marked "(coming)" in the README.
Sources

Research Methodology

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:

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%).

More Amplifier Stories