schemaToTool unwraps a tool schema (the map[string]any shape shared by bash and the file tools) into the typed llm.Tool the chat payload expects.
(s map[string]any)
| 695 | } |
| 696 | |
| 697 | // endTurn zeroes per-turn state after a turn finishes or aborts. Pair to |
| 698 | // beginTurn. Cancels the per-turn context unconditionally to release the |
| 699 | // CancelFunc; Background-rooted contexts otherwise leak one child cancelCtx |
| 700 | // per turn until the process exits. Drops pending tool calls so a turn cut |
| 701 | // short mid-dispatch (Ctrl+C or error) can't leak a leftover call into the next |
| 702 | // turn, which would dispatch with stale args and append an orphan tool_result |
| 703 | // whose tool_call_id no longer pairs the latest assistant message. Does NOT |
| 704 | // touch scrollback; callers decide whether to flush streaming or emit a banner. |
| 705 | func (m *Model) endTurn() { |
| 706 | if m.cancel != nil { |
| 707 | m.cancel() |
| 708 | } |
| 709 | m.phase = phaseIdle |
| 710 | m.cancel = nil |