Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(grid): route Pi through Auto instead of refusing it a model

bubu-dudua8cdff07a2a0
diff --git a/cli/src/lib/gridLaunch.spec.ts b/cli/src/lib/gridLaunch.spec.ts
index a0de88c37..00aed5bbf 100644
--- a/cli/src/lib/gridLaunch.spec.ts
+++ b/cli/src/lib/gridLaunch.spec.ts
@@ -182,8 +182,19 @@ describe('the launch each engine gets', () => {
expect(parsed).not.toHaveProperty('defaultProjectTrust')
})
- it('refuses Pi without a model — its provider block has to name one', () => {
- expect(buildGridEngineLaunch('pi', OVERRIDE)).toMatchObject({ ok: false, error: 'GRID_MODEL_REQUIRED' })
+ it('routes Pi through Auto when the user picked no model, rather than refusing', () => {
+ // Pi's provider block has to name a model, so "none" cannot be left blank — but the answer is
+ // the router's own id, the way OpenCode's block already does it, not a refusal. This was
+ // GRID_MODEL_REQUIRED, which made Pi the one grid-capable engine the New agent dialog could
+ // never start: that dialog always creates on Auto and offers no model field.
+ const launch = launchOf('pi', OVERRIDE)
+ expect(launch.args).toEqual(['--model', 'grid/Auto'])
+ const models = launch.configDir?.files.find((file) => file.name === 'models.json')
+ const parsed = JSON.parse(models!.content) as {
+ providers: Record<string, { models: { id: string; name: string }[] }>
+ }
+ // Named in the block too, not just in argv — Pi resolves `grid/Auto` against this list.
+ expect(parsed.providers.grid.models.map((m) => m.id)).toEqual(['Auto'])
})
it('never puts the key in argv, or on disk, for any engine', () => {
diff --git a/cli/src/lib/gridLaunch.ts b/cli/src/lib/gridLaunch.ts
index 6768f9e37..db4777e3c 100644
--- a/cli/src/lib/gridLaunch.ts
+++ b/cli/src/lib/gridLaunch.ts
@@ -622,21 +622,29 @@ const GRID_ENGINE_CONTRACTS: Partial<Record<AgentEngine, GridEngineContract>> =
// directory. So it gets a private one per agent: the provider block lands there, the user's
// ~/.pi/agent/models.json is never opened, and their skills are handed back through settings.json.
//
- // The model is not optional — the provider block has to name the model it serves, and Pi selects
- // it as `grid/<model>`.
+ // The provider block has to name the model it serves, and Pi selects it as `grid/<model>` — so
+ // something must always be named. No model chosen means the grid routes: `Auto` is the router's
+ // own id and the relay answers it like any other, exactly as OpenCode's block above relies on.
+ //
+ // This used to be `requiresModel: true`, which refused the launch outright. That made Pi the one
+ // grid-capable engine a person could not start from the New agent dialog at all, since the dialog
+ // always creates on Auto and no longer offers a model field — a dead end, not a prompt to go and
+ // pick something.
pi: {
- requiresModel: true,
- build: (override) => ({
- env: { [GRID_KEY_VAR]: override.apiKey },
- args: ['--model', `${GRID_PROVIDER_ID}/${override.model as string}`],
- configDir: {
- envVar: 'PI_CODING_AGENT_DIR',
- files: [
- { name: 'models.json', content: piModelsJson(relayBaseUrl(override.baseUrl), override.model as string) },
- { name: 'settings.json', content: piSettingsJson(userPiSkillsDir()) },
- ],
- },
- }),
+ build: (override) => {
+ const model = override.model ?? GRID_ROUTER_MODEL
+ return {
+ env: { [GRID_KEY_VAR]: override.apiKey },
+ args: ['--model', `${GRID_PROVIDER_ID}/${model}`],
+ configDir: {
+ envVar: 'PI_CODING_AGENT_DIR',
+ files: [
+ { name: 'models.json', content: piModelsJson(relayBaseUrl(override.baseUrl), model) },
+ { name: 'settings.json', content: piSettingsJson(userPiSkillsDir()) },
+ ],
+ },
+ }
+ },
},
// GitHub's documented BYOK path for Copilot CLI (docs.github.com … /use-byok-models). Copilot