Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(codex): exclude historical turns from resume responses (#9020)
mrlonelyb2561aad6105
diff --git a/server/pkg/agent/codex.go b/server/pkg/agent/codex.goindex 13a8f9b3cb..e168c38c0c 100644--- a/server/pkg/agent/codex.go+++ b/server/pkg/agent/codex.go@@ -2020,6 +2020,9 @@ func (c *codexClient) startOrResumeThread(ctx context.Context, opts ExecOptions,"cwd": opts.Cwd,"model": nilIfEmpty(opts.Model),"developerInstructions": nil,+ // Only omit history from the response, not the resumed model context.+ // We need the thread ID, not an unbounded single-line turns payload.+ "excludeTurns": true,}// Explicit override of the persisted reasoning effort: without// this, a Codex resume silently reuses whatever level the priordiff --git a/server/pkg/agent/codex_test.go b/server/pkg/agent/codex_test.goindex 887ca3f9d8..0386561dc8 100644--- a/server/pkg/agent/codex_test.go+++ b/server/pkg/agent/codex_test.go@@ -2362,6 +2362,12 @@ func TestCodexStartOrResumeThreadResumesPriorThread(t *testing.T) {if params["cwd"] != "/work" {t.Errorf("cwd = %v, want /work", params["cwd"])}+ if params["excludeTurns"] != true {+ t.Errorf("excludeTurns = %v, want true to avoid replaying unbounded history over stdout", params["excludeTurns"])+ }+ if _, ok := params["history"]; ok {+ t.Error("resume must load persisted history, not override it")+ }},},})@@ -3437,6 +3443,66 @@ func TestCodexExecuteFailsWhenProcessExitsDuringActiveTurn(t *testing.T) {t.Fatalf("process exit should fail fast instead of timeout, got %q", result.Error)}}++func TestCodexExecuteResumesWithoutHydratingLargeHistory(t *testing.T) {+ t.Parallel()+ if runtime.GOOS == "windows" {+ t.Skip("shell-script fixture is POSIX-only")+ }++ // Simulate an app-server whose persisted history exceeds the stdout line+ // cap. excludeTurns makes the response small without starting a new thread.+ fakePath := writeFakeCodexAppServer(t, `+read line+echo '{"jsonrpc":"2.0","id":1,"result":{}}'+read line+read line+case "$line" in+ *'"excludeTurns":true'*)+ echo '{"jsonrpc":"2.0","id":2,"result":{"thread":{"id":"thr_prior","turns":[]}}}'+ ;;+ *)+ printf '{"jsonrpc":"2.0","id":2,"result":{"thread":{"id":"thr_prior","turns":[{"text":"'+`+fmt.Sprintf(`head -c %d /dev/zero | tr '\0' 'x'`, agentStreamMaxLineBytes+1024*1024)+`+ printf '"}]}}}\n'+ exit 0+ ;;+esac+read line+printf '%s\n' "$line" > "$(dirname "$0")/turn-start.json"+echo '{"jsonrpc":"2.0","id":3,"result":{}}'+echo '{"jsonrpc":"2.0","method":"turn/started","params":{"threadId":"thr_prior","turn":{"id":"turn-current"}}}'+echo '{"jsonrpc":"2.0","method":"item/completed","params":{"threadId":"thr_prior","turnId":"turn-current","item":{"type":"agentMessage","id":"msg-current","text":"Continued"}}}'+echo '{"jsonrpc":"2.0","method":"turn/completed","params":{"threadId":"thr_prior","turn":{"id":"turn-current","status":"completed"}}}'+`)++ result := executeFakeCodex(t, fakePath, ExecOptions{+ ResumeSessionID: "thr_prior",+ ResumeExpected: true,+ Timeout: 5 * time.Second,+ SemanticInactivityTimeout: 5 * time.Second,+ })+ if result.Status != "completed" || result.SessionID != "thr_prior" || result.ResumeRejected || result.Output != "Continued" {+ t.Fatalf("expected successful continuation of the original thread, got %+v", result)+ }+ data, err := os.ReadFile(filepath.Join(filepath.Dir(fakePath), "turn-start.json"))+ if err != nil {+ t.Fatal(err)+ }+ var request struct {+ Method string `json:"method"`+ Params struct {+ ThreadID string `json:"threadId"`+ } `json:"params"`+ }+ if err := json.Unmarshal(data, &request); err != nil {+ t.Fatal(err)+ }+ if request.Method != "turn/start" || request.Params.ThreadID != "thr_prior" {+ t.Fatalf("expected turn/start on the original thread, got %s", data)+ }+}+func TestCodexExecuteCleansUpWhenScannerOverflowsOnResume(t *testing.T) {// Not t.Parallel(): this test mutates codexGracefulShutdownTimeoutNanos// globally, so running concurrently with other codex Execute tests