The graph passed remaining_steps=20 (50 for injection) in the run inputs.
RemainingSteps is a LangGraph managed value derived from recursion_limit,
so the input was ignored and the real budget was 25 (100 for injection).
No one could see those numbers, and a turn that hit the cap ended on a
bare tool result with no explanation.
- Remove the dead remaining_steps input.
- Add resolve_recursion_limit(): max_steps from the LLM model config wins;
otherwise 25 teaching_assistant, 50 lab_automation_assistant, 100
troubleshooting_injection.
- When fewer than 4 steps remain after a tool run, route to the new
budget_wrapup node. The next llm_call binds no tools and gets a wrap-up
instruction, so the turn ends with a short summary of what was done and
what remains.
- should_continue skips the title call after a wrap-up (no step left).
- budget_exhausted is reset at the start of every user turn.
- Add max_steps to the LLM config schemas. The config is a JSON column,
so no migration is needed.
- Tests: 16 new tests cover the resolver, the routing, the tool-free
wrap-up call and the removed input. Docs updated.