Skip to content

fix(dev): pnpm dev trial agents sign in through a model provider, as eval's do - #1413

Merged
allisonmahmood merged 1 commit into
mainfrom
t3/trial-provider-environment
Nov 12, 2026
Merged

allisonmahmood merged 1 commit into
mainfrom
t3/trial-provider-environment

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

What changed

pnpm dev trial started its agents with the runner's closed environment plus three sign-in variables, and the agent launcher loads no user settings. So on a machine that reaches Claude through a model provider (ANTHROPIC_BASE_URL with ANTHROPIC_AUTH_TOKEN or ANTHROPIC_CUSTOM_HEADERS, set in the environment or in Claude Code's settings.json), a trial's agents couldn't sign in. pnpm dev eval already handled this case.

Now a trial's agents get the provider the same way eval's builders do, through one shared module.

Closes #1300

Look at

  • One resolution, two users. scripts/dev/src/claudeSignIn.ts holds what eval/home.ts had inline. readClaudeVariables reads each variable from the environment, then dev.env, then the env of Claude Code's settings.json. providerEnv passes the provider only when ANTHROPIC_BASE_URL names one, and eval's claudeEnv is built on it. Eval's sandbox setup stays where it was.
  • Trial keeps its own sign-in. agentEnv in trial.ts adds only the provider to the side's closed environment. Its tokens still come from the environment (CLAUDE_CONFIG_DIR, ANTHROPIC_API_KEY, CLAUDE_CODE_OAUTH_TOKEN, each passed when set), next to the login in HOME, so Claude Code's own precedence still decides between them. Eval still picks one token.
  • The sanitizer redacts header values. A header's name, such as X-Api-Key, doesn't mark it as secret. So the sanitizer now treats a *_HEADERS variable as headers, whether or not its name is also secret-named (secretsInEnv). It collects the whole value and each line's value, everything after the line's first colon. One header a line is how Claude Code reads ANTHROPIC_CUSTOM_HEADERS, so a value with commas or colons in it is redacted whole rather than guessed apart. Trial's sanitizer reads each agent's environment, so this covers its progress lines, its section and --json. Eval's readSignIns now calls the same function instead of its own copy.
  • The sanitizer redacts the model provider's address. A section is public, and ANTHROPIC_BASE_URL names the developer's own host. It's redacted whole, along with any credentials in its userinfo. Its host is redacted too, with and without its port, both as written and as URL lowercases it, because an error can name the host alone. A loopback host (localhost, 127.x, [::1], a trailing dot included) is left alone. So is a bare name with no dot, like gpubox, unless it comes with its port: on its own it could match inside ordinary words. Eval gets the same, and its section's redaction line now names header values and the provider's address too.

The new test in trial.test.ts writes a dummy provider into a temporary HOME's .claude/settings.json, then checks the agent's environment and the redaction. Removing either half of the fix makes it fail:

# agentEnv without the provider
AssertionError: expected { PATH: '/usr/bin:/bin', …(4) } to deeply equal { PATH: '/usr/bin:/bin', …(6) }

# sanitizer without the headers rule
Expected: "sent [redacted]; 401 for [redacted]"
Received: "sent X-Api-Key: dummy-header-key; 401 for dummy-header-key"

Two cases in sanitize.test.ts pin the header rule. The first is a secret-named COOKIE_HEADERS with a header on each line and a colon in one value, which fails if the secret name takes precedence:

Expected: "sent [redacted], then [redacted]"
Received: "sent dummy-alpha, then dummy:beta"

The second checks that a comma-joined line's whole value is redacted, and that http://localhost:4000 survives a header like X-Forwarded-For: 192.0.2.1, ::. That second part fails against the comma splitting this PR tried and dropped:

Expected: "401 for [redacted] at http://localhost:4000"
Received: "401 for [redacted] at http[redacted]//localhost[redacted]4000"

A third pins the provider's address:

  • a remote one, its password and its host in any spelling are redacted;
  • a loopback one is redacted only whole, so 127.0.0.1:4000 and other local URLs survive;
  • h doesn't garble handler;
  • gpubox:8317 is redacted, while gpubox alone isn't.

It fails without the rule.

How it was verified

  • vitest run scripts/dev: 20 files, 193 tests pass. That includes eval's provider tests, unchanged except for where claudeEnv is imported from. One assertion also expects the provider's address and host among eval's collected secrets.
  • pnpm lint, pnpm typecheck (25 tasks, tests included) and bun fmt --check pass.
  • No live trial against a real provider. As the issue asks, the test with dummy values is the proof. It sets its own config and HOME, so it never reads this machine's Claude settings.

Surfaces: the dev loop applied. docs/DEVELOPMENT.md's trial paragraph now says where the provider comes from, and its sanitizer paragraph says how a headers variable is redacted (whole, and one Name: value a line, as Claude Code reads them) and how the provider's address is. The patchy-dev-loop skill doesn't describe trial's sign-in, so it needed no change, and the seed and Postgres template are untouched. The wire contract, CLI, vocabulary and migrations don't apply.

Release impact

Tick exactly one.

  • Breaking — requires action from anyone already running this

  • Not breaking — no action required: dev runner only, nothing in the CLI, server or schema

  • What does a revert leave behind? Nothing. Trial goes back to not passing the provider.

  • Does the release before it still work with that? Yes.


Built by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, through T3 Code.

@github-actions github-actions Bot added area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area size:m 100-500 changed lines labels Nov 12, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review (GPT 6.1 Sol), two rounds.

Round 1, at 3903325.

  • Eval's resolution is preserved: the old and new functions give identical environments and secret sets across 243 dummy combinations.
  • Trial's environment stays closed.
  • Passing both tokens matches Claude Code's documented precedence.

Two sanitizer findings:

  1. Several headers joined by commas on one line weren't redacted one by one.
  2. A *_HEADERS variable with a secret-sounding name skipped header extraction.

Round 2, at c55723b. Splitting on commas fixed finding 1, but caused two problems of its own:

  • A value that contains a comma leaked its tail.
  • A value such as :: turned : into a secret, and garbled unrelated output (http://localhost:4000).

Resolution.

  • Finding 1 is dismissed, and the comma splitting comes out. Claude Code takes one Name: Value per line in ANTHROPIC_CUSTOM_HEADERS. A comma-joined line is one header whose value is everything after the first colon, and that whole value is already redacted. Splitting on commas guesses at a structure Claude Code doesn't have, and the guess both leaks and corrupts.
  • Finding 2's fix stays. Header extraction applies whatever else the variable's name says.

The next push carries this, with tests for a comma-joined line and for output the sanitizer must leave alone.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review (GPT 6.1 Sol), rounds 3 and 4: the provider's address.

The earlier acceptance verdict noted that ANTHROPIC_BASE_URL wasn't redacted, so a private host could reach a public section. 6412a51 added it.

Round 3 found four gaps in that commit, and 8d1157e fixes them:

  • a password in the URL's userinfo came through;
  • a host spelled differently from URL's lowercased form came through;
  • a one-letter host like h garbled ordinary words;
  • localhost. missed the loopback exception.

Round 4, at 8d1157e: nothing blocking. All four were rerun and are fixed. Sol also checked default ports, bracketed IPv6, loopback spellings, encoded forms, and that ordinary output survives.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked 0200529 (base b9dc456) on team, by Claude Opus 5.5 in Claude Code. This replaces the verdict at 8d1157e. 0200529 changes only providerSecrets in sanitize.ts, one test case and the matching DEVELOPMENT.md sentence. It fixes that verdict's main note: gpubox:8317 came through unredacted.

Done means

  • A bare provider host is redacted with its port, and not on its own: passed. I ran the same trial at both commits, with a dummy provider that won't resolve here (getent hosts gpubox1413 exits 2). The task names the host with its port and alone, so the runner's redaction of that text shows up in the key, the section and --json:

    $ env -u PATCHY_API_URL -u PATCHY_API_TOKEN PATH="<node 26.13>/bin:$PATH" \
        ANTHROPIC_BASE_URL='http://gpubox1413:18415' ANTHROPIC_AUTH_TOKEN=dummy-auth-token-1413 \
        pnpm dev trial "Ask the model provider at gpubox1413:18415 for a reply, and say whether gpubox1413 answered." \
        --scenario team --max-turns 1 --minutes 4 --json
    • At 0200529:

      key   ask-the-model-provider-at-redacted
      task  Ask the model provider at [redacted] for a reply, and say whether gpubox1413 answered.
      | Finished | No: API Error: Can't reach the API server — check your internet or DNS (EAI_AGAIN) | No: API Error: … (EAI_AGAIN) |
      The agent on this branch never really tried the task (API Error: Can't reach the API server — check your internet or DNS (EAI_AGAIN)), so nothing was published; the section is above.
      
    • At 8d1157e (--minutes 1, since only the task text shows the leak; see the notes):

      key   ask-the-model-provider-at-gpubox1413-18415
      task  Ask the model provider at gpubox1413:18415 for a reply, and say whether gpubox1413 answered.
      
    • Raw values, counted:

      gpubox1413:18415 18415 token bare gpubox1413
      0200529: progress lines 0 0 0 0
      0200529: --json 0 0 0 2
      0200529: section 0 0 0 1
      8d1157e: progress lines 0 0 0 0
      8d1157e: --json 2 7 0 —
      8d1157e: section 1 4 0 —

      The bare name survives at the head, as the PR says it should. At 8d1157e, it isn't counted on its own, because it also appears inside every leaked gpubox1413:18415. Both runs' progress lines exclude pnpm's own echo of the command, which prints the task as typed before the runner starts.

    • The rest stays readable. The connection error, the table, and the redaction line ("secret-named variables, header values and the model provider's address the runner passed") come through intact.

  • Other spellings, calling makeSanitizer directly: passed. I wrote a scratch script that calls each commit's makeSanitizer with envs: [{ ANTHROPIC_BASE_URL: <address> }]:

    address                               text → 0200529
    http://gpubox1413:18415               url [redacted] | hp [redacted] | host gpubox1413 | port 18415
    http://GPUBox1413:18415               written [redacted] | lower [redacted] | bare GPUBox1413
    http://gpubox1413:80                  url [redacted] | hp [redacted] | host gpubox1413
    http://u:dummy-pass-1413@gpubox1413:18415   via [redacted] | hp [redacted] | pass [redacted]
    https://h:8317                        the handler at [redacted] said hi, h is fine
    http://localhost:18415                local localhost:18415 | url [redacted]
    
    address                               text → 8d1157e
    http://gpubox1413:18415               url [redacted] | hp gpubox1413:18415 | host gpubox1413 | port 18415
    

    The default-port case holds because the host as written (gpubox1413:80) is kept even though URL drops :80.

  • The suite: passed.

    $ pnpm exec vitest run scripts/dev
     Test Files  20 passed (20)
          Tests  193 passed (193)

    CI on 0200529: 23 checks passed and 3 skipped (imap-live, attio-live, pidgeon-suite), none pending. That includes lint, all four test jobs, browser, cli-smoke and rollback-rehearsal.

The earlier non-loopback and loopback runs: not rerun, since this diff can't change them. The diff touches one case only: a non-loopback host with no dot or bracket. Before, it got no host spellings. Now it gets the ones containing a colon.

  • A loopback host still gets none (local ? []).
  • A dotted or bracketed host still gets all four spellings.
  • The address, userinfo and password lines are unchanged.

The earlier runs used Stub-1413.localhost, which is dotted and non-loopback, and 127.0.0.1, which is loopback. Both take unchanged branches, and their unit cases in sanitize.test.ts still pass at the head. The sign-in code (trial.ts, claudeSignIn.ts, eval/home.ts) is unchanged since fad1bd8 as well. Both agents in the run above did try the dummy provider and failed with EAI_AGAIN.

Golden journeys

  • None touched. The diff is the dev runner's sanitizer and DEVELOPMENT.md.

Rollback answers: they match the diff. A revert leaves nothing behind: no migrations, packages/api, CLI or infra. rollback-rehearsal passes on the head, and no one-way label is needed.

Not run

  • The agent printing the host itself. The brief's dummy host doesn't resolve, so the agent never reached a model and printed nothing beyond Claude Code's error. That error doesn't name the host. The host:port redaction was checked on text the runner writes (the task, the key) and by calling the sanitizer directly. Agent-printed output goes through the same redact, and the earlier verdict's runs A and A2 checked it with a dotted host.

Notes

  • The connection error needs a longer budget. Claude Code retries an unreachable provider about ten times, which took about three minutes here. A --minutes 1 run at the head timed out before the error, with nothing to redact. I reran it with --minutes 4 to capture the error.
  • pnpm dev up fails installing the environment's CLI: pinned npm 12 refuses the local tarball (EALLOWREMOTE) #1240 is still open, so I used the earlier verdict's workaround from the start: Node 26.13, with its bundled npm 11, first on PATH for every run. I didn't retest the refusal.
  • The first head run failed to come up. The after instance's server got "Is port 33584 in use?" on this shared machine. The port was free a moment later, and an identical retry came up. It's not the change's.
  • The earlier verdict's note about the username still stands. A username in the URL on its own isn't redacted. This delta doesn't touch it. Its note about the PR body is resolved: the body now describes the dotless rule and 193 tests.

@allisonmahmood
allisonmahmood force-pushed the t3/trial-provider-environment branch from 0200529 to bb9ae7f Compare November 12, 2026 18:16
@allisonmahmood
allisonmahmood merged commit 1f67b0d into main Nov 12, 2026
26 checks passed
@allisonmahmood
allisonmahmood deleted the t3/trial-provider-environment branch November 12, 2026 19:14
allisonmahmood added a commit that referenced this pull request Nov 12, 2026
…ey shortcuts (#1421)

## What changed

This adds release 42's What's new entry, written from `1cd6d12`. It
covers everything merged since release 41's `through` (`a25a9c5`), and
sets the `patchy` release to `0.42.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`.

| Change | PRs |
| --- | --- |
| New: Tell Patchy what it's missing | #1217, #1218, #1219, #1227, #1228
|
| New: Turn off single-key shortcuts | #1276, #1279, #1301 |
| Fixed: Typing reaches the patch again | #1407, #1412 |
| Fixed: Dialogs in patches keep your place | #1420, #1255 |
| Behind the scenes: plainer facts for agents building patches | #1249,
#1256, #1297, #1418 |
| Behind the scenes: Patchy stores teams and audiences ahead of teams |
#1416 |
| Patch changes: Mod+/ and `client.close()` in patchy/hotkeys;
single-key shortcuts can be off; Tab wraps in plain modal dialogs |
#1279, #1301, #1420 |

#1376 is release 41's own entry. #1400, #1406, #1414, #1415, #1302,
#1413 and #1419 are test, CI and dev tooling and need no line.

The teams bridge (#1416) ships alone in this release so teams (#1417)
can follow in the next one with a release to roll back to that reads its
data closed.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`.
- **Rollback safety, from the live commit `7f93b91` (release 41) to this
PR's merge.** No PR in the range is labelled `one-way`, and every
Release impact answer says release 41 still works:
- **#1217** adds migration `0037_feedback`, a schema release 41 never
reads. **#1227** and **#1228** write into it.
- **#1276** adds migration `0038_single_key_shortcuts`, a column with a
default that release 41 never selects.
- **#1416** adds migrations `0039_company_teams` to
`0041_connection_audiences`, which hold tables that stay empty until
teams ship, and widens one scope check. Its CI rehearsal ran `7f93b91 →
head → 7f93b91 → head` on one set of data, and all four steps passed.
- **#1279**, **#1301**, **#1255** and **#1420** change the SDK and the
shell. Patches built on this release carry a `shortcutSetting` manifest
field that release 41 reads without refusing, and its shell names no
frame, so every shortcut stays on.
- **#1218** and **#1219** add CLI commands and an optional
`feedbackHint` in `--json` failures. A CLI from this release refuses to
publish to an older instance before sending anything, as any mismatched
release does.
  - Everything else is skill text, docs, tests and CI.

If this release misbehaves, roll back to `7f93b91` (release 41).

Written by Claude Opus 5.5 in Claude Code, through T3 Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area size:m 100-500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(dev): pnpm dev trial agents can't sign in through a model provider

1 participant