postChat dispatches via doPost; on a 400 rejecting reasoning it drops reasoning_effort for this Client's lifetime and retries once. Two wild flavours, both caught by substring match: newer OpenAI models ("reasoning_effort … not supported") and Ollama non-thinking models (" does not support th
(parent context.Context, body chatRequest)
| 377 | Elapsed: time.Since(start), |
| 378 | }) |
| 379 | } |
| 380 | |
| 381 | // sendEvent puts e on out, bailing if parent cancels first, so a slow or |
| 382 | // vanished consumer after Ctrl+C can't wedge the stream goroutine on a full |
| 383 | // buffer. |
| 384 | func sendEvent(parent context.Context, out chan<- Event, e Event) bool { |
| 385 | select { |
| 386 | case out <- e: |
| 387 | return true |
| 388 | case <-parent.Done(): |
| 389 | return false |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | // sendChat POSTs the request and returns the response on 200. On failure it |
| 394 | // returns the Event the caller forwards, populated with Kind/Err/Budget. The |
| 395 | // body is closed on every non-200 branch; 200 leaves it open for the caller. |
| 396 | func (c *Client) sendChat(parent context.Context, msgs []chmctx.Message, tools []Tool) (*http.Response, *Event) { |