Native tool calls vs ReAct text: what changed when the model got real

Earlier in this series I built a ReAct loop and GPT-2 couldn’t drive it: it answered Thought: 12 and stopped.
This week I gave the same idea to a real model, gemini-3.5-flash-lite, and four tools over my own
Go database. Then I ran it two ways — the model’s native tool calls, and my old text loop — on the
same 10 tasks. Native got 9/10, and really 10/10. Text got 4/10. The interesting part is everything
I had to build around the model so it could act safely.

What I built

An agent that investigates a Go repo with four tools. search_code, read_file and git_log are
read-only. run_go_tests executes code, so it needs approval. There is no SDK tool runner. I wrote
the loop by hand, and every call goes through one gate:

model turn ──▶ known tool? ──▶ args validate? ──▶ sensitive? ──▶ already ran? ──▶ approved?
                   │ no            │ no              │ no            │ yes           │ no (default)
                   ▼               ▼                 ▼               ▼               ▼
             error result     error result        run it       stored result    error result

All results of a turn go back to the model in one message, and it takes the next step.

Mode Task success Right tools Errors Mean steps Tokens Cost
Native tool calls 9/10 (really 10/10) 10/10 0 2.7 35,776 $0.013
Text ReAct (my old loop) 4/10 7/7 answered 3 3.7 34,704 $0.016

Same model, same tools, same gate. Native’s one “failure” was my scorer: it answered “October 15,
2026” and the key fact was 2026-10-15. Text ReAct crashed 3 times, broke format twice (a final
reply that was only “Thought: …”), and once ran the tests and then searched 6 more times without
answering.

The concepts that made it work

  • The model proposes, the gate disposes. A tool call is an untrusted request. Unknown tool, bad
    arguments, denied approval, a tool that throws: each comes back as an error the model can read and
    fix. On a smoke test the model invented a path argument for search_code. Validation rejected it
    with “Extra inputs are not permitted”, and the model dropped the field and carried on.
  • One schema, two jobs. Each tool’s arguments are a Pydantic model. Its JSON schema is what the
    model sees, and the same model validates what comes back. Strict mode on one provider is not a
    reason to skip validation on all of them.
  • At-most-once, again. An approved run_go_tests is stored under (session, tool, canonical args).
    Ask again and you get the stored result, not a second run and not a second prompt to the human. It
    is the dedup table from my distributed database’s RPC week, one layer up. The model is a client that
    retries whenever it likes.
  • Paths are attacks until proven otherwise. Resolve symlinks first, then check is_relative_to
    the repo root. A string prefix check lets /repo-evil pass as /repo.
  • Replay the model’s turn untouched. Thinking blocks and Gemini’s thought signatures ride inside
    the assistant turn. Rebuild it from text plus calls and they’re lost; Gemini even has an error for
    it (MISSING_THOUGHT_SIGNATURE).

The thing that bit me

My first text-ReAct run scored 0/10, and every answer was the word “Thought:”. It looked like a verdict on text
agents. It was my harness. Gemini read the tool list in my prompt as functions,
tried a native call nobody had declared, and returned MALFORMED_FUNCTION_CALL with no text. My
adapter passed that on as an empty answer, and my loop scored it. Now that reason raises an error. I
added a plain-text instruction and one worked example to the prompt, deleted the report and reran.
The model still did it on 3 tasks, but now they show up as crashes, not as answers.

Then the summary flattered it. “Success over answered tasks” gave text ReAct 0.571. Counting crashes
as failures gives the honest 0.4. An error that turns into an empty success is the worst thing a
harness can do, and I had built it twice.

Tradeoffs & the road not taken

  • Default deny, two tiers. Read-only or sensitive. A real system wants more tiers, per-argument
    rules, and a dry-run that shows the exact command before anyone approves it.
  • The dedup table is a dict. It dies with the process. Persisting it is the same job as making
    the database’s dedup survive a restart.
  • A hard step limit throws away work. On the smoke test the model found the answer on its 8th and
    last allowed step and got cut off with nothing. The loop now gives one final turn: answer from what
    you found.
  • No tool runner, no framework. The SDKs can run the loop for you. I wanted the gate in plain
    sight, because the gate is the part that matters when a tool can change something.

Where this sits in the system

My ReAct loop from scratch showed
that the loop is easy and the policy is everything. This week a real policy drove it, and the native
format removed the parsing seam that broke GPT-2. The model took a step less per task, at about the
same cost, because there was no format to get wrong. Next I measure whether a change made the
assistant worse, then put it behind a service and attack it with prompt injection on purpose.


Part of a series building a modern AI stack from scratch, told visually. (Last time: a ReAct agent loop.)