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.

Harness Team account: a Codex start for a model its owner is not offered is refused before it launches

bitcoinbuilder0ff2ad834990
diff --git a/cli/src/superTabs/start.spec.ts b/cli/src/superTabs/start.spec.ts
index 6c7d4b4e1..aabd1d2e2 100644
--- a/cli/src/superTabs/start.spec.ts
+++ b/cli/src/superTabs/start.spec.ts
@@ -4,9 +4,9 @@ import { existsSync } from 'node:fs'
import { homedir } from 'node:os'
import { inspectCapacity, startAgent } from './start.js'
import { buildEngineCommandArgv } from '../lib/engineLaunch.js'
-const teamDaemon = vi.hoisted(() => ({ value: false, relayed: true }))
+const teamDaemon = vi.hoisted(() => ({ value: false, relayed: true, offered: null as null | { slugs: string[]; listed: string[] } }))
vi.mock('./teamDaemon.js', async (original) => ({ ...await original<object>(), isTeamDaemon: () => teamDaemon.value }))
-vi.mock('../team/relay.js', async (original) => ({ ...await original<object>(), teamRelayed: () => teamDaemon.relayed }))
+vi.mock('../team/relay.js', async (original) => ({ ...await original<object>(), teamRelayed: () => teamDaemon.relayed, offeredCodexModels: async () => teamDaemon.offered }))
const where = { port: 14001, machineId: 'lead-machine', dataDir: '/fixture' }
/** A queued start is watched before the Lead moves on (startAgent); these tests read the queued answer at once. */
const noPause = async () => {}
@@ -331,6 +331,37 @@ it('refuses a Codex Product Manager on a Team daemon with no owner relay before
} finally { teamDaemon.value = false; teamDaemon.relayed = true }
})
+// Mac Auto, 2026-10-29: a Codex start for gpt-6.1-sol, which its owner's ChatGPT account does not offer, launched and then
+// failed every request. In a Team account on the relay such a start is refused before anything launches, with what is offered.
+it('refuses a Codex start in a Team account for a model its owner is not offered, naming what is', async () => {
+ teamDaemon.value = true
+ teamDaemon.offered = { slugs: ['gpt-6-luna', 'gpt-reserve', 'gpt-5.6-terra'], listed: ['gpt-6-luna', 'gpt-5.6-terra'] }
+ try {
+ const f = fixture()
+ f.start.request = { ...f.start.request, engine: 'codex', model: 'gpt-6.1-sol', effort: 'medium' } as typeof f.start.request
+ const result = await startAgent({ action: 'start', tabId: 'tab', operationId: 'not-offered', request: f.start.request }, f.scoped, where, f.open)
+ const reason = 'This machine\'s ChatGPT account (its owner\'s subscription, used through the owner\'s relay) does not offer gpt-6.1-sol; it offers gpt-6-luna, gpt-5.6-terra.'
+ expect(result).toMatchObject({ error: 'START_FAILED', detail: reason })
+ expect(f.request.mock.calls.map(call => call[0])).not.toContain('agent_create')
+ expect(f.start.error).toBe(reason)
+ // An offered model, the default, a list that cannot be read, Claude Code and a Mac's own daemon all start as before.
+ const starts = async (request: Record<string, unknown>, offered: { slugs: string[]; listed: string[] } | null, team = true) => {
+ teamDaemon.offered = offered
+ teamDaemon.value = team
+ const g = fixture()
+ g.start.request = { ...g.start.request, ...request } as typeof g.start.request
+ await startAgent({ action: 'start', tabId: 'tab', operationId: `ok-${String(request.model)}`, request: g.start.request }, g.scoped, where, g.open)
+ return g.request.mock.calls.map(call => call[0]).includes('agent_create')
+ }
+ const list = { slugs: ['gpt-6-luna'], listed: ['gpt-6-luna'] }
+ expect(await starts({ engine: 'codex', model: 'gpt-6-luna', effort: 'medium' }, list)).toBe(true)
+ expect(await starts({ engine: 'codex', model: 'default', effort: 'default' }, list)).toBe(true)
+ expect(await starts({ engine: 'codex', model: 'gpt-6.1-sol', effort: 'medium' }, null)).toBe(true)
+ expect(await starts({ engine: 'claude', model: 'sonnet', effort: 'medium' }, list)).toBe(true)
+ expect(await starts({ engine: 'codex', model: 'gpt-6.1-sol', effort: 'medium' }, list, false)).toBe(true)
+ } finally { teamDaemon.value = false; teamDaemon.offered = null }
+})
+
describe('the skills of the project the agent joins', () => {
const projects = (skillMode?: string) => ({ conversations: [{ id: 'other', projectId: 'p1' }, { id: 'group', projectId: 'p2' }],
projects: [{ id: 'p1', skillMode: 'default' }, { id: 'p2', ...(skillMode ? { skillMode } : {}) }] })
diff --git a/cli/src/superTabs/start.ts b/cli/src/superTabs/start.ts
index f428d3b3b..23f780a81 100644
--- a/cli/src/superTabs/start.ts
+++ b/cli/src/superTabs/start.ts
@@ -10,7 +10,7 @@ import { permissionModeFlags } from '../lib/engineLaunch.js'
import type { AgentEngine } from '../engines/types.js'
import { isSwarmSkillMode, swarmSkillUse, type SwarmSkillMode } from '../lib/swarmSkills.js'
import { isTeamDaemon, pmEngineHome } from './teamDaemon.js'
-import { NO_PM_RELAY, teamRelayed } from '../team/relay.js'
+import { codexModelNotOffered, NO_PM_RELAY, offeredCodexModels, teamRelayed } from '../team/relay.js'
type Json = Record<string, unknown>
export type ScopedRequest = (payload: Json) => Promise<Json>
@@ -324,6 +324,18 @@ async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open:
requireSuccess(await scoped({ action: 'command', operationId: `refused-${startId}`, command: { type: 'agent.startFailed', startId, error: NO_PM_RELAY } }))
return { error: 'START_FAILED', startId, detail: NO_PM_RELAY }
}
+ // A Codex model the Mac owner's ChatGPT account does not offer launched and then failed every request (Mac Auto, whose
+ // owner is offered GPT-6-Luna and the GPT-5.6 models, was asked for gpt-6.1-sol, 2026-10-29). In a Team account on the
+ // relay the owner's list is read first, and such a start is refused before anything launches, naming what is offered.
+ // A list that cannot be read refuses nothing.
+ if (request.engine === 'codex' && model && model !== 'default' && request.gridModel === undefined && isTeamDaemon()) {
+ const offered = await offeredCodexModels().catch(() => null)
+ if (offered && !offered.slugs.includes(model)) {
+ const detail = codexModelNotOffered(model, offered)
+ requireSuccess(await scoped({ action: 'command', operationId: `refused-${startId}`, command: { type: 'agent.startFailed', startId, error: detail } }))
+ return { error: 'START_FAILED', startId, detail }
+ }
+ }
const resources = await inspectCapacity(target, request)
if (resources.capacity.error === 'GUEST_NOT_ALLOWED') return {
error: 'CONTRIBUTION_REQUIRED', startId,
diff --git a/cli/src/team/relay.spec.ts b/cli/src/team/relay.spec.ts
index 1194302ee..8ea4e3e57 100644
--- a/cli/src/team/relay.spec.ts
+++ b/cli/src/team/relay.spec.ts
@@ -1,6 +1,6 @@
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
-import { join } from 'node:path'
+import { dirname, join } from 'node:path'
import { afterEach, describe, expect, it, onTestFinished, vi } from 'vitest'
import { CODEX_RELAY_ACCOUNT, type SubscriptionRelay } from '../lib/subscriptionRelay.js'
import { engineAccount } from '../lib/engineAccount.js'
@@ -8,7 +8,7 @@ import type { TeamConfig } from './config.js'
import {
publishTeamRelay, publishWindowsTeamRelay, readTeamRelay, readWindowsTeamRelay, setfaclGrant, TEAM_RELAY_GUEST, teamRelayDir, teamRelayFile,
teamRelayLaunch, teamRelayPublished, NO_PM_RELAY, type OwnerRelayLaunch, TeamRelayPublisher, prepareCodexHome, installedCodexVersion,
- CODEX_CLIENT_VERSION_FALLBACK, dropUnofferedModel,
+ CODEX_CLIENT_VERSION_FALLBACK, dropUnofferedModel, offeredCodexModels, codexModelNotOffered,
type TeamRelayLaunchDeps, type TeamRelayPublisherDeps, type TeamRelayReadDeps, type WindowsRelayFs,
} from './relay.js'
@@ -376,3 +376,41 @@ describe('Codex\'s home for the relay', () => {
expect((await engineAccount('codex', { home: root, env: {}, lastUsed: false })).signedIn).toBe(false)
})
})
+
+// Mac Auto, 2026-10-29: its owner's ChatGPT account is offered GPT-6-Luna and the GPT-5.6 models, a start asked gpt-6.1-sol,
+// and the agent launched only to fail every request.
+describe('the Codex models a Team account\'s owner is offered', () => {
+ const grant = { url: 'http://127.0.0.1:9', token: TOKEN }
+ const rows = [{ slug: 'gpt-6-luna', visibility: 'list' }, { slug: 'gpt-reserve', visibility: 'hide' }, { slug: 'gpt-5.6-terra', visibility: 'list' }, 'not a model']
+ const deps = (over: Partial<Parameters<typeof offeredCodexModels>[0] & object> = {}) => ({
+ team: () => true, config: () => config, read: () => grant, prepare: vi.fn(async () => rows as unknown[]), ...over,
+ })
+
+ it('reads them fresh through the relay: every slug, and the ones Codex lists, in its order', async () => {
+ const d = deps()
+ expect(await offeredCodexModels(d)).toEqual({ slugs: ['gpt-6-luna', 'gpt-reserve', 'gpt-5.6-terra'], listed: ['gpt-6-luna', 'gpt-5.6-terra'] })
+ expect(d.prepare).toHaveBeenCalledWith(grant)
+ expect(codexModelNotOffered('gpt-6.1-sol', { slugs: [], listed: ['gpt-6-luna', 'gpt-5.6-terra'] }))
+ .toBe('This machine\'s ChatGPT account (its owner\'s subscription, used through the owner\'s relay) does not offer gpt-6.1-sol; it offers gpt-6-luna, gpt-5.6-terra.')
+ expect(codexModelNotOffered('gpt-6.1-sol', { slugs: ['x'], listed: [] })).toContain('it lists no model to choose.')
+ })
+
+ it('says nothing outside a Team account on its relay, or when the list cannot be read', async () => {
+ expect(await offeredCodexModels(deps({ team: () => false }))).toBeNull()
+ expect(await offeredCodexModels(deps({ config: () => null }))).toBeNull()
+ expect(await offeredCodexModels(deps({ read: () => null }))).toBeNull()
+ expect(await offeredCodexModels(deps({ prepare: async () => null }))).toBeNull()
+ expect(await offeredCodexModels(deps({ prepare: async () => { throw new Error('relay down') } }))).toBeNull()
+ expect(await offeredCodexModels(deps({ prepare: async () => ['not a model'] }))).toBeNull()
+ })
+
+ it('is what prepareCodexHome kept, or null when it kept none', async () => {
+ const dir = join(mkdtempSync(join(tmpdir(), 'team-offered-')), '.codex')
+ onTestFinished(() => rmSync(dirname(dir), { recursive: true, force: true }))
+ const models = [{ slug: 'gpt-6-luna', visibility: 'list' }]
+ const fetch = vi.fn(async () => new Response(JSON.stringify({ models }), { status: 200 }))
+ expect(await prepareCodexHome(dir, grant, { fetch: fetch as never, version: () => null, now: () => 0 })).toEqual(models)
+ expect(await prepareCodexHome(dir, grant, { fetch: (async () => new Response('{}', { status: 503 })) as never, version: () => null, now: () => 0 })).toBeNull()
+ expect(await prepareCodexHome(dir, grant, { fetch: (async () => { throw new Error('down') }) as never, version: () => null, now: () => 0 })).toBeNull()
+ })
+})
diff --git a/cli/src/team/relay.ts b/cli/src/team/relay.ts
index c7b71b008..c1fe65467 100644
--- a/cli/src/team/relay.ts
+++ b/cli/src/team/relay.ts
@@ -328,7 +328,7 @@ export interface TeamRelayLaunchDeps {
onboarded(engine: 'claude' | 'codex'): void
/** Codex's home made ready for the relay before each launch ([prepareCodexHome]): [home], the launch's own, when it has one.
* Never throws. */
- codexHome(grant: TeamRelayGrant, home?: string): Promise<void>
+ codexHome(grant: TeamRelayGrant, home?: string): Promise<unknown>
}
/** In the team daemon, for an engine it has not signed in itself: the owner's relay, when there is one. [codexHome]: the
@@ -374,8 +374,10 @@ export interface CodexHomeDeps {
* CLI 0.5.1 instead signed Codex in to ChatGPT through the relay, which `codex exec` takes but Codex's own screen does not:
* it checks the workspace with ChatGPT before it opens and exited ("account/read failed during TUI bootstrap"). Its
* sign-in is removed here, so a team account it reached starts Codex again.
+ *
+ * Returns the list it fetched and kept, null when it kept none.
*/
-export async function prepareCodexHome(dir: string, grant: TeamRelayGrant, deps: CodexHomeDeps): Promise<void> {
+export async function prepareCodexHome(dir: string, grant: TeamRelayGrant, deps: CodexHomeDeps): Promise<unknown[] | null> {
const auth = join(dir, 'auth.json')
try { if (isCodexRelayAuth(JSON.parse(readFileSync(auth, 'utf8')))) rmSync(auth, { force: true }) } catch { /* none, or the account's own */ }
const version = deps.version() ?? CODEX_CLIENT_VERSION_FALLBACK
@@ -383,17 +385,54 @@ export async function prepareCodexHome(dir: string, grant: TeamRelayGrant, deps:
const answer = await deps.fetch(`${grant.url.replace(/\/$/, '')}/codex/models?client_version=${encodeURIComponent(version)}`, {
headers: { authorization: `Bearer ${grant.token}`, accept: 'application/json' }, signal: AbortSignal.timeout(10_000),
})
- if (!answer.ok) return
+ if (!answer.ok) return null
const models = ((await answer.json()) as { models?: unknown }).models
- if (!Array.isArray(models) || !models.length) return
+ if (!Array.isArray(models) || !models.length) return null
mkdirSync(dir, { recursive: true, mode: 0o700 })
const file = join(dir, 'models_cache.json'), next = `${file}.harness-${process.pid}`
writeFileSync(next, JSON.stringify({ fetched_at: new Date(deps.now()).toISOString(), client_version: version, models }), { mode: 0o600 })
renameSync(next, file)
dropUnofferedModel(join(dir, 'config.toml'), new Set(models.flatMap(m => typeof (m as { slug?: unknown })?.slug === 'string' ? [(m as { slug: string }).slug] : [])))
+ return models
} catch { /* The relay or ChatGPT did not answer: Codex keeps the list it had. */ }
+ return null
+}
+
+/** The Codex models the owner's ChatGPT account offers: every slug, and those its /model picker lists, in its order. */
+export interface OfferedCodexModels { slugs: string[]; listed: string[] }
+
+export interface OfferedCodexModelsDeps {
+ team(): boolean
+ config(): TeamConfig | null
+ read(config: TeamConfig): TeamRelayGrant | null
+ /** [prepareCodexHome] for this account's Codex home: the list it fetched, or null. */
+ prepare(grant: TeamRelayGrant): Promise<unknown[] | null>
+}
+
+/**
+ * In a Harness Team account on its owner's relay: the Codex models the owner's ChatGPT account offers, read fresh through
+ * the relay (and kept for the launch that follows, [prepareCodexHome]). Null anywhere else, or when the list cannot be read.
+ * A start for a model the owner is not offered launched, then failed every request ("The 'gpt-6.1-sol' model is not
+ * supported when using Codex with a ChatGPT account": Mac Auto, whose owner is offered GPT-6-Luna and the GPT-5.6 models,
+ * 2026-10-29); with this, the start is refused before it launches, naming what the owner is offered.
+ */
+export async function offeredCodexModels(deps: OfferedCodexModelsDeps = realOfferedDeps): Promise<OfferedCodexModels | null> {
+ if (!deps.team()) return null
+ const config = deps.config()
+ const grant = config ? deps.read(config) : null
+ if (!grant) return null
+ const models = await deps.prepare(grant).catch(() => null)
+ if (!models) return null
+ const rows = models.flatMap(m => m && typeof m === 'object' && typeof (m as { slug?: unknown }).slug === 'string' ? [m as { slug: string; visibility?: unknown }] : [])
+ if (!rows.length) return null
+ return { slugs: rows.map(m => m.slug), listed: rows.filter(m => m.visibility === 'list').map(m => m.slug) }
}
+/** Why a start for [model] is refused: the owner's account does not offer it, and what it does offer. */
+export const codexModelNotOffered = (model: string, offered: OfferedCodexModels) =>
+ `This machine's ChatGPT account (its owner's subscription, used through the owner's relay) does not offer ${model}; `
+ + (offered.listed.length ? `it offers ${offered.listed.join(', ')}.` : 'it lists no model to choose.')
+
/**
* A default model saved in the team account's Codex config that the owner's account does not offer is taken out, so Codex
* starts on the owner's default. Codex saves the model a /model switch picks there, and a switch made while the account
@@ -428,6 +467,14 @@ export function installedCodexVersion(home: string): string | null {
} catch { return null }
}
+const realOfferedDeps: OfferedCodexModelsDeps = {
+ team: () => readAuthSession()?.kind === 'team',
+ config: () => readTeamConfig(),
+ read: (config) => readTeamRelay(config),
+ prepare: (grant) => prepareCodexHome(process.env.CODEX_HOME || join(homedir(), '.codex'), grant,
+ { fetch, version: () => installedCodexVersion(homedir()), now: Date.now }),
+}
+
/** The team daemon's own: its sign-in, the root-owned config, its engines' sign-ins in its own home. */
export const realTeamRelayLaunch = (engine: AgentEngine, codexHome?: string) => teamRelayLaunch(engine, {
team: () => readAuthSession()?.kind === 'team',