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): opencode's router is "no model", not a model called Auto

bubu-dudubd0f702e30cf
diff --git a/cli/src/lib/gridAssignment.spec.ts b/cli/src/lib/gridAssignment.spec.ts
index 26b380003..fa63d1e3a 100644
--- a/cli/src/lib/gridAssignment.spec.ts
+++ b/cli/src/lib/gridAssignment.spec.ts
@@ -214,6 +214,16 @@ describe('readOpencodeGridAssignment', () => {
expect(JSON.stringify(assignment)).not.toContain('gridkey-secret')
})
+ it('reports the router as NO model, the way every other engine does', async () => {
+ // OpenCode is the only engine whose provider block must name something, so a launch with no
+ // model picked writes the relay's router id there. Letting that id back out would be the app's
+ // own "Auto" under a second name: the header would print the raw id, and `assignmentMatches`
+ // would compare it against null and call every such agent mis-targeted forever.
+ const path = write(config(RELAY, ['Auto']))
+ await expect(readOpencodeGridAssignment({ OPENCODE_CONFIG: path }))
+ .resolves.toEqual({ baseUrl: RELAY, model: null })
+ })
+
it('answers the same whatever the engine has done to its command line', async () => {
// The flicker: argv is a live process's to rewrite, so nothing here may depend on it.
const path = write(config(RELAY))
diff --git a/cli/src/lib/gridAssignment.ts b/cli/src/lib/gridAssignment.ts
index 9bd63d78f..23dc9dece 100644
--- a/cli/src/lib/gridAssignment.ts
+++ b/cli/src/lib/gridAssignment.ts
@@ -21,6 +21,7 @@
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
import type { AgentEngine } from '../engines/types.js'
+import { GRID_ROUTER_MODEL } from './gridLaunch.js'
import { readProcessEnv } from './processEnv.js'
import type { ProcessIdentity } from './registry.js'
@@ -171,7 +172,17 @@ export async function readOpencodeGridAssignment(
if (typeof baseUrl !== 'string' || !isGridUrl(baseUrl)) return null
const models = Object.keys(providers[0].models ?? {})
if (models.length !== 1) return null
- return { baseUrl, model: models[0] }
+ // The router reports as NO model, the same as every other engine launched without one.
+ //
+ // OpenCode is the only engine whose provider block has to name something, so a launch with no
+ // model picked writes the relay's router id there. That is an OpenCode implementation detail and
+ // must not leak: the app's own "Auto" is `model: null`, and a raw `Auto` coming back would be the
+ // same state under a different name — the header would print the id instead of "Auto", and
+ // `assignmentMatches` would compare 'Auto' against null and report every such agent as being on
+ // the wrong target, forever. See the desktop's `kAutoModelId`, and the commit that stopped the
+ // model menu offering the router beside its own Auto row.
+ const model = models[0]
+ return { baseUrl, model: model.toLowerCase() === GRID_ROUTER_MODEL.toLowerCase() ? null : model }
} catch {
return null
}
diff --git a/cli/src/lib/gridLaunch.ts b/cli/src/lib/gridLaunch.ts
index 30a3b1605..e825762a4 100644
--- a/cli/src/lib/gridLaunch.ts
+++ b/cli/src/lib/gridLaunch.ts
@@ -156,7 +156,7 @@ export function anthropicBaseUrl(baseUrl: string): string {
* the relay's `/models`, and the relay answers it like any other id — which is what lets a provider
* block that must name SOMETHING name this.
*/
-const GRID_ROUTER_MODEL = 'Auto'
+export const GRID_ROUTER_MODEL = 'Auto'
/** The file OpenCode's `OPENCODE_CONFIG` is pointed at. */
const OPENCODE_CONFIG_FILE = 'opencode.json'