Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(agent): lift Codex project_doc_max_bytes so the runtime brief is not truncated (MUL-10124) (#11648)
Bohan Jiang9fe5209612a2
diff --git a/server/pkg/agent/codex.go b/server/pkg/agent/codex.goindex e18b6e9b3b..db565495cf 100644--- a/server/pkg/agent/codex.go+++ b/server/pkg/agent/codex.go@@ -1886,6 +1886,19 @@ func codexTurnInput(prompt string, resumeExpected, resumed bool, notice string)return []map[string]any{{"type": "text", "text": text}}}+// codexProjectDocMaxBytes replaces Codex's project_doc_max_bytes (32 KiB by+// default) for daemon threads. Codex reads AGENTS.md only up to that many bytes+// and silently drops the rest, which cut the trailing Workflow / Mentions /+// Output sections off long runtime briefs (GitHub #11480). The cap is not+// persisted with the thread, so every thread/start and thread/resume sends it.+const codexProjectDocMaxBytes = 4 << 20++// codexThreadConfig is the per-thread config override the daemon sends with+// thread/start and thread/resume.+func codexThreadConfig() map[string]any {+ return map[string]any{"project_doc_max_bytes": codexProjectDocMaxBytes}+}+// startOrResumeThread picks between Codex's thread/resume and thread/start// based on opts.ResumeSessionID. When a prior thread ID is provided it first// tries thread/resume; recoverable protocol errors (unknown thread, schema@@ -1904,6 +1917,7 @@ func (c *codexClient) startOrResumeThread(ctx context.Context, opts ExecOptions,"threadId": priorThreadID,"cwd": opts.Cwd,"model": nilIfEmpty(opts.Model),+ "config": codexThreadConfig(),"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.@@ -1966,7 +1980,7 @@ func (c *codexClient) startOrResumeThread(ctx context.Context, opts ExecOptions,"cwd": opts.Cwd,"approvalPolicy": nil,"sandbox": nil,- "config": nil,+ "config": codexThreadConfig(),"baseInstructions": nil,"developerInstructions": nil,"compactPrompt": nil,diff --git a/server/pkg/agent/codex_test.go b/server/pkg/agent/codex_test.goindex 4927004ed8..bee9edfd1a 100644--- a/server/pkg/agent/codex_test.go+++ b/server/pkg/agent/codex_test.go@@ -2840,6 +2840,46 @@ func TestCodexThreadResumeNeverInlinesSystemPrompt(t *testing.T) {}}+// assertProjectDocMaxBytes checks that thread setup lifts Codex's 32 KiB+// AGENTS.md cap, which would otherwise drop the end of a long runtime brief+// (GitHub #11480). Codex does not persist the override, so resume needs it too.+func assertProjectDocMaxBytes(t *testing.T, params map[string]any) {+ t.Helper()+ config, ok := params["config"].(map[string]any)+ if !ok {+ t.Fatalf("config = %#v, want an object carrying project_doc_max_bytes", params["config"])+ }+ if got := config["project_doc_max_bytes"]; got != float64(codexProjectDocMaxBytes) {+ t.Errorf("project_doc_max_bytes = %v, want %d", got, codexProjectDocMaxBytes)+ }+}++func TestCodexThreadSetupLiftsProjectDocCap(t *testing.T) {+ t.Parallel()++ for _, tc := range []struct {+ method string+ opts ExecOptions+ }{+ {method: "thread/start", opts: ExecOptions{Cwd: "/work"}},+ {method: "thread/resume", opts: ExecOptions{Cwd: "/work", ResumeSessionID: "thr_prior"}},+ } {+ t.Run(tc.method, func(t *testing.T) {+ t.Parallel()+ c, fs, _ := newTestCodexClient(t)+ wait := drainRPCScript(t, c, fs, []rpcResponse{{+ method: tc.method,+ result: json.RawMessage(`{"thread":{"id":"thr_prior"}}`),+ assertFn: assertProjectDocMaxBytes,+ }})+ defer wait()+ if _, _, err := c.startOrResumeThread(context.Background(), tc.opts, slog.Default()); err != nil {+ t.Fatalf("startOrResumeThread: %v", err)+ }+ })+ }+}+func TestCodexStartOrResumeThreadFallsBackOnResumeError(t *testing.T) {t.Parallel()