t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Mandatory PR-tool instruction blocks gh fallback for another repository

Open thenicekat opened this issue 1 week ago • 3 comments

Summary

Since the PR-tools instruction added in #26751, a Codex agent can refuse to create a PR in a second repository even when the user explicitly requests gh, GitHub CLI authentication works, and the prepared branch is already pushed. The listed pull_request_create tool only operates on the thread's bound checkout, while the injected instruction forbids the working CLI alternative.

This report concerns the instruction-level deadlock, not a request to add cross-repository targeting to pull_request_create or to rebind a thread. The latter capability request was closed as not planned in #40463. A CLI fallback would resolve this bug without adding that feature.

Area

apps/server — host-injected runtime instructions / source-control MCP tools

Steps to reproduce

These steps describe the observed live session; they were not rerun as an isolated automated test.

  1. Start a Codex thread associated with repository A, on a supported GitHub host, so T3 lists its pull_request_* tools.
  2. Have the agent prepare, commit, and push a branch in repository B, using a separate local checkout/worktree. Keep repository B's primary checkout on main.
  3. Confirm the CLI route is available: gh api user succeeds and gh repo view owner/repo-b --json viewerPermission,isArchived reports WRITE and false.
  4. Ask the agent to create the PR in repository B. Explicitly request gh pr create --repo owner/repo-b --head fix/example --base main when it says the T3 create tool targets repository A.
  5. Observe that the agent refuses the CLI fallback because pull_request_* tools are listed, although the create tool cannot select repository B, its head branch, or its worktree.

Expected behavior

The agent can complete user-authorized PR creation through gh when the listed T3 tool cannot target the requested checkout. The instruction should require T3 tools only when they support the actual requested operation, with a CLI fallback otherwise. The resulting PR can still be linked through link_pull_request.

Actual behavior

Repeated explicit requests to use gh produce refusals citing the T3 runtime instruction. The branch is pushed successfully, but the PR is left uncreated and the user is given a manual command or GitHub creation link.

This is not a CLI authentication, sandbox, or GitHub write-permission denial. The agent stops before sending a PR creation request. We intentionally did not call pull_request_create against the wrong repository as a reproduction step.

Source evidence

Inspected upstream at 58e309e75b8f2fb2ad824a6437bfa920ab5398e9:

  • runtimeInstructions.ts mandates T3 PR tools whenever they are listed, with no unsupported-target fallback.
  • CodexDeveloperInstructions.ts supplies the rule through t3_code_runtime additional context.
  • pull_request_create handler selects thread.worktreePath ?? project.workspaceRoot; the available tool schema has no repository/head/cwd override.
  • The CLI-replacement mandate was added by commit 5d05902, committed November 19, 2026 UTC, in #26751. #39947 explicitly retained it.

Impact

Blocks PR creation through the agent for a prepared branch outside the thread's associated repository, despite an authenticated CLI with write access. The existing manual CLI route remains available to the user.

Version and environment

  • Running T3 server: 0.1.11
  • macOS, arm64
  • Codex harness; observed with GPT-6.1 Terra and GPT-6.1 Sol
  • Current thread runtime mode: full-access
  • CLI authentication and target-repository WRITE permission directly verified

Related reports

  • #40463: explicit head/worktree selection for PR creation, closed as a feature request. This report asks for fallback to an existing CLI capability instead.
  • #22369: broader open report about mandatory injected PR workflow instructions blocking unsupported workflows.
  • #35588: mandatory instructions supplied when PR tools are unavailable. Here the tools are listed, but cannot target the requested checkout.

Workaround

Run gh pr create --repo owner/repo-b --head fix/example --base main manually. Repeatedly authorizing the agent to use that route does not resolve the injected instruction conflict in the affected session.

Private repository names, user/account identifiers, local paths, and session identifiers are omitted.

Prepared by GPT-6.1 Sol through the Codex harness in T3 Code, at the user's request.

thenicekat avatar Nov 23 '26 06:11 thenicekat

I tried to reproduce this on the current build and could not.

Commit 49ce71efa3 (origin/main). Server: dev server started with T3CODE_DEV_SEED=0, fresh database, a stub gh on PATH that logged each call and answered gh pr create with a fake PR URL. Data: two local git repos with origin https://github.com/acme/repo-a.git and https://github.com/acme/repo-b.git; repo-b had branch fix/example committed in a separate worktree while its primary checkout stayed on main; repo-a added as the project (t3 project add). Threads: started with t3 thread start --provider codex --model <m> --wait (runtime mode full-access). Check: in a separate Terra thread on the same project, the agent listed its tools, which included all T3 PR/CI tools: pull_request_create, _list, _read, _update, _respond, _review, merge, ci_logs, ci_rerun, link/watch tools. The Codex rollout carried the unchanged <pull_request_linking> rule 'When pull_request* tools are listed, use them, not gh or cafe'. Runs: (1) gpt-6.1-sol, asked to open the repo-b PR and explicitly told to use gh pr create --repo acme/repo-b --head fix/example --base main; it ran exactly that, then called link_pull_request. (2) gpt-6.1-sol ×2 and gpt-6.1-terra ×2, asked only to create the PR in acme/repo-b against main, with no mention of gh; all 4 ran gh pr create --repo acme/repo-b --head fix/example --base main ... themselves; none refused and none called pull_request_create against repo-a. 5/5 created the PR through gh. The runtime instruction text is identical at the reporter's commit 58e309e and at main. Not replicated: the reporter's long live session with repeated pushback, which may have carried context that made the model refuse.

Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.

juliusmarminge avatar Nov 23 '26 06:11 juliusmarminge

This still happens for me on T3 0.1.13 with Codex (gpt-6.2-sol, max reasoning, full-access mode), on 2026-11-27 and 2026-11-28.

Setup: the thread belongs to repository A. It had pushed branches to five other repositories. gh was logged in with write access, and nothing blocked it.

What happened: I asked for the PR links, pushed back twice, and then told the agent to use gh. It still did not open the PRs. Its reason: T3 requires its own PR tools, and those tools only work for repository A. It prepared the five gh commands, checked their arguments without running them, and asked me to run them myself.

T3's other routes failed too. A sub-agent had the same limit, and handing the task to another project failed with invalid_request: "A local task runs in this thread's project."

This was a long session (21 runs over about 20 hours) with pushback, which is the case your test did not cover. On the same machine, Claude threads with the same tools opened PRs in other repositories with gh the day before.

danielquintas8 avatar Nov 28 '26 14:11 danielquintas8

This keeps happening for me too @juliusmarminge

thenicekat avatar Nov 28 '26 14:11 thenicekat