# Coding agents A conversation can run on a coding agent CLI that is already installed on the computer: Claude Code, Codex, or OpenCode 2.1.0 or newer in the 2.x series. OpenCode v1 is no longer supported. The CLI runs the agent loop with its own sign-in and model. OhMyGame keeps the conversation, checkpoints and Undo, its canvas, media, game and plugin tools, and the approval decisions. The [integration specification](agent-runtimes.md) records the architecture, accepted tradeoffs, and validation limits. ## Using one First-run setup also shows Claude Code, Codex, and OpenCode beside OhMyGame in its row of agents. Select an agent after installation and sign-in, choose its model on the same connection screen, then save with **Next** and continue to choosing where to start. Switching agents retains each selection until it is saved. OhMyGame (Pi) is always enabled and uses connected model providers. Discovery alone never enables a CLI. **Settings → Agents** lists who can work in a conversation. OhMyGame's own agent comes first: it uses the models set up in Providers, and its page chooses the one new conversations start on (a conversation that switches model moves it too). This is the only place to choose it; Providers' **Default models** covers image, video, 3D and audio, and shows once one of them has a model. The coding agent CLIs follow, under **Coding agent CLIs on this computer**; **Rescan** checks for them again. Each row shows whether the CLI was found and its version; its page (`#/settings/agents/`) provides account and permission controls. The agent whose model new conversations start with is marked **Default**. Agents are off by default. Enabling the switch offers their models in the conversation model picker; the detail page signs in, checks again, chooses the executable and permissions, and explains that the CLI loads the person's existing configuration. On macOS, discovery includes the CLIs bundled with Codex and ChatGPT in `/Applications` and `~/Applications`, as well as PATH, the login shell's PATH and usual CLI install folders. The detail page shows the resolved executable and where it was found. With several installations, the newest version wins; equal versions keep discovery order. A manually selected executable takes precedence even when another installation is newer. On Windows, discovery also checks Codex's versioned desktop installations under `%LOCALAPPDATA%/OpenAI/Codex/bin` and the native executable inside npm installations on PATH or in the usual npm folder. Selecting an npm `codex.cmd` or `codex.ps1` path resolves its adjacent package's native executable; the shell shim is never executed. Both current platform packages and older `vendor/` layouts are supported. A Codex shim whose native package is missing is reported as an unavailable manual installation and is never executed or replaced with another installation. For Claude Code, discovery checks for npm's `claude.cmd` on PATH and in the usual install folders. You can also enter its absolute path. For Claude Code, OpenCode, and plugin agents, supported npm `.cmd` shims identify the program to launch without running the script. Other `.cmd`, `.bat`, and `.ps1` scripts, including `claude.ps1`, are rejected before settings are saved. An undetected CLI is not necessarily uninstalled. Choose its absolute executable path for a custom installation, or leave the path field empty and save to restore automatic discovery. An unavailable manual path is reported explicitly rather than silently switching installations. **Rescan** and **Check again** refresh the login shell's PATH and probe caches, so installing a CLI or changing shell setup does not normally require restarting OhMyGame. Discovery, CLI startup, protocol compatibility and sign-in are separate checks; finding a bundled CLI does not guarantee that its version supports OhMyGame's integration. If Codex is found and signed in but offers no models, check the diagnostics on its detail page. Model discovery first verifies that Codex activates its built-in `:read-only` permission profile by starting an ephemeral thread without a prompt; a CLI that ignores named permission profiles is reported as incompatible before the model catalog is requested. OhMyGame does not change Codex's sandbox configuration. A successful model probe still requires a real conversation test on the target installation, including on Windows. ![Codex settings showing the desktop-bundled executable and automatic detection](assets/codex-cli-discovery.png) The model picker opens as a small card: the current model's **Thinking** levels (one click sets a level and closes it), up to three recent models, each at the level it was last used at, and **All models**. Typing in its search box, or choosing **All models**, shows every model grouped by provider, with a tab for each provider. A model chosen anywhere in the picker comes back at its last level when it still offers that level. The recent models live in the renderer's local storage (`ohmygame:recent-models`), shared by every picker. Codex and Claude Code models that offer fast mode show a lightning button at the end of the **Thinking** row. Fast mode gives quicker replies and uses more of your plan's usage; Claude Code needs usage credits for it. A filled bolt on the model button and in **Recent** means it is on. It stays with the model it was turned on for. Choosing a model again from **Recent** brings fast mode back as it was, on or off. The full list shows each agent's models in a group named after the agent. Each CLI group shows its brand icon; the conversation's model button keeps the same icon beside the selected model name. OpenCode's model rows also show the upstream provider beside the model name. Choosing one runs the conversation on that agent. A model reference names both: its provider is the agent's ID (`claude-code-cli`, `codex-cli`, `opencode-cli`), its ID is the agent's own model name, such as `sonnet` or `anthropic/claude-sonnet-5`. The `-cli` suffix keeps these apart from Pi providers of the same name; Pi has its own `opencode` provider. ![Agent brand icons in the model picker and composer (sample data)](assets/model-selector-agent-icons.png) `GET /models` lists Pi's models only, for canvas text and other one-off generation. Conversation pickers ask for `GET /models?runtimes=1`, which adds the enabled agents' models. An agent that is slow to list them is named in `loadingRuntimes`, and the picker asks again shortly. A new conversation in a project keeps the coding agent the person was using. A conversation created without a model takes the one the picker shows: the saved default, else Pi's preferred model, else the first enabled agent's. One made while no model was available takes that model when its next message is sent. Native effort/variant strings are exposed as `nativeReasoningLevels` and stored separately from Pi's reasoning enum. Saving a native default keeps both model and effort as `defaultModel` in `agent-runtimes.json`; it applies while that agent is enabled and offers the model. Choosing a Pi default clears it. Plain `GET /models` reports Pi's default as `defaultModel`; answers outside a conversation use the [default language model](custom-models.md#global-and-project-defaults), which `GET /models?runtimes=1` names as `textDefaultModel`. An explicitly chosen different model does not inherit an incompatible effort. Context usage uses the native context window when reported. Stored assistant messages record the latest model request's usage, as Pi's own messages do, rather than a turn's or thread's running total, so a conversation that moves back to Pi does not look larger than it is. Missing measurements remain unknown rather than being inferred from token totals. An account's quota windows show in **Settings → Agents**: a bar per window in each agent's row (5-hour, weekly), labeled as used. The detail page adds reset times. In a conversation they stay out of the composer and appear only under the commands when `/` is typed, with compact percentages and a tooltip on each window stating the share used. A conversation shows the account's latest report, so it has them before its own first turn. Codex reports them whenever its models are checked and while it works; Claude Code reports them during a conversation (its `rate_limit_event`), so they appear after its first one. The latest report is kept in `agent-runtimes/limits.json`, and a window whose reset time has passed shows as empty. System default reports saved by earlier versions are dropped once, since they may belong to the directory OhMyGame was launched with. OpenCode bills each model provider and has no quota of its own. When a turn stops at a usage limit (such as Claude Code's "You've hit your 5-hour limit") and an exhausted window of known length, opened before the failure, reports its reset time, the daemon sends one English `Continue where you left off.` 30 seconds after the last such window resets. The turn's error card shows that time beside a switch, on by default. It runs while OhMyGame is open, whichever conversation is showing; quitting ends the schedule and nothing is sent on the next launch. While the computer sleeps it waits until the computer wakes. Anything else that happens to the conversation ends the schedule: another turn, restoring or undoing, moving to another agent or account, turning the agent off, or starting to write in it while it is open. A different model on the same account continues on that model. If another conversation holds the project, the message waits for it. A turn in a plan, or a compaction, does not continue by itself. The card's switch, or the one on the agent's settings page, turns it off for that agent. Claude Code run with `-p` reports itself as `sdk-cli`, and subscription measurements show that label using the 5-hour limit about twice as fast as the interactive CLI for the same work ([anthropics/claude-code#97074](https://github.com/anthropics/claude-code/issues/97074); Anthropic has not confirmed it). **Report OhMyGame as the client**, on by default on Claude Code's settings page, sets `CLAUDE_CODE_ENTRYPOINT=ohmygame` for conversations: OhMyGame's own name, never another client's. Under any name but the `sdk-*` ones Claude Code also offers its claude.ai Artifact tools, so the switch sets `CLAUDE_CODE_DISABLE_ARTIFACT=1` too and the conversation keeps the tools it had under `sdk-cli`. Sign-in and model checks keep the CLI's default. Open conversations follow a change with their next message, as they do for a permission change. ![Claude Code and Codex quotas labeled as used (sample data)](assets/agent-usage-used-label.png) ![Compact quota percentages in the slash menu (sample data)](assets/agent-usage-compact.png) ![Codex conversation with a denied read, a cancelled turn, and Medium effort selected](assets/coding-agent-native-effort.png) ## Account configurations (Claude Code and Codex) Both CLIs support a separate configuration/state directory for each sign-in: | Agent | Official environment setting | What stays separate | | --- | --- | --- | | Claude Code | `CLAUDE_CONFIG_DIR` | CLI configuration, sign-in and native history | | Codex | `CODEX_HOME` | CLI configuration, credential store, sessions and state | In **Settings → Agents → Claude Code/Codex → Accounts**, click **+**, enter a name and click **Add** to create a private configuration and start the official sign-in flow. **Use an existing directory** expands an optional import field for an absolute configuration path; importing does not start another sign-in. System default's own directory (`~/.claude` or `~/.codex`) cannot be imported: naming it explicitly would give Claude a separate Keychain entry and global configuration file while sharing its settings. A managed Codex directory is created before its CLI starts and uses `cli_auth_credentials_store = "file"` in its own `config.toml`. The directory is private, and Codex manages its sign-in in `auth.json`. Imported configurations keep their own native credential-storage settings. OhMyGame stores profile names and directory references; it never copies tokens between accounts or implements its own OAuth flow. Each account row has a sign-in action. Use the refresh icon after the official browser flow completes if the status has not updated. The sign-in action starts the CLI's official login flow directly; OhMyGame does not log out first, delete the account configuration or clear conversation history. Completing authorization lets the CLI update credentials in that configuration. ![Compact account list with a default selection and sign-in actions](assets/coding-agent-accounts.png) **System default** is the CLI's own default directory (`~/.claude` or `~/.codex`) and its sign-in. A `CLAUDE_CONFIG_DIR` or `CODEX_HOME` that OhMyGame inherits, from a terminal or from a tool that sets it for apps with `launchctl setenv`, is not used: it only records whichever account was selected when OhMyGame started. To use that directory, import it with **Use an existing directory**; it then shares its sign-in and files with the terminal. New profiles have independent CLI settings, hooks, MCP servers, Skills and native history. System default stays first; **Move up** and **Move down** in another row's **⋯** menu set the order, which the chat header's account menu follows. Select an account row's radio button to make it the default for new chats. Existing chats retain their own selections; switching between Claude Code and Codex in a chat retains each agent's selection. With multiple profiles, the chat header offers an account menu showing the selected account name and its shortest quota window's share used, such as the 5-hour one. The menu lists every account with that share and a ring per window; hovering or focusing an account shows its windows with how much is used and how long until each resets beside the menu. The times count down while the menu is open, from each account's last quota report. The system account is called **Default** there. Buttons beside the heading open the agent's account settings and check the accounts again. Picking another account switches it without an additional confirmation. Wait for the current request to finish before switching. Choosing the account the chat already uses changes nothing. When the selected account's model catalog does not offer the chat's model, the chat moves to the new-chat default model if that account offers it, otherwise to the first model the account lists, and the timeline records the model change. A catalog that cannot be read in time leaves the model unchanged. The next message creates a context for the selected account, with a bounded history handoff if it has not seen this chat; switching back before a message on the other account resumes the earlier context instead. `/compact` waits for that first message on the selected account. Other chats keep their accounts. No automatic rotation at usage limits is provided. **⋯ → Edit account** renames an account. An imported account can also point at another directory, which passes the same checks as an import and is refused during a turn or session startup. The account keeps its id, so its chats stay on it: deleting and adding it again would move them to System default. A chat whose native session is not in the new directory finds it expired and continues with a history handoff. A managed account's directory cannot change, because deleting it relies on that directory staying in the reserved folder. **⋯ → Open configuration directory** opens an account's directory, System default's included, to edit the CLI's own files, and **Copy directory path** copies it. OhMyGame has no editor for these files: their formats belong to the CLI, and the directory also holds its sign-in. Use **⋯ → Delete** to remove a profile after confirmation. The confirmation states whether its files will be removed: app-created profiles delete their managed configuration directory (including sign-in and native history), while imported profiles only disconnect from OhMyGame and keep their files. System default cannot be deleted. Deleting the new-chat default resets it to System default. Existing chats, including restored branches, fall back to System default when next read and discard the deleted account's native resume context; the shared conversation history remains available for a fresh handoff. Deletion is refused during a turn or session startup; finish or cancel the work first. Idle sessions and pending sign-in processes stop before managed files are removed. A managed profile is then signed out with the CLI's own command (`claude auth logout` or `codex logout`) in its directory, so Claude's macOS Keychain entry for that directory does not outlive it; a missing CLI or failed sign-out does not keep the directory. Imported profiles are not signed out. ![Account removal confirmation stating that managed files will be deleted (sample data)](assets/coding-agent-account-delete.png) Switching saves the selection locally and reads previously reported usage without creating a native session. It reads the selected account's model catalog to check the chat's model. Model catalogs are cached per account for ten minutes; a valid catalog is returned without another auth probe. A cold or expired catalog can query the CLI for models, account information and limits, which may contact the provider. Switching does not start sign-in, force a token refresh or send a model turn; the CLI session is created when it is needed for a message. Authentication, models and usage caches are separate per runtime and profile. Codex app servers may be shared only when executable, environment (including `CODEX_HOME`) and staged Skills match. Different account homes never share a server. Explicit Claude profiles omit an ambient `CLAUDE_CODE_OAUTH_TOKEN` so it cannot override the selected sign-in. Codex Image and external MCP client configuration continue using System default independently of chat selections. See the official [Claude account configuration guide](https://code.claude.com/docs/en/authentication#log-in-with-multiple-accounts), [Codex state directory reference](https://learn.chatgpt.com/docs/config-file/environment-variables) and [Codex credential storage reference](https://learn.chatgpt.com/docs/auth). Directory isolation does not establish whether combining subscription allowances is permitted by a provider's terms. ## Codex as an image provider **Providers → Codex CLI** exposes one image entry, **Codex Image**, using the installed CLI and its saved sign-in. Its image switch is independent of the Codex conversation-agent switch in Agents. Any chat agent can use it through `generate_image`; canvas image nodes and global/project image defaults use the same provider. Choose the global image default in the Providers overview. The Codex CLI detail page shows its image status and model without a default-model selector. Closing a terminal does not disconnect the provider. ![Codex image provider connected through the saved CLI sign-in (sample data)](assets/codex-image-provider-settings.png) ![Codex Image selected in the asset canvas](assets/codex-image-canvas.png) The image connection follows the installed CLI's saved sign-in. A signed-in account exposes **Codex Image** without a separate image-capability probe or inference request. Missing CLI or sign-in keeps the entry visible with a diagnostic. The detail page offers **Sign in** only when the CLI reports a signed-out account. **Check again** refreshes the saved sign-in, including when image generation is disabled. Image access, compatibility and usage-limit errors are reported by the generation request, without switching providers or retrying inference automatically. The provider list and first-run setup return the last known sign-in status without waiting for the CLI. Enabled image providers refresh that status in the background; disabled ones do not start a check. Each generation starts its own ephemeral app-server thread, with no OhMyGame dynamic tools, external MCP servers, shell tools or subagents. The process is started on demand and stopped on completion, failure or cancellation. Multiple reference images are passed in order as inline image inputs, without staging reference files; the app's shared 16-image limit applies. Codex manages the actual image model and dimensions, so the canvas hides resolution and aspect-ratio controls for this provider. Built-in Codex chat generation remains a separate native path; the image provider does not force a Codex chat to stop using its own tools. Validation includes simulated canvas generation, image-toggle persistence, failure/cancellation fixtures, and a real image generation with Codex 0.163.0-alpha.10.2 on macOS while its conversation agent was disabled. ## Branch in new chat A completed agent response has **Branch in new chat** immediately to the right of Copy. After confirmation, OhMyGame opens a new chat containing the source chat's current history through that response, inclusive. Later messages are not copied. The source chat is unchanged, and either chat can continue independently. This applies to Pi and all supported coding agent CLIs. ![Branch in new chat next to Copy on a completed response](assets/chat-branch-response.png) Both chats use the same project's current files. Branching a chat does not restore older files or create a separate workspace. The new chat receives the model and settings recorded at the branch point, clears active plan state, and creates its own native CLI context from a history handoff. ## What OhMyGame keeps A coding agent session (`NativeCodingSession`) implements the same `CodingSession` interface as Pi, so `AgentManager` runs it unchanged: queues, plan mode, cancellation, errors and events are the same code. - **Conversation record.** Every user message, answer, reasoning block and tool result is stored as a Pi message in the conversation's session file, so the conversation list, history, message edits and restarts work as for Pi. These messages are a record; the CLI keeps its own context. - **Checkpoints.** The workspace snapshot is taken before each user message is stored, exactly where Pi's checkpoint extension takes it, through the shared `recordCheckpoint`. Turn changes and Undo therefore cover whatever the CLI changed. - **Native session.** The CLI's own session or thread ID is stored as an version-2 `ohmygame-native-session` custom entry on the branch. Only a `ready` marker resumes; `active` marks an unfinished turn and `invalid` requires a rebuild. The next message continues it (`--resume`, `thread/resume`, the OpenCode session). Every edit or restore invalidates context, even when the native ID is unchanged. Later Pi messages/model changes, unconfirmed cancellation, unrecoverable failure, legacy metadata and interrupted writes also invalidate it. Codex retains its thread after a confirmed stop, a terminal failed request or an explicit request rejection; an exited app server resumes the thread on its next run. Inputs rejected before startup are carried into the next turn. An expired native session triggers one fresh-context retry with handoff rather than silently losing history. - **Handoff.** When an agent joins a conversation it has not seen, its first message carries a summary built from the stored record: recent turns and the files the earlier agent worked on, the structured plan, and restore notices. It asks no model, and private context such as file references is left out. When you switch back to Pi, it reads recent native replies and tool activity as [historical context](agent-runtimes.md#shared-transcript-and-native-context). Pi can look up older decisions and tool details in this conversation as needed. Terminal approval decisions and native compaction results are custom entries in the same session file. OhMyGame keeps no permission grants: an agent's "always allow" lives in that agent's own session or settings. No second conversation manager or event database is needed. ## How each agent is driven | Agent | Transport | OhMyGame tools | Approvals | | ----------- | ---------------------------------------------------------------- | ------------------------------------------------------- | ---------------------------------------------------- | | Claude Code | `claude -p` with stream-json in and out; one process per session | In-process MCP server answered over the same pipe | `can_use_tool` control requests | | Codex | `codex app-server` JSON-RPC; one thread per conversation | The thread's dynamic tools, answered over the same pipe | App server approval requests | | OpenCode | `opencode serve` on loopback with its own password | Remote MCP on the daemon with a turn token | `permission.asked` events, answered on the server | ### Codex subagents, background terminals and plans **Codex tasks** above the chat composer lists Codex's subagents and the commands that outlive their turn, with their status and recent output. The driver follows them from the app server's notifications for the conversation's thread and its subagents' threads, so they stay visible after the turn that started them ends. Finished tasks fold into one row and are put away when the next message starts a turn; their results stay in the conversation. - **Subagents.** A subagent appears when Codex reports starting it (`subAgentActivity`, or a `spawnAgent` call). Its tool calls show in the turn it works for while that turn runs, labelled with its name; its messages show in its task. Its approval cards show in Codex tasks and stay answerable after the turn ends. Planning and the conversation's permission mode still apply. **Stop task** interrupts the subagent's own turn. - **OhMyGame tools.** A subagent's call to OhMyGame's tools runs only while the turn it works for runs, and its card shows there. Outside that turn the call is refused with a message saying so, since nothing would show its result. Questions a subagent asks are answered empty. - **Background terminals.** A command still running when its turn ends becomes a terminal task. Its end arrives later on the ended turn; the driver also checks `thread/backgroundTerminals/list`, since Codex can end a turn without reporting the end of a command whose shell already exited. **Stop task** terminates the command. - **Plans.** Codex updates the conversation's checklist above the composer through `ohmygame_update_plan`. An empty list clears the checklist. OhMyGame selects this tool in its Codex threads, including when the user's Codex configuration enables the built-in checklist. Tasks keep the process from being reclaimed by the idle timer. Letting go of the thread, such as when the conversation closes or its native context is reset, stops what still runs. The task list is live session state: after the daemon restarts, running work is not restored. Codex can also start a turn by itself. That turn shows in the conversation as a turn with no message of the person's. It runs, can be stopped, and messages sent meanwhile wait for it, as for any turn. Its changes have no checkpoint of their own, so Undo of the turn before it does not cover them. It starts only when a message could: while a restore, an undo or a put-back changes the project's files, or with checkpoints while another conversation of the project runs, it waits and then starts. A turn that Codex starts while OhMyGame is closing the previous turn appears separately, before queued messages. One that Codex starts while a message is being prepared becomes part of that message's turn and shows first in it: if it is still running, Codex adds the message to it, and the turn ends when it does. **Stop** interrupts only the conversation's own turn, so subagents and background terminals keep running until stopped from their task. Each stdin stays open for the session. A CLI that no message has used for ten minutes is stopped; the next message starts a new process that resumes the same native session. Codex conversations with the same executable, environment and staged Skills share one app server, routed by thread; it stops with its last conversation. OpenCode keeps a server per conversation because its MCP servers, and so OhMyGame's tools, are registered for the whole instance. After **Stop**, once Claude Code or Codex has reported that the turn ended, the next message continues the same session and tells it the turn was stopped. A forced stop still requires a history handoff, as does every OpenCode stop. Native queue prioritization means **Next**: after the current turn, before ordinary follow-ups. Mid-turn native injection is excluded because concurrent file writes cannot provide an independent checkpoint before delivery. Processes run in their own process group, are registered with the desktop app for crash cleanup, and are stopped when the daemon closes. On macOS and Linux, forcing a stop also kills descendants that lead a group of their own, such as Codex background terminals. The timeline shows retries reported by the CLI, with attempt counts when available. Retry notices are live activity. Codex terminal error notifications can appear while the turn is still running, and the turn's final result determines the saved error. Cancellation checks before/after startup prevent late input delivery. Interrupt waits are bounded, then the CLI is stopped. HTTP calls time out and loss of OpenCode's SSE stream fails the pending turn. Standalone startup also reclaims verified orphan process groups from `agent-runtimes/processes`, checking both the daemon and child's executable/birth identity before killing anything. Private folders carry the daemon's ownership identity as well: startup reclaims verified orphans while preserving another live daemon's folders. Identity queries run asynchronously, one at a time, and concurrent requests for the same PID share a query. Queries allow up to 30 seconds on Windows for PowerShell cold starts, and 10 seconds on other platforms. Ownership records are written in the background so starting a CLI or image job does not wait for PowerShell. Startup recovery still waits for identity checks before reclaiming anything. A crash before records are written can leave unrecorded folders or processes that startup recovery preserves. Removing a private folder cancels a pending lease and waits for an active write. Configuration and Skills are removed only after the CLI stops. Unverifiable identities and subprocesses that escape their group cannot be reclaimed this way. OhMyGame's tools are the handlers Pi uses (`createAgentTools`), offered through `ToolBridge`. Plugin MCP servers reach the agent through the same `mcp` tool Pi uses, run in a model-less session in the daemon, so plugin settings, switches and credentials stay in the daemon. Codex registers bridged tools with an `ohmygame_` prefix to avoid reserved names such as `mcp`; dispatch and the conversation timeline retain the original tool names. Skills (plugin Skills and OhMyGame's own) are copied into a private folder for the session and handed to the CLI: a session plugin for Claude Code, `skills/extraRoots/set` for Codex, the `skills` array for OpenCode v2. Skills a message names as `$name`, any number of them, reach each agent its own way: as Codex `skill` input items, and as a first line asking Claude Code (by their `ohmygame:` names) or OpenCode to load them; see [agent runtimes](agent-runtimes.md#tools-plugins-and-skills). Staging copies regular files and omits symbolic links, so it cannot copy an external credential through a Skill's link. Each agent reads the staged Skills without asking: Claude Code also gets the folder with `--add-dir`, OpenCode's session allows it as an external directory, and Codex's profiles read it already. Running a staged script follows the agent's own rules. Nothing is written to the workspace. The OpenCode tool endpoint, `POST /agent-runtime-bridge/mcp`, takes the turn's token instead of the app's. It is revoked permanently on completion, cancellation, failure or disposal; each later turn gets a new token. Bridged tools receive the turn's abort signal and late results do not enter its timeline. New plugin capabilities must be expressible as Skills or MCP servers; Pi extensions do not reach coding agents. ## Approvals and limits Each coding agent keeps its own permission system: its rules decide what it does without asking and what it asks. OhMyGame adds no rules, sandbox settings or protected folders of its own, as its own agent works without asking. Each agent's detail page has a **Permissions** setting with the agent's own modes, by the names its CLI uses, and a note on what the chosen one does: - **Claude Code**: Manual (`default`, called `manual` by newer CLIs: asks before edits and commands), Accept edits (`acceptEdits`), Auto (`auto`: Claude Code's classifier allows safe actions and asks about risky ones; a model without auto mode stays in Manual), and Bypass permissions (`bypassPermissions`, the default). - **Codex**: Default (`:workspace`: works in the project and asks, `on-request`, before edits outside it or internet access) and Full Access (`:danger-full-access` without approvals, the default). - **OpenCode**, which has no modes: Your rules (the person's OpenCode permission rules) and Allow all (the session allows everything, the default). The default asks nothing, as OhMyGame's own agent does. Read-only modes are not offered, since planning uses them. Earlier versions offered OhMyGame's own Standard and Full access: settings saved by versions that stored Standard with any setting move to the mode that asks nothing, and a later Standard choice becomes the agent's usual mode (Accept edits, Default, Your rules). A mode chosen from then on is kept. Every mode loads the person's CLI configuration, including the permission rules they set up in the CLI. Changing permissions or the executable path lets go of the agent's idle open conversations. A running turn keeps its setting and is released when its run closes. The next run restarts the CLI with the new settings and resumes its session, including when settings change during startup. What an agent asks appears as an approval card above the composer, with the command, files, network access and reason the agent gives. The card offers **Allow**, **Deny**, and, when the agent offers it, **Always allow** (saved in the agent's own settings) or **Allow for this conversation** (for the agent's session), with the agent's own description of what that covers, such as Claude Code's `Bash(npm install:*)` or Codex's proposed command prefix. Always allowing goes back to the agent in its own form: Claude Code's suggested permission updates, Codex's exec-policy amendment or session-wide acceptance, OpenCode's `always` reply. Answered requests stay in the timeline. Stopping the turn denies every request still waiting. OhMyGame's own tools never ask; the daemon runs them. OpenCode file patterns resolve from its reported session location rather than assuming it equals the application workspace, and search metadata identifies the actual search directory. Child-session permission requests are admitted only after verifying their ancestry through the native API; they cannot be dropped merely because their session ID differs from the parent. A planning turn only reads the project and proposes a plan. There is no approval step: the plan stays in the conversation, and the person carries it out, or asks for changes, with an ordinary message. Plan is a switch on the message, kept with the draft until the person turns it off. A new project's first message sent in plan mode from Home leaves it on in that conversation. Editing or retrying the latest message runs it in the mode the switch shows. Each agent plans in its own plan mode: Claude Code in its `plan` permission mode, Codex in its native Plan mode and `:read-only` profile, OpenCode with its `plan` agent, and an ACP agent in its plan or read-only mode when it has one. An ACP agent without one is told in the turn that it is planning. Pi has no plan mode, so OhMyGame gives it read-only tools and plan mode's instructions as a hidden message after the person's, which later turns no longer send to the model; the conversation stores and shows only what the person wrote. Native agents get only the person's message. The plan is what the agent proposes in its own way. Claude Code's `ExitPlanMode` and Codex's plan item are shown as a plan card in the conversation, kept as a `proposed_plan` call in the session; Claude's call is then declined, since leaving plan mode would start the work. Pi and OpenCode reply with their plan. Another agent that takes the conversation over gets a proposed plan whole. Planning turns are read-only in every mode. Claude Code may write only its own plan file outside the project; its file-changing tools are refused in the project. Tool permission requests while planning are refused without asking, with feedback, so the agent adjusts instead of stopping; a bare OpenCode rejection would end its loop. Native agents are told that OhMyGame's tools come from its `ohmygame` tool server under their CLI's MCP names. Claude's `AskUserQuestion` is routed to a question card, including during planning. Codex registers every OhMyGame tool when its thread starts, since a thread that begins in planning continues with work; tools the current mode does not allow are refused when called. Claude Code runs with background tasks and scheduled prompts disabled (`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS`, `CLAUDE_CODE_DISABLE_CRON`): a background subagent or shell would report after the turn's result, with no turn to receive it. OhMyGame's tools are marked always loaded so Claude's tool search does not hide them. Full access launches Claude Code with `--allow-dangerously-skip-permissions`, so a planning turn can leave `bypassPermissions` for plan mode and return to it. Codex requires named permission profiles and checks that its app server activated the requested built-in profile before delivering a prompt. Each CLI runs as the signed-in OS user. What it can read, including other CLIs' sign-ins and OhMyGame's data, is what its own configuration and sandbox allow. Strong confidentiality isolation requires a separate process/container sandbox and isolated credentials. ## Questions during a task OhMyGame's `questionnaire` is available in normal and planning turns for every agent. Codex's `item/tool/requestUserInput` and Claude Code's `AskUserQuestion` use the same question cards above the composer. These are separate from tool permissions. Cards preserve single choices, multiple selections and free-text answers; submit the answers to continue, or **Skip** without providing an answer. OhMyGame's `questionnaire` always offers **Answer manually** alongside its choices; selecting it opens a text field and stops the countdown. Models cannot disable custom answers. Text-only questions show the field directly. Native question cards follow their protocol. Claude allows custom answers. Codex input RPCs use `isOther` when choices are supplied, and Codex asynchronous messages allow free text. Concurrent requests remain queued. Switching chats or hiding the panel does not answer or cancel a question, and partial drafts survive those view changes in memory. Reloading the page restores pending questions from the daemon, but not unsubmitted drafts. Finished questions remain in the work history. Codex planning turns select native Plan mode, which makes its native question tool available; execution explicitly returns to Default mode. Codex nonblocking questions keep the composer available. Codex can also attach questions to an asynchronous agent message. Its choices and free-text field appear on the same card. Submitting delivers the answers to the originating active turn; **Skip** closes the card without sending a message. A card that closes without an answer, through **Skip** or because the turn ended, leaves the message Codex sent in the chat, so the question stays readable and can be answered in the composer. For a pending Codex input RPC, **Skip** returns an empty answer map. A server-resolved request, CLI exit, turn end or cancellation clears its waiter. Late answers are rejected. Restarting the daemon does not resurrect a pending request. Native secret-input requests are rejected with an explanation; do not enter credentials into a chat question. MCP form and URL elicitation remain unsupported and are declined. **Settings → Agents → Automatically use recommended answers** offers Off, 1, 3 (the default) or 5 minutes. Saved choices, including Off, are preserved. Unreadable settings leave automatic answers off and report the problem. The daemon commits a deadline when an eligible question arrives; it continues while the window or chat is hidden. The whole request must consist of single-choice questions with exactly one explicit recommendation each. Text-only questions, multiple selections and unmarked choices stay manual. The first option is never an implicit recommendation. The card displays its countdown; interacting with it cancels that request's deadline. Choosing **Off** cancels existing deadlines; other delay changes apply to future requests. Automatic answers are labeled in history. Quitting ends the timers. Automatic answers apply to OhMyGame's `questionnaire` (including when called by Codex or Claude) and Claude's native clarification questions with a literal `(Recommended)`, `(推荐)` or `(推荐)` label. Native Codex input requests remain manual: the same protocol can carry app action confirmations and does not provide a reliable clarification discriminator. Tool approvals are never answered by this setting. These boundaries follow the [Codex app-server protocol](https://learn.chatgpt.com/docs/app-server) and [Claude user-input contract](https://code.claude.com/docs/en/agent-sdk/user-input). ## Environment and isolation A CLI gets an environment built from an allowlist: PATH, HOME, locale, temporary folders, proxies, certificates, and that CLI's own configuration folder variable. API keys are left out, so an ambient key never moves a subscription to metered billing; Claude Code keeps `CLAUDE_CODE_OAUTH_TOKEN`, which is a subscription sign-in. The daemon's token and `OHMYGAME_*` variables never reach a CLI. The executable is resolved to an absolute path from the person's choice, PATH, the login shell's PATH, usual install folders, and known bundled copies such as ChatGPT's Codex. On Windows only native `.exe` programs are started; supported Codex npm shims resolve to the packaged executable because Node cannot start `.cmd`/`.bat` shims without a shell. An explicit path wins; automatic discovery chooses the newest SemVer, including prerelease ordering, and retries failed version probes. Recheck also invalidates successful probes. Catalog refreshes honor their TTL and discard results from a superseded configuration. In conversations, all three runtimes load the person's existing CLI configuration, including settings, hooks, MCP servers, Skills and instructions supported by that CLI. There is no configuration-isolation switch. Stored `isolateUserConfig` values from earlier versions are ignored and dropped when settings are next saved. OhMyGame adds its tools, project instructions and staged Skills, and selects the permission mode. A configured external `ohmygame-studio` MCP connection is disabled inside Claude Code and Codex to avoid reconnecting to the same app recursively. Other user MCP servers and notification hooks remain enabled. Codex's own project root markers, shell environment policy, instructions, Skills and plugins apply as configured. Configuration inheritance does not remove read-only planning. OpenCode v2 adds staged Skills and an instruction file in its private session directory. Its MCP bridge disables code mode so native calls retain their tool names and structured app results. It waits for the MCP connection and catalog before sending a prompt. No configuration file is written to the workspace. Custom `OPENCODE_CONFIG_DIR` and `OPENCODE_CONFIG` paths are retained, alongside XDG roots. Discovery probes may suppress external MCP servers and hooks while inspecting protocol compatibility and model catalogs; they do not send inference prompts. ### Sealed turns Outside a conversation, such as a canvas answer or a plugin's models, an agent runs a **sealed** turn (`AgentRuntimeService.run`). It sees only OhMyGame's instructions, the prompt and the tools it is given, works in an empty folder of its own (`agent-runtimes/sealed/`), and every permission it asks for is refused without asking: | Agent | How it is sealed | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Claude Code | `--tools ""`, `--strict-mcp-config`, `--setting-sources ""`, `--disable-slash-commands`, `--system-prompt`; default mode, and every tool but OhMyGame's refused | | Codex | A thread with Codex's tool features off (shell, code mode host, plugins, apps, browser and computer use, image viewing, worktrees, hooks; `sealedCodexConfig`), web search, MCP servers and Skill instructions off, no project `AGENTS.md` or configured developer instructions, `baseInstructions`, `:read-only` and `never` | | OpenCode | An agent of OhMyGame's own that denies OpenCode's tools by name, a session rule denying the person's other MCP servers, and no Claude Code or project files (`OPENCODE_DISABLE_CLAUDE_CODE`, `…_PROJECT_CONFIG`) | | Plugin ACP | Its manifest's `sealed` launch ([plugin coding agents](plugins.md#coding-agents)); a call named like one of OhMyGame's tools is allowed only if it is of no kind the agent's own tools have | OpenCode 2.1 drops every MCP tool, OhMyGame's included, once a rule denies `"*"`, so its own tools are denied by name; one a later version adds is still refused if it asks permission. What no setting removes, checked against Codex 0.162 and OpenCode 2.1: - Codex reads `$CODEX_HOME/AGENTS.md`, and its models keep a code-mode `exec` and helper-agent tools. `exec` reaches only OhMyGame's tools, and a helper is sealed the same way. - OpenCode reads its global `AGENTS.md` and loads the person's plugins, whose tools stay available. Its code mode still lists tools that only manage its own sessions. A turn keeps no native session unless the caller asks to continue it (Claude's `--no-session-persistence`, an ephemeral Codex thread, an OpenCode session deleted afterwards); a plugin ACP agent may keep its own history. A continued session keeps the instructions it began with. Only agents that can be sealed list their models with `standalone: true`; a plugin agent without a `sealed` launch is offered only in conversations. Canvas text, documents and tables, random ideas, project names and plugins' `models.complete` answer with these models in one sealed turn each (`TextModels`, `src/daemon/text-models.ts`). Several messages become one transcript prompt; images go with the last message, to Claude Code and Codex only. A request's effort is the agent's own (`nativeReasoningLevel`), and the agent sets its own output limit and may report no token usage. Stopping a turn asks the agent to stop, then stops its process if the turn hasn't ended within a few seconds. Sealed answers come one after another, so their agents start ahead. A turn without tools or a session to continue takes an agent already started with the same settings (agent, profile, executable, environment, model, effort and instructions) and starts the next one (`NativeDriver.warm`). Claude Code, OpenCode and plugin ACP agents are started up to their first prompt: a process, or with ACP a session. A started agent waits 2 minutes and then stops, and at most 3 settings have one at a time. Codex's app server stays 2 minutes after its last sealed turn instead; each turn starts a thread on it, which the server unloads (`thread/unsubscribe`) once the turn ends. An answer returns without waiting for its agent to stop. A turn that keeps a session, is stopped or fails waits for it. ## Settings and API `agent-runtimes.json` in the data directory stores, per agent, `enabled` (default off), `autoContinue` and, for Claude Code, `identifyAsOhMyGame` (both default on), `permissionMode` (one of the agent's own modes, default the one that asks nothing), an optional absolute `binaryPath`, and an optional native model/effort `defaultModel`. A damaged file falls back to the defaults. Credentials remain in the CLI's own store. The person's own [agent instructions](runtime.md#agent-instructions) reach a coding agent with OhMyGame's, after them. | Route | Purpose | | --------------------------------------------------------- | ---------------------------------------------------------------------- | | `GET /agent-runtimes` | Status of every agent; `?recheck=1` probes again | | `PATCH /agent-runtimes/:id` | `enabled`, `autoContinue`, `identifyAsOhMyGame` (Claude Code), `permissionMode`, `binaryPath` | | `POST /agent-runtimes/:id/recheck` | Probe one agent again | | `GET /agent-runtimes/:id/profiles`, `POST /agent-runtimes/:id/profiles` | List or add Claude Code/Codex account configurations | | `PATCH /agent-runtimes/:id/profiles/:profileId` | Rename an account, or point an imported one at another directory | | `POST /agent-runtimes/:id/profiles/:profileId/move` | Move an account up or down; System default stays first | | `GET /agent-runtimes/:id/profiles/:profileId/directory` | The directory the desktop app opens for an account | | `DELETE /agent-runtimes/:id/profiles/:profileId` | Remove an account; managed files are deleted, imported files kept | | `PUT /projects/:p/conversations/:c/account-profile` | Select an account for the conversation | | `POST /agent-runtimes/:id/login` | Start the CLI's sign-in; returns a browser URL or a command | | `PUT /projects/:p/conversations/:c/reasoning` | Select a native effort/variant string | | `PUT /models/default`, `POST /projects/:p/conversations`, Canvas text, document and table `…/generate` | Take `nativeReasoningLevel` for a native model, never `reasoningLevel` | | `GET /settings/questions`, `PUT /settings/questions` | Automatic recommendation delay: `delaySeconds` is 0, 60, 180 or 300 | | `POST /projects/:p/conversations/:c/questionnaire` | Answer or skip questions; multi-select answers carry explicit `values` | | `POST /projects/:p/conversations/:c/questionnaire/:requestId/hold` | Cancel a question's automatic deadline on manual interaction | | `POST /projects/:p/conversations/:c/approvals/:requestId` | Answer an approval request: `allow`, `allow-always` or `deny` | Status and models are probed only when asked for and cached by executable signature. Conversation model discovery does not start disabled CLIs; the image catalog independently probes Codex when checking image providers. ## Adding an agent 1. Add its ID to `AGENT_RUNTIME_IDS` and a definition to `AGENT_RUNTIME_DEFINITIONS` (binaries, version arguments, tested version, sign-in command). 2. Teach `probeAuth` and `probeModels` how to ask it who it is and what models it has. 3. Write a `NativeDriver` that runs a turn and reports through the `NativeTurnSink`, honours `DriverContext.sealed` (see [sealed turns](#sealed-turns)), and create it in `driverFor` (`src/daemon/agent-runtimes/service.ts`). 4. Add an icon to `PROVIDER_ICONS` and test the driver against a fake process (`setAgentProcessSpawner`), as `test/agent-runtime-drivers.test.ts` does. The Provider, media, canvas, checkpoint and plugin code does not change. ## Recorded turns `test/agent-transcript-replay.test.ts` plays turns recorded from the real Claude Code and Codex CLIs back to their adapters. Each transcript in `test/fixtures/agent-transcripts//` holds every line between the CLI and the adapter. The test fails when the adapter writes a line the CLI did not receive or leaves one out, and compares what the adapter reported (text, tool calls and results, proposed plans, approvals) with the `.reported.json` file beside the transcript. A change to what an adapter reports shows in that file's diff; update it with `bunx vitest run test/agent-transcript-replay.test.ts -u`. Record a turn again after a CLI update or to add a scenario: ```sh node --import tsx scripts/record-agent-transcript.ts claude-code-cli edit node --import tsx scripts/record-agent-transcript.ts codex-cli plan ``` The script runs one short turn in `/tmp/ohmygame-transcript` with the installed, signed-in CLI, and uses a little of the account's quota. It leaves out the person's own setup (commands, agents, plugins, Skills, MCP servers, account fields and Codex configuration) and replaces the home folder, user name, host name and email addresses. Read a transcript before committing it. OpenCode talks over HTTP, which the recorder does not capture yet; its adapter is tested with the fake server in `test/agent-runtime-drivers.test.ts`. ## Compatibility and real acceptance Compatibility follows the capabilities the adapter needs, rather than a CLI being older than the version used for acceptance. Settings records Claude Code 2.1.302 and Codex 0.163.0 as reference acceptance versions. OpenCode uses the v2 server contract, records 2.1.0 as its real acceptance version, and requires 2.1.0 or newer in the 2.x series; the version check selects that supported API generation, and runtime checks still apply. Enabling or rechecking an agent uses the same discovery checks as its model catalog; incompatible agents do not offer models. Results are cached by the executable signature and invalidated when settings change or **Check again** is used. Temporary failures remain probe/catalog errors and retry after the short failure cache expires; they are not classified as unsupported capabilities. - Codex discovery starts an ephemeral thread with a dynamic tool in Codex's built-in `:read-only` permission profile, and checks the returned `activePermissionProfile`. It sends no model turn. The real driver checks the profile again on start/resume. Codex 0.162.0-alpha.17.2 has passed this protocol probe; that alone is not a full inference or sandbox acceptance run. - Claude discovery registers the SDK tool server and PreToolUse callback during its control handshake, and accepts catalogs from `initialize` or `list_models`. - OpenCode discovery starts `serve --stdio --hostname 127.0.0.1 --port 0` with a private password and reads its JSON address announcement. It establishes `/api/event`, checks `/api/info` and `/api/location`, waits for its `build` and `plan` agents, and lists `/api/model`. This creates no session and sends no inference. Before each prompt a real session applies the rules its mode needs: the staged Skills readable and, in its Allow all mode outside planning, everything allowed. Child-session requests must have verified ancestry and the same workspace location; file resources resolve relative to that session's location rather than the Git root. Saved OpenCode grants are the person's own and apply. User plugins remain trusted CLI code. OpenCode v2 native session IDs carry an `opencode-v2:` marker in OhMyGame's session record. A v1 marker or missing v2 session triggers the existing fresh session and conversation-history handoff; v1 context is never resumed as v2. Missing optional quota or reasoning metadata stays unavailable. Local CLI compatibility failures have their own chat error presentation and CLI details. Being signed in and seeing a model does not guarantee account entitlement. ![CLI capability diagnostic and reference acceptance version](assets/coding-agent-compatibility.png) This screenshot uses a simulated CLI reporting `99.0.0` that ignores the requested permission profile. A higher version cannot bypass the capability check, and the verified version remains a reference. The direct adapters preserve the installed executable and shared host services. The Claude Agent SDK was evaluated and not adopted: it bundles its own Claude Code binary (about 268 MB per platform) and each release targets one CLI release, while OhMyGame drives the CLI the person installed. See [agent-runtimes.md](agent-runtimes.md#runtime-transports-and-compatibility). Claude's direct control protocol and Codex's experimental dynamic tools need compatibility tests when their CLIs change. A generic Basic CLI adapter is not implemented; each new CLI needs discovery, a driver, and acceptance tests. Run public checks from [CONTRIBUTING](../CONTRIBUTING.md). Focused fixtures cover branch invalidation, expired resume, queue checkpoint ordering, startup/interrupt cancellation, bridge token revocation and abort, SSE loss, quotas, model dialects/defaults, stale discovery results, catalog pagination, planning write grants, child-session approvals, persisted approvals/compaction and verified orphan recovery. Real inference is opt-in and consumes the provider's quota: ```bash bun run test:agent-runtimes:live opencode-cli opencode/mimo-v2.6-flash-free bun run test:agent-runtimes:live codex-cli YOUR_AVAILABLE_MODEL bun run test:agent-runtimes:live claude-code-cli YOUR_AVAILABLE_MODEL ``` Choose a currently listed model with a working account. The script uses isolated app data and a disposable workspace, runs the agent in its usual mode (Accept edits, Default, Your rules) so its own approvals reach the test, grants only scoped test requests, and saves evidence under ignored `.runtime/`. It checks writes, an OhMyGame tool call, continuation, daemon restart, compaction, editing a later message, checkpoint restore, denial of external dummy files where the agent asks before reading outside the project (Claude Code and OpenCode; Codex's workspace sandbox reads anywhere), approval persistence, cancellation during an executing shell tool, running the toolchain (Node, `npm install` over the network and Git), loading a staged Skill without approval, a planning turn that proposes a plan and changes no file, and a turn in the mode that asks nothing. Claude Code refuses a standalone `sleep`, so its cancellation step runs an equivalent `node` command. Earlier acceptance, before agents kept their own permission rules, passed on macOS with Claude Code 2.1.302 / `sonnet` and Codex 0.163.0 / `gpt-6-luna`. OpenCode 2.1.0 with `opencode/deepseek-v4.1-flash-free` passed the full live acceptance on macOS: file edits, direct app tools, native continuation and daemon restart, compaction, message revision, Undo, denied external reads, an approved Node/npm/Git toolchain command, cancellation, staged Skills without an approval, and structured read-only planning. Image request parameters and native effort selection are covered by protocol fixtures; this run did not send an image. Historical v1 acceptance used OpenCode 1.18.33 with `opencode/mimo-v2.6-flash-free` on macOS; that run does not establish v2 acceptance. In Claude's `-p` mode it has no `TodoWrite`, `Glob`, `Grep` or `LS` and searches with `Bash`, so planning turns run the read commands Claude Code allows without asking. Keep a runtime opt-in until real acceptance passes on the target platform; fixture success alone is insufficient. An optional final argument selects an absolute executable path, for example `bun run test:agent-runtimes:live codex-cli MODEL /absolute/path/to/codex`. The test continues other checks after a protected-read failure, saves each boundary failure and exits unsuccessfully. A missing denial record is not a persistence regression when the runtime never requested approval at all.