Skip to content

ReAct: drop TOOL_SCHEMAS descriptions after iteration 1 #86

@VarunGitGood

Description

@VarunGitGood

Why

TOOL_SCHEMAS in repi/investigation/tools.py is verbose by design — each tool has a multi-line description teaching the LLM when and how to call it (scan_window's description alone is ~10 lines). That's correct and necessary on the first iteration: the model has never seen these tools before. On every subsequent iteration the same description is replayed verbatim in the system / user prompt and contributes nothing — the model has already used the tools, the schemas no longer teach.

On a 10-iteration investigation this is a measurable token cost. With message compaction (#12) handling observation growth, schema repetition becomes the next biggest source of avoidable tokens.

Scope (in)

  • After iteration 1, emit a compact form of the schemas: tool name + arg names + arg types only. Drop the prose descriptions and the long usage notes.
  • The compact form should still be enough for the model to look up an arg name if it forgets; it just doesn't re-teach behaviour.
  • Iteration 1 keeps the full schemas — never strip on the first turn.
  • A new tool registered mid-loop (unlikely today, but possible with New ReAct tool: compare_services(s1, s2, window) #84 compare_services) gets its full schema the first time it appears, then collapses.

Scope (out)

Acceptance

  • Token usage on a 10-iteration investigation drops measurably vs. before this change, on the eval scenarios.
  • Tool-call success rate is unchanged (the LLM still picks the right tool with right args).
  • A unit test in tests/investigation/test_react_loop.py asserts the compact schema form is emitted for iterations >= 2.

Files

  • repi/investigation/react_loop.py — prompt assembly.
  • repi/investigation/tools.py — possibly a compact_schema() helper.
  • tests/investigation/test_react_loop.py

Depends on

#12 (message compaction) — orthogonal but lands in the same code path; coordinate to avoid merge churn.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestreact-qualityReAct loop reasoning improvements

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions