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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
cli: stop agents without a session yet sharing one runtime state
bitcoinbuilder4fc83a5bbe25
diff --git a/cli/src/cli.ts b/cli/src/cli.tsindex 9b45df0e0..bf9f849ef 100644--- a/cli/src/cli.ts+++ b/cli/src/cli.ts@@ -3867,7 +3867,14 @@ async function runForeground(session: AuthSession): Promise<void> {// the model. For claude the decoded value is already the vendor's alias (`opus`), which is what// ANTHROPIC_MODEL wants. Null when the daemon has not observed this pane's model yet, which is a// real answer: there is then nothing to come back to and the engine decides, as it did before.- const observed = parseRuntimeProfile(runtimeProfiles.selectedModel(session))?.model ?? null+ // ⚠️ The profile's OWN engine has to match, not just the session it was read under. A model is+ // only meaningful to the engine that named it — `opencode/big-pickle` handed back as+ // ANTHROPIC_MODEL is not a Claude model, and Claude Code says so ("It may not exist or you may+ // not have access to it") on a pane the user never chose it for. The keying bug that let one+ // agent read another's model is fixed at its source in RuntimeProfileManager; this is the second+ // lock, because the cost of being wrong here is a pane that answers on nothing.+ const profile = parseRuntimeProfile(runtimeProfiles.selectedModel(session))+ const observed = profile && profile.engine === session.engine ? profile.model : nullconst remembered = grid// Two guards, and both come from watching this go wrong://diff --git a/cli/src/lib/runtimeProfile.spec.ts b/cli/src/lib/runtimeProfile.spec.tsindex db1f60d2e..9e524c40b 100644--- a/cli/src/lib/runtimeProfile.spec.ts+++ b/cli/src/lib/runtimeProfile.spec.ts@@ -31,6 +31,30 @@ function session(engine: RegisteredSession['engine']): RegisteredSession {}describe('RuntimeProfileManager', () => {+ it('keeps agents that have not bound a session yet out of one another state', () => {+ // An agent awaiting its first bind carries `sessionId: ''`, which is not an identity: keyed on it,+ // EVERY unbound agent shared one entry, across engines. Measured — a claude agent ten seconds old+ // was retargeted onto a grid, the "what model was it on?" read answered `opencode/big-pickle`+ // (an OpenCode agent had sat at `''` first), and the pane came home with+ // `ANTHROPIC_MODEL=opencode/big-pickle`. Claude Code: "There's an issue with the selected model".+ const manager = new RuntimeProfileManager()+ const unboundOpencode = { ...session('opencode'), sessionId: '' }+ const unboundClaude = { ...session('claude'), sessionId: '' }++ manager.ingestPane(unboundOpencode, ' ┃ Build · Big Pickle OpenCode Zen', true)++ // Not "the other agent's model" and not the first agent's own either: with no session there is+ // nowhere to keep one, which is the truth about an engine that has not started talking yet.+ expect(manager.selectedModel(unboundClaude)).toBeNull()+ expect(manager.selectedModel(unboundOpencode)).toBeNull()+ // A bound agent is unaffected — the fix removes a shared bucket, not the feature.+ const bound = session('codex')+ manager.ingestPane(bound, 'gpt-5.6-terra high ·', true)+ expect(parseRuntimeProfile(manager.selectedModel(bound))).toMatchObject({+ engine: 'codex', model: 'gpt-5.6-terra', effort: 'high',+ })+ })+it('limits Codex Max and Ultra to GPT-5.6 models', () => {expect(codexEffortAllowed('gpt-5.6-sol', 'max')).toBe(true)expect(codexEffortAllowed('gpt-5.6-terra', 'ultra')).toBe(true)diff --git a/cli/src/lib/runtimeProfile.ts b/cli/src/lib/runtimeProfile.tsindex a69f50ac6..e3e64123f 100644--- a/cli/src/lib/runtimeProfile.ts+++ b/cli/src/lib/runtimeProfile.ts@@ -624,6 +624,7 @@ export class RuntimeProfileManager {onChanged: ((sessionId: string) => void) | null = nullhydrate(session: RegisteredSession, rawLines: string[]): void {+ if (this.unbound(session.sessionId)) returnthis.states.set(session.sessionId, {// Registries written by older builds can hold a non-string model; treat it as unknown instead of// letting it reach claudeAliasForModel and abort startup.@@ -926,6 +927,7 @@ export class RuntimeProfileManager {}selectedModel(session: RegisteredSession): string | null {+ if (this.unbound(session.sessionId)) return nullconst state = this.states.get(session.sessionId)if (!state?.model) return nullconst model = session.engine === 'claude' ? claudeAliasForModel(state.model) ?? state.model : state.model@@ -1077,10 +1079,30 @@ export class RuntimeProfileManager {return null}+ /**+ * An agent that has not bound an engine session yet. Its `sessionId` is the EMPTY STRING, which is+ * not an identity — every unbound agent would share one entry in a map keyed on it, across engines.+ *+ * That is not hypothetical. A claude agent ten seconds old was retargeted onto a grid, and the+ * "what model was it on?" read that the retarget keeps — so a later move home can restore it —+ * answered `opencode/big-pickle`: an OpenCode agent sitting at `''` had written its footer there+ * first. The claude pane came home with `ANTHROPIC_MODEL=opencode/big-pickle` and Claude Code+ * answered "There's an issue with the selected model (opencode/big-pickle). It may not exist".+ *+ * So `''` gets no entry. Reads answer "nothing observed", which is TRUE — an agent with no engine+ * session has no model to report — and writes land in a throwaway rather than in a bucket the next+ * agent will read. Everything real is re-read once the session binds, moments later.+ */+ private unbound(sessionId: string): boolean {+ return !sessionId+ }+private state(sessionId: string): RuntimeState {+ const blank = (): RuntimeState => ({ model: null, effort: null, mode: 'unknown', cliVersion: null, observedAt: null })+ if (this.unbound(sessionId)) return blank()let state = this.states.get(sessionId)if (!state) {- state = { model: null, effort: null, mode: 'unknown', cliVersion: null, observedAt: null }+ state = blank()this.states.set(sessionId, state)}return state