// backend, in canonical form.
quotaPrefix = "X-Codex-"
+ // turnStateHeader is an x-codex-* header that holds an opaque state of
+ // the backend, not quota.
+ turnStateHeader = "X-Codex-Turn-State"
+
// errorBytes is the most bytes of an error response that go into the
// error.
errorBytes = 4096
}
// usageRecord is one line of usage.jsonl. Status is the HTTP status, or 0 when
-// no response came. Quota holds the x-codex-* headers of the response.
+// no response came. Quota holds the x-codex-* headers of the response, without
+// the turn state.
type usageRecord struct {
Date string `json:"date"`
Model string `json:"model"`
}
}
-// quotaHeaders returns the x-codex-* headers, with lowercase names.
+// quotaHeaders returns the x-codex-* headers, with lowercase names, without the
+// turn state.
func quotaHeaders(header http.Header) map[string]string {
var quota map[string]string
for name, values := range header {
- if !strings.HasPrefix(name, quotaPrefix) || len(values) == 0 {
+ if !strings.HasPrefix(name, quotaPrefix) || name == turnStateHeader || len(values) == 0 {
continue
}