gateway: a turn on one of Codex's own models logs the reasoning Codex asked for (Karen, Discord #feedback: ChatGPT 账号登录,升级到最新版推理强度直接不显示了) — Codex signed in with ChatGPT sends its own models (gpt-6-astra, gpt-6.1-sol) on to chatgpt.com through /backend-api/codex, and that relay (codexUpstream) wrote its request-log row, its Routing trace and the trace's try without the effort, so the log's 推理强度 column was — on every one. It now records reasoning.effort from the (zstd-decoded) body as it goes on, unchanged, in all three. With the owner's real ChatGPT account in a sandbox magpie, codex exec at xhigh through openai_base_url: the row says openai · chatgpt.com, gpt-5.5, effort xhigh. TestCodexOwnModelLogsEffort (a zstd body at xhigh: the ledger's Effort, the route's and its try's) fails on the old code. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass (TestProvidersAnswerWhileListsComeIn, TestUserPath and TestClaudeSignedOut timed out under load and pass on their own).
This commit is contained in:
1 parent
d5619d5a92
commit
969e54f23b
2 files changed
+35
-3
No files matched your search
@@ -312,6 +312,7 @@ func (s *Server) codexUpstream(w http.ResponseWriter, r *http.Request, rest stri
|
||||
kind := requestCallKind(r.Header, metadata)
|
||||
var titleReply capturedBody // bounded; ordinary streams incur no copy
|
||||
captureTitle := false
|
||||
effort := "" // the reasoning Codex asked for, which goes on as it is
|
||||
end := func(status int, msg string, tokens, out int) {}
|
||||
if rest == "/responses" {
|
||||
who := "Codex's own sign-in"
|
||||
@@ -319,11 +320,12 @@ func (s *Server) codexUpstream(w http.ResponseWriter, r *http.Request, rest stri
|
||||
who = "Codex's API key"
|
||||
}
|
||||
model := modelOf(body)
|
||||
effort = requestEffort(provider.Responses, body)
|
||||
seat := Weighed{ID: "codex", Provider: "openai", Name: "OpenAI", Icon: "openai", Who: who, Kind: "account", Agent: "codex", Model: model}
|
||||
link := s.titlePrompts.observe(r, body, metadata, kind, start)
|
||||
captureTitle = link != nil && isTitleKind(kind)
|
||||
tr = s.trace.begin(Route{TitleLink: link, Time: start, Agent: agentOf(r), Session: sessionOf(r.Header), ParentSession: titleParentSession(r.Header, metadata, kind), Kind: kind, Model: model, Provider: "openai",
|
||||
Order: []Weighed{seat}, Tries: []Try{{ID: seat.ID, Model: model, Start: start}}})
|
||||
tr = s.trace.begin(Route{TitleLink: link, Time: start, Agent: agentOf(r), Session: sessionOf(r.Header), ParentSession: titleParentSession(r.Header, metadata, kind), Kind: kind, Model: model, Effort: effort, Provider: "openai",
|
||||
Order: []Weighed{seat}, Tries: []Try{{ID: seat.ID, Model: model, Effort: effort, Start: start}}})
|
||||
end = func(status int, msg string, tokens, out int) {
|
||||
ms := time.Since(start).Milliseconds()
|
||||
ttft, text := first.ms()
|
||||
@@ -492,7 +494,7 @@ func (s *Server) codexUpstream(w http.ResponseWriter, r *http.Request, rest stri
|
||||
rec := usage.Record{RouteID: tr.ID, Time: start, Agent: call.Agent, Provider: call.Provider, Host: provider.HostOf(base), Model: call.Model,
|
||||
Requested: call.Model, Served: served,
|
||||
Input: uu.Input, Output: uu.Output, CacheRead: uu.CacheRead, CacheWrite: uu.CacheWrite,
|
||||
Reasoning: uu.Reasoning, Millis: call.Millis, TTFT: call.TTFT, FirstText: call.FirstText, Status: call.Status, Session: sessionOf(r.Header), NativeSession: nativeSessionOf(r.Header), Kind: call.Kind,
|
||||
Reasoning: uu.Reasoning, Effort: effort, Millis: call.Millis, TTFT: call.TTFT, FirstText: call.FirstText, Status: call.Status, Session: sessionOf(r.Header), NativeSession: nativeSessionOf(r.Header), Kind: call.Kind,
|
||||
RequestID: requestID(res.Header), ResponseID: uu.ResponseID, Endpoint: r.URL.Path}
|
||||
failedWith(&rec, call.Status, call.Error, errType)
|
||||
appendUsage(r, rec)
|
||||
|
||||
@@ -752,3 +752,33 @@ func TestCodexOwnModelKindAccounting(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A turn on one of Codex's own models logs the reasoning Codex asked for,
|
||||
// as the others' turns do: the request log's reasoning column was blank
|
||||
// for every one (Karen, #feedback), its body sent zstd as Codex sends it.
|
||||
func TestCodexOwnModelLogsEffort(t *testing.T) {
|
||||
setup(t, provider.Chat, &fake{t: t})
|
||||
var got []byte
|
||||
chatgpt(t, func(w http.ResponseWriter, r *http.Request) {
|
||||
got, _ = io.ReadAll(r.Body)
|
||||
w.Header()["Content-Type"] = nil
|
||||
io.WriteString(w, sse(`data: {"type":"response.completed","response":{"id":"r1","usage":{"input_tokens":9,"output_tokens":2}}}`))
|
||||
})
|
||||
enc, _ := zstd.NewWriter(nil)
|
||||
z := enc.EncodeAll([]byte(`{"model":"gpt-5.5","stream":true,"input":"hi","reasoning":{"effort":"xhigh","summary":"auto"}}`), nil)
|
||||
s := New()
|
||||
rec := httptest.NewRecorder()
|
||||
req := httptest.NewRequest("POST", CodexPath+"/responses", bytes.NewReader(z))
|
||||
req.Header.Set("Content-Encoding", "zstd")
|
||||
req.Header.Set("Authorization", "Bearer chatgpt-token")
|
||||
s.Handler().ServeHTTP(rec, req)
|
||||
if rec.Code != 200 || !strings.Contains(string(got), `"effort":"xhigh"`) {
|
||||
t.Fatalf("%d %s, sent %s", rec.Code, rec.Body, got)
|
||||
}
|
||||
if u := usage.Load(time.Time{}); len(u) != 1 || u[0].Effort != "xhigh" {
|
||||
t.Errorf("usage %+v", u)
|
||||
}
|
||||
if rs := s.Trace(t.Context(), 0, 0).Routes; len(rs) != 1 || rs[0].Effort != "xhigh" || rs[0].Tries[0].Effort != "xhigh" {
|
||||
t.Errorf("trace %+v", rs)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user