From b435cf06b78853bec87bf238f526bc60679d7712 Mon Sep 17 00:00:00 2001 From: t Date: Wed, 10 Jun 2026 16:46:30 -0600 Subject: fix anthropic thinking effort json placement --- libpanto/src/provider_openai_chat.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libpanto/src/provider_openai_chat.zig') 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; } -- cgit v1.3