diff --git a/apps/server/src/provider/agentContextBudget.json b/apps/server/src/provider/agentContextBudget.json index 70b98d6cff0a..14b800f3c489 100644 --- a/apps/server/src/provider/agentContextBudget.json +++ b/apps/server/src/provider/agentContextBudget.json @@ -1,5 +1,5 @@ { - "claudeSystemAppendBytes": 6241, - "codexAdditionalContextBytes": 7635, + "claudeSystemAppendBytes": 6332, + "codexAdditionalContextBytes": 7726, "mcpToolListJsonBytes": 62351 } diff --git a/evals/mcp-tool-use/cases/threads-vs-tasks.ndjson b/evals/mcp-tool-use/cases/threads-vs-tasks.ndjson index 4819920e24c0..f3f35b4b493b 100644 --- a/evals/mcp-tool-use/cases/threads-vs-tasks.ndjson +++ b/evals/mcp-tool-use/cases/threads-vs-tasks.ndjson @@ -27,3 +27,4 @@ {"id": "tt-independent-local-default-no-remote", "area": "orchestration", "kind": "guard", "pattern": "Another thread and PR must use thread workspace binding", "experience": "Independent-work defaults must preserve an explicitly requested base or a local-only repository.", "rule": "`t3_thread_launch` and `create_threads` make new top-level threads, only when the user asks for a new thread. \"Subagent\", \"delegate\", and \"parallel\" never mean one. Worktree thread: set `workspaceStrategy`; shell worktrees do not bind it, and no checkout setup in its prompt.", "privacy": "commit-safe", "setup": {"role": "top", "context": "Repository: /home/user/app (acme/app). This is the local machine. Main is the local default branch. No Git remotes are configured.", "world": {"repo": "acme/app", "branch": "feature/error-display", "status": "", "files": {"docs/cache.md": "Cache exports must preserve keys.\n", "src/thread-pool.ts": "export const workerCount = 4;\n", "src/task-queue.ts": "export const queueLimit = 10;\n", "src/agent-config.ts": "export const agentLabel = \"Assistant\";\n", "AGENTS.md": "The repository default branch is main.\n"}, "remotes": []}, "mocks": {"t3_thread_wait": {"threadId": "11111111-1111-4111-8111-111111111111", "runId": "run-acme-thread", "status": "running", "timedOut": true, "next": "Completion wakes this thread. Do not wait on it or poll it. Continue other work, and end your turn when none is left."}}}, "prompt": "Open another thread in its own worktree to retire the legacy models, with its own independent PR.", "expect": {"calls": [{"tool": "t3_thread_launch", "args": {"workspaceStrategy.type": "worktree", "workspaceStrategy.baseRef": "main", "message": "~retir"}}], "notCalls": ["delegate_task", "Agent", "Workflow", "create_threads"], "shellMustNot": ["git\\s+worktree\\s+add"], "callsMustNot": [{"tool": "t3_thread_launch", "args": {"message": "~git worktree add"}}], "newThreads": ["~retir"]}, "source": {"request": "Reported unintended stack during independent model-retirement work, November 2026"}, "notes": "Synthetic guard for existing worktree behavior."} {"id":"tt-delegate-independent-worktree-from-origin","area":"orchestration","kind":"bad","pattern":"Independent delegate_task worktree must start from the remote, not a stale parent","experience":"A delegated worktree child for unrelated work was cut from the parent's commit instead of the fetched remote, so it started on stale code.","rule":"delegate_task: Separate checkout or PR per child: `isolation:'worktree'`, plus `startFromOrigin:true` when the work does not need your commits.","privacy":"commit-safe","setup":{"role":"top","context":"Repository: /home/user/app (acme/app). This is the local machine.","mocks":{"orchestrator_capabilities":{"parentThreadId":"33333333-3333-4333-8333-333333333333","inheritedProviderInstanceId":"claudeAgent","inheritedModel":"claude-sonnet-5-5","inheritedOptions":[{"id":"effort","value":"high"}],"runtimeMode":"full-access","interactionMode":"default","features":{"appOwnedSubagents":true,"asyncPolling":true,"cancellation":true,"batchThreadCreation":true,"threadManagement":true,"incrementalThreadRead":true,"scheduledTasks":true},"providers":[{"providerInstanceId":"claudeAgent","driverKind":"claudeAgent","displayName":"Claude","models":[{"id":"claude-opus-5-5","label":"Claude Opus 5.5","options":[{"id":"effort","values":["low","medium","high","xhigh","max"],"default":"high"},{"id":"fastMode","type":"boolean","default":false}]},{"id":"claude-sonnet-5-5","label":"Claude Sonnet 5.5","options":[{"id":"effort","values":["low","medium","high","xhigh","max"],"default":"high"}]},{"id":"claude-haiku-5-5","label":"Claude Haiku 5.5","options":[{"id":"effort","values":["low","medium","high","xhigh","max"],"default":"high"}]}]},{"providerInstanceId":"codex","driverKind":"codex","displayName":"Codex","models":[{"id":"gpt-6.1-sol","label":"GPT-6.1 Sol","options":[{"id":"reasoningEffort","values":["low","medium","high","xhigh","max"],"default":"high"},{"id":"serviceTier","values":["default","priority"],"default":"default"}]}]},{"providerInstanceId":"muse","driverKind":"muse","displayName":"Muse Code","runtimeModes":["approval-required","full-access"],"models":[{"id":"muse-wonder-full","label":"Muse Wonder Full","options":[{"id":"reasoningEffort","values":["minimal","low","medium","high","xhigh","max"],"default":"high"}]}]},{"providerInstanceId":"grok","driverKind":"grok","displayName":"Grok","models":[{"id":"grok-4.7","label":"Grok 4.7","options":[]}]}]},"delegate_task":"default"},"world":{"repo":"acme/app","branch":"main","status":"","files":{"src/session.ts":"export function reconnect(socket: Socket) {\n socket.close();\n return openSocket(socket.url); // races the close event\n}\n","src/session.test.ts":"it('reconnects after close', async () => {\n const s = await connect();\n reconnect(s);\n expect(s.state).toBe('open');\n});\n","src/export/csv.ts":"export function toCsv(rows: Row[]) {\n return rows.map((r) => [r.id, new Date(r.at).toLocaleString(), r.total].join(',')).join('\\n');\n}\n","AGENTS.md":"The repository default branch is main.\n"}}},"prompt":"Delegate a child to fix the flaky reconnect test in src/session.test.ts in its own worktree and open a PR. It is unrelated to what we're doing here. Meanwhile, explain what toCsv in src/export/csv.ts does.","expect":{"calls":[{"tool":"delegate_task","args":{"isolation":"worktree","startFromOrigin":true}}],"notCalls":["t3_thread_launch","create_threads"],"shellMustNot":["git\\s+worktree\\s+add"]},"source":{"request":"Fork work board reports, November 2026: delegated worktree children started 3 releases and 8 commits behind the remote"},"notes":"Bad before delegate_task took startFromOrigin: the field did not exist."} {"id":"tt-delegate-dependent-worktree-parent-commit","area":"orchestration","kind":"guard","pattern":"Dependent delegate_task worktree keeps the parent commit","experience":"A delegated child that must build on the parent's unpushed commits has to start from the parent commit, not the remote default branch.","rule":"delegate_task: Separate checkout or PR per child: `isolation:'worktree'`, plus `startFromOrigin:true` when the work does not need your commits.","privacy":"commit-safe","setup":{"role":"top","context":"Repository: /home/user/app (acme/app). This is the local machine.","mocks":{"orchestrator_capabilities":{"parentThreadId":"33333333-3333-4333-8333-333333333333","inheritedProviderInstanceId":"claudeAgent","inheritedModel":"claude-sonnet-5-5","inheritedOptions":[{"id":"effort","value":"high"}],"runtimeMode":"full-access","interactionMode":"default","features":{"appOwnedSubagents":true,"asyncPolling":true,"cancellation":true,"batchThreadCreation":true,"threadManagement":true,"incrementalThreadRead":true,"scheduledTasks":true},"providers":[{"providerInstanceId":"claudeAgent","driverKind":"claudeAgent","displayName":"Claude","models":[{"id":"claude-opus-5-5","label":"Claude Opus 5.5","options":[{"id":"effort","values":["low","medium","high","xhigh","max"],"default":"high"},{"id":"fastMode","type":"boolean","default":false}]},{"id":"claude-sonnet-5-5","label":"Claude Sonnet 5.5","options":[{"id":"effort","values":["low","medium","high","xhigh","max"],"default":"high"}]},{"id":"claude-haiku-5-5","label":"Claude Haiku 5.5","options":[{"id":"effort","values":["low","medium","high","xhigh","max"],"default":"high"}]}]},{"providerInstanceId":"codex","driverKind":"codex","displayName":"Codex","models":[{"id":"gpt-6.1-sol","label":"GPT-6.1 Sol","options":[{"id":"reasoningEffort","values":["low","medium","high","xhigh","max"],"default":"high"},{"id":"serviceTier","values":["default","priority"],"default":"default"}]}]},{"providerInstanceId":"muse","driverKind":"muse","displayName":"Muse Code","runtimeModes":["approval-required","full-access"],"models":[{"id":"muse-wonder-full","label":"Muse Wonder Full","options":[{"id":"reasoningEffort","values":["minimal","low","medium","high","xhigh","max"],"default":"high"}]}]},{"providerInstanceId":"grok","driverKind":"grok","displayName":"Grok","models":[{"id":"grok-4.7","label":"Grok 4.7","options":[]}]}]},"delegate_task":"default"},"world":{"repo":"acme/app","branch":"feature/reconnect","status":"","files":{"src/session.ts":"export function reconnect(socket: Socket) {\n socket.close();\n return openSocket(socket.url); // races the close event\n}\n","src/session.test.ts":"it('reconnects after close', async () => {\n const s = await connect();\n reconnect(s);\n expect(s.state).toBe('open');\n});\n","src/export/csv.ts":"export function toCsv(rows: Row[]) {\n return rows.map((r) => [r.id, new Date(r.at).toLocaleString(), r.total].join(',')).join('\\n');\n}\n","AGENTS.md":"The repository default branch is main.\n"},"commits":[{"sha":"9c1e2f4","subject":"feat(web): reconnect banner shows retry countdown"},{"sha":"5b7a0d3","subject":"feat(client): expose reconnect state from the socket"},{"sha":"2e48c61","subject":"refactor(client): extract reconnect backoff"}]}},"prompt":"Delegate a child in its own worktree to add tests for the reconnect changes I just committed here (not pushed yet) and open a PR stacked on this branch. Meanwhile, explain what toCsv in src/export/csv.ts does.","expect":{"calls":[{"tool":"delegate_task","args":{"isolation":"worktree"}}],"notCalls":["t3_thread_launch","create_threads"],"shellMustNot":["git\\s+worktree\\s+add"],"callsMustNot":[{"tool":"delegate_task","args":{"startFromOrigin":true}}]},"source":{"request":"Control for tt-delegate-independent-worktree-from-origin, November 2026"},"notes":"Omitting startFromOrigin and baseRef keeps the parent commit, which holds the unpushed work."} +{"id":"tt-standing-request-another-project","area":"orchestration","kind":"bad","pattern":"standing dispatch rule for another project after delegate_task refusal: t3_thread_launch","experience":"A coordinator with a standing board-dispatch rule refused to call t3_thread_launch for a task in another local project because orchestration instructions said 'only when the user asks for a new thread', even after delegate_task refused target.projectId and named t3_thread_launch.","rule":"`t3_thread_launch` and `create_threads` make new top-level threads, only when the user asks (directly, in standing project or board-dispatch rules, or via a T3 tool refusal naming `t3_thread_launch`).","privacy":"commit-safe","setup":{"role":"top","context":"Repository: /home/user/code/app (acme/app). This is the local machine. Project instructions (AGENTS.md): You are the work-board coordinator. Dispatch ready board tasks to workers in their owning project's worktree. If a rule in project instructions conflicts with your T3 Code system orchestration instructions, stop and report the conflict instead of breaking T3 Code system instructions.","priorTurns":[{"role":"user","text":"[Scheduled board tick] Ready task billing-42 (repo: billing): 'Bump the Stripe SDK to v18 and fix broken imports.' Dispatch ready work."},{"role":"assistant","toolCalls":[{"tool":"t3_project_list","input":{},"result":{"projects":[{"id":"22222222-2222-4222-8222-222222222222","title":"app","workspaceRoot":"/home/user/code/app"},{"id":"22222222-2222-4222-8222-bbbbbbbbbbbb","title":"billing","workspaceRoot":"/home/user/code/billing"}],"nextCursor":null}},{"tool":"delegate_task","input":{"title":"billing-42: Bump Stripe SDK to v18","mode":"async","isolation":"worktree","target":{"projectId":"22222222-2222-4222-8222-bbbbbbbbbbbb"},"task":"Bump the Stripe SDK to v18 and fix broken imports."},"result":{"code":"invalid_request","message":"A local task runs in this thread's project, so omit target.projectId. For another project in this environment, use t3_thread_launch with its projectId and a worktree workspaceStrategy ({type: \"worktree\"}). target.environmentId only reaches a remote environment; this one's id changes nothing."}}]}],"mocks":{"orchestrator_capabilities":{"parentThreadId":"33333333-3333-4333-8333-333333333333","inheritedProviderInstanceId":"claudeAgent","inheritedModel":"claude-sonnet-5-5","inheritedOptions":[{"id":"effort","value":"high"}],"runtimeMode":"full-access","interactionMode":"default","features":{"appOwnedSubagents":true,"asyncPolling":true,"cancellation":true,"batchThreadCreation":true,"threadManagement":true,"incrementalThreadRead":true,"scheduledTasks":true},"providers":[{"providerInstanceId":"claudeAgent","driverKind":"claudeAgent","displayName":"Claude","models":[{"id":"claude-opus-5-5","label":"Claude Opus 5.5","options":[{"id":"effort","values":["low","medium","high","xhigh","max"],"default":"high"},{"id":"fastMode","type":"boolean","default":false}]},{"id":"claude-sonnet-5-5","label":"Claude Sonnet 5.5","options":[{"id":"effort","values":["low","medium","high","xhigh","max"],"default":"high"}]},{"id":"claude-haiku-5-5","label":"Claude Haiku 5.5","options":[{"id":"effort","values":["low","medium","high","xhigh","max"],"default":"high"}]}]},{"providerInstanceId":"codex","driverKind":"codex","displayName":"Codex","models":[{"id":"gpt-6.1-sol","label":"GPT-6.1 Sol","options":[{"id":"reasoningEffort","values":["low","medium","high","xhigh","max"],"default":"high"},{"id":"serviceTier","values":["default","priority"],"default":"default"}]}]},{"providerInstanceId":"muse","driverKind":"muse","displayName":"Muse Code","runtimeModes":["approval-required","full-access"],"models":[{"id":"muse-wonder-full","label":"Muse Wonder Full","options":[{"id":"reasoningEffort","values":["minimal","low","medium","high","xhigh","max"],"default":"high"}]}]},{"providerInstanceId":"grok","driverKind":"grok","displayName":"Grok","models":[{"id":"grok-4.7","label":"Grok 4.7","options":[]}]}]},"t3_project_list":{"projects":[{"id":"22222222-2222-4222-8222-222222222222","title":"app","workspaceRoot":"/home/user/code/app"},{"id":"22222222-2222-4222-8222-bbbbbbbbbbbb","title":"billing","workspaceRoot":"/home/user/code/billing"}],"nextCursor":null}},"world":{"repo":"acme/app","branch":"main","status":"","files":{"AGENTS.md":"You are the work-board coordinator. Dispatch ready board tasks to workers in their owning project's worktree.\n","src/session.ts":"export function reconnect(socket: Socket) {\n socket.close();\n return openSocket(socket.url);\n}\n"}}},"prompt":"","expect":{"calls":[{"tool":"t3_thread_launch","args":{"projectId":"22222222-2222-4222-8222-bbbbbbbbbbbb","workspaceStrategy.type":"worktree"}}],"notCalls":["delegate_task","Agent","create_threads","Edit","Write"],"shellMustNot":["git\\s+worktree\\s+add"],"newThreads":["~stripe"]},"source":{"request":"t3code-94 / dotfiles board feedback -434 and -550 (2026-11)"},"notes":"Synthetic Acme scenario reproducing cross-project board dispatch after delegate_task refuses target.projectId and names t3_thread_launch. Empty prompt resumes immediately after the refusal."} diff --git a/packages/provider-core/src/server/orchestrationInstructions.test.ts b/packages/provider-core/src/server/orchestrationInstructions.test.ts index 4d336e643a67..401e145f5265 100644 --- a/packages/provider-core/src/server/orchestrationInstructions.test.ts +++ b/packages/provider-core/src/server/orchestrationInstructions.test.ts @@ -130,4 +130,17 @@ describe("T3 orchestration instructions", () => { `\n\n${T3_CODE_ORCHESTRATION_SECTIONS.join("\n\n")}\n`, ); }); + + it("lets standing project or board-dispatch rules and tool refusals count as the user's ask for t3_thread_launch while keeping the subagent guard", () => { + for (const instructions of [ + T3_CODE_ORCHESTRATION_INSTRUCTIONS, + T3_CODE_ANTIGRAVITY_ORCHESTRATION_INSTRUCTIONS, + ]) { + assert.include( + instructions, + "`t3_thread_launch` and `create_threads` make new top-level threads, only when the user asks (directly, in standing project or board-dispatch rules, or via a T3 tool refusal naming `t3_thread_launch`).", + ); + assert.include(instructions, '"Subagent", "delegate", and "parallel" never mean one.'); + } + }); }); diff --git a/packages/provider-core/src/server/orchestrationInstructions.ts b/packages/provider-core/src/server/orchestrationInstructions.ts index c2d2cbfd0787..6c211cd86eb2 100644 --- a/packages/provider-core/src/server/orchestrationInstructions.ts +++ b/packages/provider-core/src/server/orchestrationInstructions.ts @@ -16,7 +16,7 @@ ${subagentGuidance} - Every new delegate review or re-check is a new \`delegate_task\` (brief, findings, objections), never a \`t3_thread_send\`. Fix small review findings yourself; start no delegate for them. When told to proceed without a delegate, or to run fewer, \`task_cancel\` the extras. Start no replacement. - Follow a running delegate's \`next\`. Don't poll it (\`task_status\`, \`sleep\`, watchers, Monitor, ScheduleWakeup). Stop a delegate run you replace or no longer need with \`task_cancel\`, never \`t3_thread_interrupt\` on its thread. - As a subagent or child, do the work yourself. Start no subagents unless your task says to.`, - `- \`t3_thread_launch\` and \`create_threads\` make new top-level threads, only when the user asks for a new thread. "Subagent", "delegate", and "parallel" never mean one. Worktree thread: set \`workspaceStrategy\`. Honor a requested base. Otherwise independent work uses the default branch as \`remote/branch\` with \`startFromOrigin:true\`; with no remote, use the local default. Required unpublished commits and dependent work use their local base. Shell worktrees don't bind it, and no checkout setup in its prompt. No \`workspaceStrategy\`: project default, not your worktree. + `- \`t3_thread_launch\` and \`create_threads\` make new top-level threads, only when the user asks (directly, in standing project or board-dispatch rules, or via a T3 tool refusal naming \`t3_thread_launch\`). "Subagent", "delegate", and "parallel" never mean one. Worktree thread: set \`workspaceStrategy\`. Honor a requested base. Otherwise independent work uses the default branch as \`remote/branch\` with \`startFromOrigin:true\`; with no remote, use the local default. Required unpublished commits and dependent work use their local base. Shell worktrees don't bind it, and no checkout setup in its prompt. No \`workspaceStrategy\`: project default, not your worktree. - Given a thread id, \`t3_thread_read\` it before you answer about it. Asked to settle a thread, this one too: \`t3_thread_organize\`. - Another machine: \`t3_environment_links\` lists linked ones. Pass its \`environmentId\` and that machine's \`threadId\` to T3 tools. - Unlinked ("delegate this to my vps"): \`t3_environment_link\` with a \`hint\` from the user's words, never a pairing code in chat. No link tools: say to enable Settings → Labs → Linked environments.