Skip to content

fix(pi): provider auth and model catalog read the agent dir sessions use - #290

Merged
xxchan merged 2 commits into
mainfrom
fix/pi-facades-agent-dir
Oct 9, 2026
Merged

xxchan merged 2 commits into
mainfrom
fix/pi-facades-agent-dir

Conversation

@xxchan

@xxchan xxchan commented Oct 9, 2026

Copy link
Copy Markdown
Member

Closes #289.

createPiProviderAuth and createPiModelCatalog passed authPath/modelsPath to pi's ModelRuntime only when the caller gave them. Otherwise pi fell back to its own agent dir (~/.pi/agent or PI_CODING_AGENT_DIR), even with OAR_PI_AGENT_DIR set. Every other pi entry point (open, listModels, inventory) honours OAR_PI_AGENT_DIR, so a login through the facade did not reach the next session, and status() described a different auth.json.

Change: both facades build their runtime through piFacadeRuntime (runtimes/pi/agent-dir.ts). It resolves OAR_PI_AGENT_DIR ?? getAgentDir() once, configures the proxy plane from that dir's settings as before, and defaults auth.json and models.json into it. Explicit paths still win, and modelsPath: null still disables the static config. pi treats an absent modelsPath as its own dir's, so null is passed through as is.

Tests: tests/providers/pi-agent-dir.test.ts pins PI_CODING_AGENT_DIR and OAR_PI_AGENT_DIR to two temp dirs:

  • Provider auth reads the agent dir's stored key, setApiKey writes there, and pi's own dir gets no auth.json.
  • The catalog lists the agent dir's models.json provider, and null disables it.
  • Explicit paths win.

The first two tests fail without the fix. The full suite, lint and typecheck pass locally.

Separate, not fixed here: the catalog's providers()[].configured reports a stored key as not configured whatever the path, because the runtime is created with refreshOnCreate: false and pi's availability snapshot stays empty. I'll file it as its own issue.

🤖 Generated with Claude Code

exe.dev user and others added 2 commits October 9, 2026 21:21
createPiProviderAuth and createPiModelCatalog passed authPath/modelsPath
to pi's ModelRuntime only when the caller gave them, so pi fell back to its
own agent dir even with OAR_PI_AGENT_DIR set: a login through the facade
did not reach the next session. Both now default auth.json and models.json
into OAR_PI_AGENT_DIR ?? getAgentDir(), the dir every other pi entry point
reads; explicit paths still win and modelsPath: null still disables.

Closes #289.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`OAR_PI_AGENT_DIR ?? getAgentDir()` kept an empty value, which joined
into relative paths: setApiKey wrote auth.json into the process's working
directory (Lookout, #290). Sessions, inventory and list-models always did
this; the facades now did too. All four share piAgentDir (resolve.ts),
which treats empty as unset, as pi treats an empty PI_CODING_AGENT_DIR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit 310b576 into main Oct 9, 2026
17 checks passed
@xxchan
xxchan deleted the fix/pi-facades-agent-dir branch October 9, 2026 21:44
@xxchan xxchan mentioned this pull request Oct 9, 2026
xxchan added a commit that referenced this pull request Oct 9, 2026
Release OAR and CLI 0.50.0. This PR changes only the two package version
fields.

**Breaking: a failed turn is a union tagged by `failure`** (#280)
- `TurnOutcome` `failed` is now `FailedTurn`, exported: `credential`
exists only on `failure: "auth"`, `resetsAt` only on `failure: "quota"`,
`status` on every class. A host that reads `outcome.credential` must
check `failure === "auth"` first, or it no longer compiles.

**Added**
- **`resetsAt` on a quota failure** (#280): when the limit that refused
the turn resets, where the runtime reports it. Only claude does: a
`rate_limit` failure while claude's latest `rate_limit_event` says a
subscription limit is `rejected`, overage does not take the requests,
and a reset is named. It is the runtime's last report; a time already
past means unknown. Codex's reset time exists only in its prose and is
not parsed.
- **Claude token totals include subagents and compaction** (#282, #292):
`usage().total` is claude's own running total (`result.modelUsage`),
which counts the main loop, Task subagents, sidechains and compaction.
Before, it was the main loop only (`result.usage`).
- **`SessionUsage.unattributed`**: what the total includes that no
`byAgent` entry accounts for (claude's subagents and compaction, which
its stream does not attribute per agent). `byAgent` plus `unattributed`
sums to `total`.
- **`SessionUsage.withChildren`**: the total plus the total of every
session derived from this one in `graph()` (codex child threads, grok
child sessions, OpenCode v2 children), each counted once.
- **Open errors keep their native cause** (#284): a failed codex, ACP or
claude open carries `cause: { method, native }` (redacted), so a host
can diagnose a failure even when no Session was returned.

**Fixed**
- **Known session credentials are redacted from every record and error**
(#286), not only from error text: session env and MCP env values chosen
by name, MCP credential headers, password-bearing connection URLs, and
pi's resolved model key. Original runtime input is unchanged. Limit: a
key the model repeats back across several streamed text deltas is not
caught, so SessionView text and coalesced events can still show it.
- **ACP error `data` is redacted** (#284); it used to bypass MCP
credential redaction.
- **Claude resume of a missing session fails at open** (#285, #287) with
claude's own text ("No conversation found with session ID: …") and
`cause: { method: "initialize", native }`, instead of returning a
Session that exits before its first prompt. A normal resume now waits
for claude's `initialize` answer (about 1 s observed).
- **Claude's `initialize` answer is no longer recorded** (#287): it
carries the account's email, organization and subscription. This
affected every open with `serviceTier` since that option shipped.
- **pi provider auth and model catalog use the agent dir sessions use**
(#289, #290): with `OAR_PI_AGENT_DIR` set, `createPiProviderAuth()` and
`createPiModelCatalog()` read and write that dir's `auth.json` and
`models.json` instead of pi's own. An empty `OAR_PI_AGENT_DIR` now
counts as unset everywhere, instead of becoming a relative path.

**Behavior changes**
- Narrow on `failure` before reading `credential` or `resetsAt` (see
above).
- Some claude rate-limit failures are now `quota` (with `resetsAt`)
instead of `rate_limited`; `failureAdvice` says `retry: "later"` for
them.
- Claude totals grow: they now include subagent and compaction tokens. A
resumed claude Session asks `get_usage` once at open for its baseline
(consumed privately, never recorded); if that answer does not come,
`usage().total` stays null for the Session rather than reporting the
lifetime figure.
- After a claude open with `serviceTier`, `serviceTier()` is null until
the first turn reports it; no `service_tier` event is emitted at open.
- Redaction now applies to every record, so a host comparing raw records
with what it sent may see `[redacted]` where a known credential
appeared.

**Known issues**
- `createPiModelCatalog().providers()[].configured` is false for a
stored credential until `refresh()` (#291). Use
`createPiProviderAuth().status(id)`.
- A Windows CI flake in the credential-redaction vendor test (#288);
tests only.

Validation: every PR passed all 17 checks on its final head. #284, #286,
#287, #280 and #290 merged with trees equal to their CI trees. #292 was
checked on its base, so its combination with #290 (disjoint files) was
verified locally (typecheck, lint, full tests: 1446 passed), and the
merged tree equals that verified tree. Lookout verified #286, #287, #290
and #292 against real binaries. After this PR passes CI and merges, tag
its exact squash commit as `v0.50.0` to trigger npm trusted publishing.

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

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
stamp-build Bot added a commit that referenced this pull request Nov 18, 2026
<!-- stamp:review:v1 -->
<sup><img
src="https://cdn.slock.ai/avatars/6aabf32c-20bc-4cba-b55a-2aa72b60999b/8ba4452ceb890f1930886ef4286fdb99.webp"
width="16" height="16" align="absmiddle" alt=""> <b>Otter</b> from
open-agent-runtime opened this pull request through
Stamp</sup><br><sup><a
href="https://stamp.build/review?receipt=prc_6eff601a7842aa4adb5af655485c0c89"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img
src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg"
width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp
→</a></sup>

---
<!-- /stamp:review:v1 -->

Opening Antigravity's skills panel currently runs authentication and
print-mode processes; the latter can start a configured global MCP
server. For CLI 1.5.10 and 1.5.11 on Linux and macOS, read native
metadata from files without starting a process, authentication or
network request. Windows and unverified versions retain the guarded
native query. The custom GEMINI_HOME refusal stays in place.

The file reader follows measured root precedence, manifest containment,
plugin metadata, copied-file deduplication and YAML invocation flags. It
returns no skill body and initializes no missing files. Every file
inventory is partial because the conditional native_swarm mount is
omitted until its selection rule is verified. A local skill named swarm
remains visible.

The repeatable comparison retains exact metadata, ordering and paths for
every other native entry. It covers six fixture stages, signed-out reads
and synthetic MCP startup on both verified versions. A separate frozen
1.5.11 CI installation preserves the existing 1.5.0 ACP baseline.
Windows instead asserts the native path through metadata, builtin
initialization and signed-out refusal.

Selected failure evidence explains the platform boundary: macOS path
resolution is fixed and its full comparison passes. Windows short-name
handling then passed the first five stages, but its junction-cwd stage
returned 14 native entries against 27 file-reader entries. That
discovery rule remains unresolved, so Windows is not admitted to the
file reader. The report retains the mismatch and requires a full native
comparison before enabling it.

Validation: both native versions passed the Linux six-stage comparison,
with 30 entries in the largest partial inventory; Linux and macOS CI
passed at the preceding head. The updated Linux 1.5.11 comparison and 44
focused unit controls pass. Full local check passed 4,917 tests and 19
mock cases. Platform CI verifies the Windows fallback. No model requests
or real-account probes were used.

Requested by xxchan, with scope and platform fallback approved by Cindy
in task #290.

---------

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

createPiProviderAuth ignores OAR_PI_AGENT_DIR for auth.json and models.json

1 participant