Repository navigation
feat(models): support Pi Coding Agent - #918
Merged
Merged
Conversation
Pi becomes the sixth agent `teamai models switch` can point at a team gateway. TeamAI writes one provider into `~/.pi/agent/models.json`, holding every catalog model; a member's other providers in that file are never touched. - **Key is the profile ref** (`team:<id>` / `local:<id>`), not the bare `id` — an `id` is unique only within one catalog file, so a root and a namespace profile may both be `tokenhub`, and a bare id would make the second switch silently overwrite the first gateway. Pi shows the profile's `name`. - **One provider covers all three protocols.** Pi resolves the api and URL per model: the first in Chat Completions, Responses, Anthropic order becomes the provider's own, and a model reached through another carries `api` and `baseUrl` itself. A model served both ways is registered once, preferring an OpenAI one; an `anthropic`-only group pins a Claude model to Anthropic Messages. - **An environment key is written as `$VAR`**, and `settings.json` is left alone, so the default model stays the member's choice. `PI_CODING_AGENT_DIR` is honored the way `CODEX_HOME` is. - **Restore** removes the key the last switch created, even after the catalog re-points the profile at a different ref. Restoring without `--agent` now covers Pi too. Rebased onto current `origin/main` (3a9a24a). The only conflict was the `./profile.js` import in `src/models/switch.ts`, where this change adds `ModelProtocol` and Tencent#894 adds `LocalConfig` / `sameTeamIdentity`; resolved as the union of both, and `git range-diff` confirms that line is the sole difference from the original commit. Verification on the rebased tree: `tsc --noEmit` and `lint` clean. Unit suite 5501 passed (the same three `push-env` cases fail on clean `origin/main`, verified in a separate worktree). Pi e2e suite 4 passed. Real built CLI against a scratch `HOME`: `models add` -> `models switch --agent pi` writes one provider keyed `local:tokenhub` with `settings.json` untouched; `models list` reports Pi active; `models restore --agent pi` returns the file to `{}`; a pre-existing user provider under the same ref is refused with `pi already has a user-owned provider named local:tokenhub` and left byte for byte intact; `PI_CODING_AGENT_DIR` redirects the write to a custom directory.
|
Findings
The PR description’s testing record is sufficient, including representative built-CLI and real-Pi verification. |
daoiqi
force-pushed
the
worktree-pi-model-distribution
branch
from
September 30, 2026 02:42
eca96df to
6ee0efb
Compare
|
Findings
The PR description includes sufficient representative real-CLI and real-Pi verification. |
jeff-r2026
approved these changes
Sep 30, 2026
6 of 10 tasks
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
Pi becomes the sixth agent `teamai models switch` can point at a team gateway. TeamAI writes one provider into `~/.pi/agent/models.json`, holding every catalog model; a member's other providers in that file are never touched. - **Key is the profile ref** (`team:<id>` / `local:<id>`), not the bare `id` — an `id` is unique only within one catalog file, so a root and a namespace profile may both be `tokenhub`, and a bare id would make the second switch silently overwrite the first gateway. Pi shows the profile's `name`. - **One provider covers all three protocols.** Pi resolves the api and URL per model: the first in Chat Completions, Responses, Anthropic order becomes the provider's own, and a model reached through another carries `api` and `baseUrl` itself. A model served both ways is registered once, preferring an OpenAI one; an `anthropic`-only group pins a Claude model to Anthropic Messages. - **An environment key is written as `$VAR`**, and `settings.json` is left alone, so the default model stays the member's choice. `PI_CODING_AGENT_DIR` is honored the way `CODEX_HOME` is. - **Restore** removes the key the last switch created, even after the catalog re-points the profile at a different ref. Restoring without `--agent` now covers Pi too. Rebased onto current `origin/main` (3a9a24a). The only conflict was the `./profile.js` import in `src/models/switch.ts`, where this change adds `ModelProtocol` and Tencent#894 adds `LocalConfig` / `sameTeamIdentity`; resolved as the union of both, and `git range-diff` confirms that line is the sole difference from the original commit. Verification on the rebased tree: `tsc --noEmit` and `lint` clean. Unit suite 5501 passed (the same three `push-env` cases fail on clean `origin/main`, verified in a separate worktree). Pi e2e suite 4 passed. Real built CLI against a scratch `HOME`: `models add` -> `models switch --agent pi` writes one provider keyed `local:tokenhub` with `settings.json` untouched; `models list` reports Pi active; `models restore --agent pi` returns the file to `{}`; a pre-existing user provider under the same ref is refused with `pi already has a user-owned provider named local:tokenhub` and left byte for byte intact; `PI_CODING_AGENT_DIR` redirects the write to a custom directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pi becomes the sixth agent
teamai models switchcan point at a team gateway. TeamAI writes one provider into~/.pi/agent/models.json, holding every catalog model; a member's other providers in that file are never touched.team:<id>/local:<id>), not the bareid— anidis unique only within one catalog file, so a root and a namespace profile may both betokenhub, and a bare id would make the second switch silently overwrite the first gateway. Pi shows the profile'sname.apiandbaseUrlitself. A model served both ways is registered once, preferring an OpenAI one; ananthropic-only group pins a Claude model to Anthropic Messages.$VAR, andsettings.jsonis left alone, so the default model stays the member's choice.PI_CODING_AGENT_DIRis honored the wayCODEX_HOMEis.--agentnow covers Pi too.Verification:
tsc --noEmitandlintclean; full suite 5379 passed (three pre-existing flakypush-envcases fail identically on the base); full e2e 384 passed, with 4 new cases driving the built CLI against a scratch HOME; realpi0.87.1 lists all three models underlocal:tokenhubwith the member's own provider untouched andrestorereturning the file exactly.Summary
Type of Change
Test Plan
npx tsc --noEmitpassesnpm run lintpassesnpx vitest runpassesRelated Issues
Notes for Reviewers