dispatchNextTool pops the next pending tool call and runs it. Every tool flows through runToolCall; none are special-cased. lastToolKey records this call's target so the failure nudge can tell when the model keeps retrying the same failing operation (see recordToolOutcome).
()
| 1051 | m.turnStart = time.Time{} |
| 1052 | m.turnTokens = 0 |
| 1053 | } |
| 1054 | |
| 1055 | // handleStreamClosed drives what happens after one round's stream finishes: |
| 1056 | // dispatch the next pending tool call, or, if none, finalize the turn and |
| 1057 | // hand control back. A turn ends precisely when the assistant emits no tool |
| 1058 | // calls; there is no loop tool to land on. |
| 1059 | func (m Model) handleStreamClosed() (tea.Model, tea.Cmd) { |
| 1060 | m.stream = nil |
| 1061 | // Stale close from a cancelled turn (handleCtrlC / EventError reset phase |
| 1062 | // to idle). |
| 1063 | if !m.phase.active() { |
| 1064 | return m, nil |
no test coverage detected