summaryrefslogtreecommitdiff
path: root/libpanto/src/provider_openai_chat.zig
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-06-10 16:46:30 -0600
committert <t@tjp.lol>2026-06-10 16:46:48 -0600
commitb435cf06b78853bec87bf238f526bc60679d7712 (patch)
tree0c4191f24730f9a0336accb701d627450483c9cf /libpanto/src/provider_openai_chat.zig
parentcee08918509689adbdbd26b6384d5ef3a47e91a2 (diff)
fix anthropic thinking effort json placement
Diffstat (limited to 'libpanto/src/provider_openai_chat.zig')
-rw-r--r--libpanto/src/provider_openai_chat.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/libpanto/src/provider_openai_chat.zig b/libpanto/src/provider_openai_chat.zig
index 8319d9d..5152d3e 100644
--- a/libpanto/src/provider_openai_chat.zig
+++ b/libpanto/src/provider_openai_chat.zig
@@ -140,6 +140,10 @@ pub const OpenAIChatRequest = struct {
rr.response = try rr.req.receiveHead(&redirect_buf);
if (@intFromEnum(rr.response.head.status) >= 400) {
+ // `head.bytes` (which `iterateHeaders` walks) points into the
+ // connection read buffer and is invalidated the moment the body
+ // stream is initialized below. Capture Retry-After first.
+ const retry_after_ms = provider_mod.retryAfterFromHead(rr.response.head);
// Drain body for diagnostics.
const body_reader = rr.response.reader(&rr.transfer_buf);
var err_buf: std.ArrayList(u8) = .empty;
@@ -159,7 +163,7 @@ pub const OpenAIChatRequest = struct {
const classified = provider_mod.classifyHttpStatus(status, err_buf.items);
if (self.diag) |d| {
d.status_code = status;
- d.retry_after_ms = provider_mod.retryAfterFromHead(rr.response.head);
+ d.retry_after_ms = retry_after_ms;
}
return classified;
}