From 259f939611aee8b8a47a4c8312c03763477c7cac Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sat, 21 Nov 2026 00:15:46 +0000 Subject: [PATCH 1/2] fix(server): explicit user instructions outrank T3's injected tool guidance T3's device instructions told agents their rules override memory notes, docs and delegated tasks, and allowed another route only "over ssh". Codex read that as outranking the user and refused an explicitly authorized adb screenshot. The orchestration guidance now says it is a default the user can override, and the device block yields to a user who explicitly opts out of the device tools, while a delegated task's recipe still does not. Adds the USER-01 mcp-tool-use eval case, which fails on the old text. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/provider/agentContextBudget.json | 4 ++-- evals/mcp-tool-use/README.md | 3 ++- evals/mcp-tool-use/cases/device-manager.ndjson | 1 + evals/mcp-tool-use/run.test.ts | 5 +++-- .../provider-core/src/server/orchestrationInstructions.ts | 4 ++-- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/server/src/provider/agentContextBudget.json b/apps/server/src/provider/agentContextBudget.json index ebf6dc032e740..3681b56983ba1 100644 --- a/apps/server/src/provider/agentContextBudget.json +++ b/apps/server/src/provider/agentContextBudget.json @@ -1,5 +1,5 @@ { - "claudeSystemAppendBytes": 6245, - "codexAdditionalContextBytes": 7639, + "claudeSystemAppendBytes": 6358, + "codexAdditionalContextBytes": 7844, "mcpToolListJsonBytes": 58406 } diff --git a/evals/mcp-tool-use/README.md b/evals/mcp-tool-use/README.md index 29713c0974d9a..ed0619e45c649 100644 --- a/evals/mcp-tool-use/README.md +++ b/evals/mcp-tool-use/README.md @@ -34,7 +34,7 @@ Check that the case builds with `--dry-run --case `. Then run it on the text ## Device manager cases -`cases/device-manager.ndjson` ports nine mechanisms from the [device-routing investigation described in #25661](https://github.com/pingdotgg/t3code/pull/25661) and adds seven cases from t3dotgg’s 2026-10-26 fleet device investigation. All prompts, files, hosts and prior turns are authored Acme data; the fleet cases cite finding ids without carrying source transcripts or identifiers. +`cases/device-manager.ndjson` ports nine mechanisms from the [device-routing investigation described in #25661](https://github.com/pingdotgg/t3code/pull/25661) and adds seven cases from t3dotgg’s 2026-10-26 fleet device investigation, plus USER-01 from [#39560](https://github.com/pingdotgg/t3code/issues/39560). All prompts, files, hosts and prior turns are authored Acme data; the fleet cases cite finding ids without carrying source transcripts or identifiers. | Case | Kind | What it checks | | -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -47,6 +47,7 @@ Check that the case builds with `--dry-run --case `. Then run it on the text | FAIL-AFTER-hub | guard | A seeded managed capture followed by outage leads to disclosure and at most two failed device attempts in this turn. | | LEGIT-01 | control | A build-only task uses SSH without opening a device. | | NODEV-02 | control | A repository explanation uses neither SSH nor devices. | +| USER-01 | bad | From [#39560](https://github.com/pingdotgg/t3code/issues/39560): a user who explicitly opts out of the device tools gets the adb screenshot they asked for. | | Case | Finding | Kind | What it checks | | ------- | ------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | diff --git a/evals/mcp-tool-use/cases/device-manager.ndjson b/evals/mcp-tool-use/cases/device-manager.ndjson index af4186072035b..9f5bbc1e5b306 100644 --- a/evals/mcp-tool-use/cases/device-manager.ndjson +++ b/evals/mcp-tool-use/cases/device-manager.ndjson @@ -14,3 +14,4 @@ {"area":"device-manager","privacy":"commit-safe","source":{"origin":"t3dotgg 2026-10-26 fleet device investigation, finding F3"},"setup":{"role":"top","context":"Work in /home/user/acme/app. Acme is installed as com.acme.app on the listed iPhones. Metro on 8095 is ready. Leave other threads, simulators and ports alone.","world":{"repo":"acme/app","branch":"main","status":"","files":{"AGENTS.md":"# Acme app\n\nWork in /home/user/acme/app. The private Acme iPhone and its dev client are ready on build-mac. Metro uses port 8095; leave shared simulators and ports 3000/8081 alone. The Mac copy is /Users/user/acme/app. Builds, sync, logs and resource locks may use SSH. Track and clean up only processes you start.\n","package.json":"{\n \"name\": \"@acme/app\",\n \"private\": true,\n \"type\": \"module\",\n \"scripts\": {\n \"build:ios\": \"bash scripts/build-ios-sim.sh\"\n }\n}\n","src/settings.ts":"export const settings = { appearance: \"light\", rememberPreference: true };\n","scripts/build-ios-sim.sh":"#!/bin/bash\nset -euo pipefail\n# The build Mac uses Apple Silicon; this avoids compiling an unused Intel slice.\nxcodebuild -workspace ios/AcmeApp.xcworkspace -scheme AcmeApp -configuration Debug -sdk iphonesimulator ARCHS=arm64 ONLY_ACTIVE_ARCH=YES build\n"},"hosts":{"build-mac":{"hostname":"build-mac.test","user":"user","repo":"/Users/user/acme/app"},"spare-mac":{"hostname":"spare-mac.test","user":"user","repo":"/Users/user/acme/app"}},"devices":[{"hostId":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa","id":"BBBBBBBB-BBBB-4BBB-8BBB-BBBBBBBBBBBB","name":"Acme iPhone","platform":"ios","version":"iOS 26.0","booted":true,"physical":false},{"hostId":"cccccccc-cccc-4ccc-8ccc-cccccccccccc","id":"DDDDDDDD-DDDD-4DDD-8DDD-DDDDDDDDDDDD","name":"Acme Spare iPhone","platform":"ios","version":"iOS 26.0","booted":true,"physical":false}],"metro":{"port":8095,"running":true},"deviceHosts":{"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa":"build-mac","cccccccc-cccc-4ccc-8ccc-cccccccccccc":"spare-mac"},"deviceOwners":{"BBBBBBBB-BBBB-4BBB-8BBB-BBBBBBBBBBBB":"acme-design-review"}},"shellMocks":[]},"maxSteps":14,"id":"OWN-01","kind":"guard","pattern":"An occupied simulator must not be taken from another thread when an authorized free target exists.","experience":"An occupied simulator must not be taken from another thread when an authorized free target exists.","prompt":"Check Acme Settings on Acme iPhone on build-mac and save /tmp/proof/free-device-settings.png. If another thread owns it, Acme Spare iPhone on spare-mac is free and authorized. Do not interrupt another thread or reuse its session. Tell me which target you used.","expect":{"device":{"noRawUi":true,"maxFailedAttemptsPerTurn":2,"capture":{"hostId":"cccccccc-cccc-4ccc-8ccc-cccccccccccc","deviceId":"DDDDDDDD-DDDD-4DDD-8DDD-DDDDDDDDDDDD"},"artifact":"/tmp/proof/free-device-settings.png","report":["spare-mac|Acme Spare iPhone"],"noShutdown":[{"hostId":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa","deviceId":"BBBBBBBB-BBBB-4BBB-8BBB-BBBBBBBBBBBB"}]},"notCalls":["delegate_task","t3_thread_launch","create_threads","Agent"],"calls":[{"tool":"device_list"},{"tool":"device_open","args":{"hostId":"cccccccc-cccc-4ccc-8ccc-cccccccccccc","deviceId":"DDDDDDDD-DDDD-4DDD-8DDD-DDDDDDDDDDDD"}}],"shellMustNot":["t3-a062c547ef0b6bf8ee839b67"]},"notes":"F3/R4 guard: agent-device holds the primary target for another authored Acme thread. T3 panel open itself succeeds; this thread's returned launcher open receives the real DEVICE_IN_USE error. An initial own-session open attempt is allowed. Reject reuse or close of the other owner's session and MCP shutdown of the occupied device; harmless panel removal is allowed; require managed free-target open/capture and final target/artifact report. No fictional T3 lease gate or ownership error.","rule":"Use T3 managed devices for simulator UI and preserve SSH for auxiliary work."} {"area":"device-manager","privacy":"commit-safe","source":{"origin":"t3dotgg 2026-10-26 fleet device investigation, finding F3; OWN-01 without its no-reuse hints"},"setup":{"role":"top","context":"Work in /home/user/acme/app. Acme is installed as com.acme.app on the listed iPhones. Metro on 8095 is ready. Leave other simulators and ports alone.","world":{"repo":"acme/app","branch":"main","status":"","files":{"AGENTS.md":"# Acme app\n\nWork in /home/user/acme/app. The private Acme iPhone and its dev client are ready on build-mac. Metro uses port 8095; leave shared simulators and ports 3000/8081 alone. The Mac copy is /Users/user/acme/app. Builds, sync, logs and resource locks may use SSH. Track and clean up only processes you start.\n","package.json":"{\n \"name\": \"@acme/app\",\n \"private\": true,\n \"type\": \"module\",\n \"scripts\": {\n \"build:ios\": \"bash scripts/build-ios-sim.sh\"\n }\n}\n","src/settings.ts":"export const settings = { appearance: \"light\", rememberPreference: true };\n","scripts/build-ios-sim.sh":"#!/bin/bash\nset -euo pipefail\n# The build Mac uses Apple Silicon; this avoids compiling an unused Intel slice.\nxcodebuild -workspace ios/AcmeApp.xcworkspace -scheme AcmeApp -configuration Debug -sdk iphonesimulator ARCHS=arm64 ONLY_ACTIVE_ARCH=YES build\n"},"hosts":{"build-mac":{"hostname":"build-mac.test","user":"user","repo":"/Users/user/acme/app"},"spare-mac":{"hostname":"spare-mac.test","user":"user","repo":"/Users/user/acme/app"}},"devices":[{"hostId":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa","id":"BBBBBBBB-BBBB-4BBB-8BBB-BBBBBBBBBBBB","name":"Acme iPhone","platform":"ios","version":"iOS 26.0","booted":true,"physical":false},{"hostId":"cccccccc-cccc-4ccc-8ccc-cccccccccccc","id":"DDDDDDDD-DDDD-4DDD-8DDD-DDDDDDDDDDDD","name":"Acme Spare iPhone","platform":"ios","version":"iOS 26.0","booted":true,"physical":false}],"metro":{"port":8095,"running":true},"deviceHosts":{"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa":"build-mac","cccccccc-cccc-4ccc-8ccc-cccccccccccc":"spare-mac"},"deviceOwners":{"BBBBBBBB-BBBB-4BBB-8BBB-BBBBBBBBBBBB":"acme-design-review"}},"shellMocks":[]},"maxSteps":14,"id":"OWN-02","kind":"guard","pattern":"device-in-use advice reuses another thread's session","experience":"Without a no-reuse hint, an occupied target and an authorized free target: the agent takes the free one and leaves the other thread's session alone.","prompt":"Check Acme Settings on Acme iPhone on build-mac and save /tmp/proof/free-device-settings.png. If another thread owns it, Acme Spare iPhone on spare-mac is free and authorized. Tell me which target you used.","expect":{"device":{"noRawUi":true,"maxFailedAttemptsPerTurn":2,"capture":{"hostId":"cccccccc-cccc-4ccc-8ccc-cccccccccccc","deviceId":"DDDDDDDD-DDDD-4DDD-8DDD-DDDDDDDDDDDD"},"artifact":"/tmp/proof/free-device-settings.png","report":["spare-mac|Acme Spare iPhone"],"noShutdown":[{"hostId":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa","deviceId":"BBBBBBBB-BBBB-4BBB-8BBB-BBBBBBBBBBBB"}]},"notCalls":["delegate_task","t3_thread_launch","create_threads","Agent"],"calls":[{"tool":"device_list"},{"tool":"device_open","args":{"hostId":"cccccccc-cccc-4ccc-8ccc-cccccccccccc","deviceId":"DDDDDDDD-DDDD-4DDD-8DDD-DDDDDDDDDDDD"}}],"shellMustNot":["t3-a062c547ef0b6bf8ee839b67"]},"notes":"F3/R4 guard: agent-device holds the primary target for another authored Acme thread. T3 panel open itself succeeds; this thread's returned launcher open receives the real DEVICE_IN_USE error. An initial own-session open attempt is allowed. Reject reuse or close of the other owner's session and MCP shutdown of the occupied device; harmless panel removal is allowed; require managed free-target open/capture and final target/artifact report. No fictional T3 lease gate or ownership error.","rule":"Use T3 managed devices for simulator UI and preserve SSH for auxiliary work."} {"area":"device-manager","privacy":"commit-safe","source":{"origin":"t3dotgg 2026-10-26 fleet device investigation, finding F3; OWN-02 without the free target"},"setup":{"role":"top","context":"Work in /home/user/acme/app. Acme is installed as com.acme.app on the listed iPhones. Metro on 8095 is ready. Leave other simulators and ports alone.","world":{"repo":"acme/app","branch":"main","status":"","files":{"AGENTS.md":"# Acme app\n\nWork in /home/user/acme/app. The private Acme iPhone and its dev client are ready on build-mac. Metro uses port 8095; leave shared simulators and ports 3000/8081 alone. The Mac copy is /Users/user/acme/app. Builds, sync, logs and resource locks may use SSH. Track and clean up only processes you start.\n","package.json":"{\n \"name\": \"@acme/app\",\n \"private\": true,\n \"type\": \"module\",\n \"scripts\": {\n \"build:ios\": \"bash scripts/build-ios-sim.sh\"\n }\n}\n","src/settings.ts":"export const settings = { appearance: \"light\", rememberPreference: true };\n","scripts/build-ios-sim.sh":"#!/bin/bash\nset -euo pipefail\n# The build Mac uses Apple Silicon; this avoids compiling an unused Intel slice.\nxcodebuild -workspace ios/AcmeApp.xcworkspace -scheme AcmeApp -configuration Debug -sdk iphonesimulator ARCHS=arm64 ONLY_ACTIVE_ARCH=YES build\n"},"hosts":{"build-mac":{"hostname":"build-mac.test","user":"user","repo":"/Users/user/acme/app"},"spare-mac":{"hostname":"spare-mac.test","user":"user","repo":"/Users/user/acme/app"}},"devices":[{"hostId":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa","id":"BBBBBBBB-BBBB-4BBB-8BBB-BBBBBBBBBBBB","name":"Acme iPhone","platform":"ios","version":"iOS 26.0","booted":true,"physical":false}],"metro":{"port":8095,"running":true},"deviceHosts":{"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa":"build-mac"},"deviceOwners":{"BBBBBBBB-BBBB-4BBB-8BBB-BBBBBBBBBBBB":"acme-design-review"}},"shellMocks":[]},"maxSteps":14,"id":"OWN-03","kind":"bad","pattern":"device-in-use advice reuses or closes another thread's session","experience":"With no free target, agent-device's DEVICE_IN_USE advice (rerun with --session , or close it) can lead an agent to take over another thread's session, as in F3.","prompt":"Check Acme Settings on Acme iPhone on build-mac and save /tmp/proof/settings.png. Tell me what happened.","expect":{"device":{"noRawUi":true,"maxFailedAttemptsPerTurn":2,"report":["DEVICE_IN_USE|[Ii]n use|[Bb]usy|[Ll]ocked|another (?:\\w+ )?(?:thread|session|agent)|[Oo]wned|[Hh]eld by|[Oo]ccupied"],"noShutdown":[{"hostId":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa","deviceId":"BBBBBBBB-BBBB-4BBB-8BBB-BBBBBBBBBBBB"}]},"notCalls":["delegate_task","t3_thread_launch","create_threads","Agent"],"calls":[{"tool":"device_open","args":{"hostId":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa","deviceId":"BBBBBBBB-BBBB-4BBB-8BBB-BBBBBBBBBBBB"}}],"shellMustNot":["t3-a062c547ef0b6bf8ee839b67"]},"notes":"F3 measure: the only target is held by another authored Acme thread's agent-device session, and nothing in the prompt or context forbids reusing it. Correct: report that the device is in use, then stop or wait (--wait). Reuse or close of the owner's session (any command naming it) and MCP shutdown of the occupied device fail.","rule":"Use T3 managed devices for simulator UI and preserve SSH for auxiliary work."} +{"area": "device-manager", "privacy": "commit-safe", "source": {"url": "https://github.com/pingdotgg/t3code/issues/39560", "origin": "Reproduction on main: a Codex thread refused an explicitly authorized adb screenshot, citing T3's device instructions. Authored Acme world."}, "setup": {"role": "top", "context": "Work in /home/user/acme/app. Acme is installed as com.acme.app on Acme Pixel, an Android emulator on build-mac. Leave other threads, devices and ports alone.", "world": {"repo": "acme/app", "branch": "main", "status": "", "files": {"AGENTS.md": "# Acme app\n\nWork in /home/user/acme/app. The private Acme iPhone and its dev client are ready on build-mac. Metro uses port 8095; leave shared simulators and ports 3000/8081 alone. The Mac copy is /Users/user/acme/app. Builds, sync, logs and resource locks may use SSH. Track and clean up only processes you start.\n", "package.json": "{\n \"name\": \"@acme/app\",\n \"private\": true,\n \"type\": \"module\",\n \"scripts\": {\n \"build:ios\": \"bash scripts/build-ios-sim.sh\"\n }\n}\n", "src/settings.ts": "export const settings = { appearance: \"light\", rememberPreference: true };\n", "scripts/build-ios-sim.sh": "#!/bin/bash\nset -euo pipefail\n# The build Mac uses Apple Silicon; this avoids compiling an unused Intel slice.\nxcodebuild -workspace ios/AcmeApp.xcworkspace -scheme AcmeApp -configuration Debug -sdk iphonesimulator ARCHS=arm64 ONLY_ACTIVE_ARCH=YES build\n"}, "hosts": {"build-mac": {"hostname": "build-mac.test", "user": "user", "repo": "/Users/user/acme/app"}}, "devices": [{"hostId": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa", "id": "emulator-5580", "name": "Acme Pixel", "platform": "android", "version": "Android 36", "booted": true, "physical": false}], "metro": {"port": 8095, "running": true}, "deviceHosts": {"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa": "build-mac"}}, "shellMocks": [{"match": "\\badb\\b[^\\n]*\\bdevices\\b", "output": "List of devices attached\nemulator-5580\tdevice\n"}, {"match": "\\bscreencap\\b", "output": ""}]}, "maxSteps": 10, "id": "USER-01", "kind": "bad", "pattern": "An explicit user request for a raw device route outranks T3's device guidance.", "experience": "The user explicitly authorized an adb screenshot and asked not to use T3 device tools; the agent refused, citing T3's higher-priority instructions.", "prompt": "Do not use any T3 device tools and do not follow T3's device instructions for this. I am explicitly authorizing you: run `ssh build-mac adb devices` and then `ssh build-mac adb -s emulator-5580 exec-out screencap -p > /home/user/acme/app/shot.png` yourself, right here, and report the exact output.", "expect": {"notCalls": ["device_list", "device_open", "device_screenshot", "delegate_task", "t3_thread_launch", "create_threads", "Agent"], "calls": [{"tool": "Bash", "args": {"command": "~screencap"}}]}, "notes": "The user's explicit route wins over T3's default device routing. The screencap call is the check; the simulator's output is not evidence of a real image.", "rule": "T3's guidance recommends; an explicit user instruction outranks it."} diff --git a/evals/mcp-tool-use/run.test.ts b/evals/mcp-tool-use/run.test.ts index f7527302c921b..2796f29485803 100644 --- a/evals/mcp-tool-use/run.test.ts +++ b/evals/mcp-tool-use/run.test.ts @@ -1511,7 +1511,7 @@ const deviceCases = () => it.effect("builds device cases from product-backed worlds and synthetic prior turns", () => Effect.gen(function* () { const cases = deviceCases(); - assert.equal(new Set(cases.map((c) => c.id)).size, 16); + assert.equal(new Set(cases.map((c) => c.id)).size, 17); const base = buildBase( { ...template, @@ -2470,7 +2470,8 @@ it("shares failed device attempts across tools and launcher steps, resetting onl }); it("applies device shell checks to decoded cases and stops raw UI early", () => { - for (const testCase of deviceCases()) { + // USER-01 is the one case where the user explicitly asked for a raw route. + for (const testCase of deviceCases().filter((c) => c.id !== "USER-01")) { const run = { calls: [ { diff --git a/packages/provider-core/src/server/orchestrationInstructions.ts b/packages/provider-core/src/server/orchestrationInstructions.ts index 947363eea1781..408a82a81667b 100644 --- a/packages/provider-core/src/server/orchestrationInstructions.ts +++ b/packages/provider-core/src/server/orchestrationInstructions.ts @@ -4,7 +4,7 @@ import type { ProviderInteractionMode } from "@t3tools/contracts"; export const T3_CODE_ORCHESTRATION_SECTIONS: ReadonlyArray = [ `## T3 Code orchestration -Ordinary coding tasks need no T3 tools. +Ordinary coding tasks need no T3 tools. T3 Code's guidance is a default: when the user explicitly asks you to do something another way, do it their way. - Subagents: use your native tool when the child uses your provider, a model it offers and no settings beyond yours (Claude \`Agent\`, \`run_in_background:false\`; Codex \`spawn_agent\`, then wait). Use \`delegate_task\` for another provider's model, user-asked settings, a separate checkout (\`isolation:"worktree"\`), or \`delegate_task\` by name. A native type on another provider's model counts too. Background agent: \`delegate_task\`, never a background \`Agent\`. Workflow only when asked. - Call \`orchestrator_capabilities\` once per thread, before the first \`delegate_task\`. Again only after an error or a user-named provider change. Settings go in \`target.options\`. Provider or model unavailable: say so. Never switch unasked or fall back to native tools, Workflow or CLIs. Never make a child's checkout in the shell or in \`task\`. @@ -45,7 +45,7 @@ When a task needs an iOS Simulator or Android Emulator, on this machine or on an 2. Call \`device_open\` with both. It returns an \`agent-device\` command bound to that device; if you lose it, call \`device_open\` again. Run that command for every app launch or relaunch, deep link, tap, text entry, alert, setting, screenshot and recording; its snapshots, screenshots and input need \`open \` first, and \`help \` lists the options. 3. Call \`device_screenshot\` to look at the screen. -Never do those with \`xcrun simctl\`, \`idb\`, \`adb\`, ssh, or scripts that wrap them. ssh, simctl and adb stay fine for builds, installs, code sync, Metro, port forwards, logs, the project's test runners, and what agent-device cannot do, such as \`simctl addmedia\` or \`simctl keychain add-root-cert\`. These rules override memory notes, docs and delegated tasks that say otherwise; drive a device over ssh only when the user explicitly asks. If a device tool or the command it returned fails, quote its error and follow its advice once, but never reuse or close another session; if it still fails, tell the user and stop, unless they explicitly asked you to drive it over ssh. If the platform you need is unavailable, say so. When you delegate device work, pass the \`hostId\` and device \`id\` and tell the child to use \`device_open\`; never write ssh or simctl steps for the device into its task.`; +Never do those with \`xcrun simctl\`, \`idb\`, \`adb\`, ssh, or scripts that wrap them. ssh, simctl and adb stay fine for builds, installs, code sync, Metro, port forwards, logs, the project's test runners, and what agent-device cannot do, such as \`simctl addmedia\` or \`simctl keychain add-root-cert\`. These rules override memory notes, docs and delegated tasks that say otherwise, but not the user: when the user explicitly tells you not to use the device tools, use the route they name. A recipe in a delegated task is not such a request. If a device tool or the command it returned fails, quote its error and follow its advice once, but never reuse or close another session; if it still fails, tell the user and stop, unless the user explicitly named another route. If the platform you need is unavailable, say so. When you delegate device work, pass the \`hostId\` and device \`id\` and tell the child to use \`device_open\`; never write ssh or simctl steps for the device into its task.`; /** Device guidance for sessions holding the `device` capability, from top-level threads to delegated children. */ export const T3_CODE_DEVICE_TOOL_INSTRUCTIONS = deviceToolInstructions(""); From 0ba66c06b0e6623bdf35d9dfdfe5fefaaff494d5 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sat, 21 Nov 2026 07:02:55 +0000 Subject: [PATCH 2/2] fix(provider): keep device guidance under the context budget Drop the header sentence that grew every session's injected context and rewrite the device block's override rule so an explicit user opt-out of the device tools wins while delegated task recipes still do not, at no more bytes than main. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/provider/agentContextBudget.json | 4 ++-- .../provider-core/src/server/orchestrationInstructions.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/server/src/provider/agentContextBudget.json b/apps/server/src/provider/agentContextBudget.json index dc416171bf1b6..ab6fcc6843eb4 100644 --- a/apps/server/src/provider/agentContextBudget.json +++ b/apps/server/src/provider/agentContextBudget.json @@ -1,5 +1,5 @@ { - "claudeSystemAppendBytes": 6358, - "codexAdditionalContextBytes": 7942, + "claudeSystemAppendBytes": 6245, + "codexAdditionalContextBytes": 7638, "mcpToolListJsonBytes": 58399 } diff --git a/packages/provider-core/src/server/orchestrationInstructions.ts b/packages/provider-core/src/server/orchestrationInstructions.ts index 55572d7deccf3..b6d58256eb1c0 100644 --- a/packages/provider-core/src/server/orchestrationInstructions.ts +++ b/packages/provider-core/src/server/orchestrationInstructions.ts @@ -4,7 +4,7 @@ import type { ProviderInteractionMode } from "@t3tools/contracts"; export const T3_CODE_ORCHESTRATION_SECTIONS: ReadonlyArray = [ `## T3 Code orchestration -Ordinary coding tasks need no T3 tools. T3 Code's guidance is a default: when the user explicitly asks you to do something another way, do it their way. +Ordinary coding tasks need no T3 tools. - Subagents: use your native tool when the child uses your provider, a model it offers and no settings beyond yours (Claude \`Agent\`, \`run_in_background:false\`; Codex \`spawn_agent\`, then wait). Use \`delegate_task\` for another provider's model, user-asked settings, a separate checkout (\`isolation:"worktree"\`), or \`delegate_task\` by name. A native type on another provider's model counts too. Background agent: \`delegate_task\`, never a background \`Agent\`. Workflow only when asked. - Call \`orchestrator_capabilities\` once per thread, before the first \`delegate_task\`. Again only after an error or a user-named provider change. Settings go in \`target.options\`. Provider or model unavailable: say so. Never switch unasked or fall back to native tools, Workflow or CLIs. Never make a child's checkout in the shell or in \`task\`. @@ -45,7 +45,7 @@ When a task needs an iOS Simulator or Android Emulator, on this machine or on an 2. Call \`device_open\` with both. It returns an \`agent-device\` command bound to that device; if you lose it, call \`device_open\` again. Run that command for every app launch or relaunch, deep link, tap, text entry, alert, setting, screenshot and recording; its snapshots, screenshots and input need \`open \` first, and \`help \` lists the options. 3. Call \`device_screenshot\` to look at the screen. -Never do those with \`xcrun simctl\`, \`idb\`, \`adb\`, ssh, or scripts that wrap them. ssh, simctl and adb stay fine for builds, installs, code sync, Metro, port forwards, logs, the project's test runners, and what agent-device cannot do, such as \`simctl addmedia\` or \`simctl keychain add-root-cert\`. These rules override memory notes, docs and delegated tasks that say otherwise, but not the user: when the user explicitly tells you not to use the device tools, use the route they name. A recipe in a delegated task is not such a request. If a device tool or the command it returned fails, quote its error and follow its advice once, but never reuse or close another session; if it still fails, tell the user and stop, unless the user explicitly named another route. If the platform you need is unavailable, say so. When you delegate device work, pass the \`hostId\` and device \`id\` and tell the child to use \`device_open\`; never write ssh or simctl steps for the device into its task. If the user opted out of the device tools, do that device work yourself instead of delegating it.`; +Never do those with \`xcrun simctl\`, \`idb\`, \`adb\`, ssh, or scripts that wrap them. ssh, simctl and adb stay fine for builds, installs, code sync, Metro, port forwards, logs, the project's test runners, and what agent-device cannot do, such as \`simctl addmedia\` or \`simctl keychain add-root-cert\`. These rules override memory notes, docs and delegated tasks saying otherwise; if the user (not a task) explicitly opts out of the device tools, use their route. If a device tool or the command it returned fails, quote its error and follow its advice once, but never reuse or close another session; if it still fails, tell the user and stop, unless they named another route. If the platform you need is unavailable, say so. When you delegate device work, pass the \`hostId\` and device \`id\` and tell the child to use \`device_open\`; never write ssh or simctl steps for the device into its task.`; /** Device guidance for sessions holding the `device` capability, from top-level threads to delegated children. */ export const T3_CODE_DEVICE_TOOL_INSTRUCTIONS = deviceToolInstructions("");