conductor(checkpoint): Phase 1 complete — tool loop lift
Phase 1 ships:
- run_with_tool_loop shared helper for all 8 vendors
(src/ai_client.py:806) with 2 extensions:
- request_builder: Callable[[int], OpenAICompatibleRequest]
for vendors that need per-round history rebuild
(minimax + grok + llama)
- send_func: Callable[[int], NormalizedResponse] +
on_pre_dispatch: Callable for vendored call paths
(gemini_cli, with anthropic + gemini + deepseek
deferred — see state.toml deferred_work)
- 4 OpenAI-compat vendors use the shared helper:
- _send_minimax (68 -> 44 lines)
- _send_grok (was single-shot, now has tool loop)
- _send_llama (was single-shot, now has tool loop)
- _send_qwen deferred (uses _dashscope_call, not
send_openai_compatible; would need a separate refactor
to switch to OpenAI-compat mode)
- 1 vendored-call-path vendor uses send_func + on_pre_dispatch:
- _send_gemini_cli (no net line reduction but loop + dispatch
are now shared)
- Audit script: scripts/audit_no_inline_tool_loops.py enforces
no inline tool loops in non-deferred _send_<vendor> functions
- 9 new tests in 3 test files lock in the helper contract:
- tests/test_ai_client_tool_loop.py (5 tests)
- tests/test_ai_client_tool_loop_builder.py (1 test)
- tests/test_ai_client_tool_loop_send_func.py (2 tests)
Verification:
- 62 vendor + tool + import-isolation tests pass
- audit_no_inline_tool_loops.py passes
- No regressions
Deferred (tracked in state.toml deferred_work):
- _send_qwen tool loop (DashScope native, not OpenAI-compat)
- _send_anthropic + _send_gemini + _send_deepseek inline loops
(vendored call paths; each needs per-vendor conversion to
OpenAICompatibleRequest before run_with_tool_loop can apply)
Next: Phase 2 (PROVIDERS move out of src/models.py into
src/ai_client.py) + Phase 3 (UX adaptations 2-9).
Commits in this phase:
- dc0f25c5 (red tests)
- 1c836647 (green: implement)
- 19a4d43e (apply to _send_minimax)
- 4069d677 (apply to _send_grok + _send_llama)
- 4748d134 (send_func + on_pre_dispatch for _send_gemini_cli)
- 9ddfa981 (openai import local-scope fix)
- 7e4503f4 (audit script + state progress)
- a22d4975 (this checkpoint, empty)
This commit is contained in: