OpenCode
This extension lets Prompt Studio run OpenCode as an agent. You write the prompt in Prompt Studio, and OpenCode does the work in your project with the model provider you set up in OpenCode.
Prompt Studio calls this kind of extension a harness: it starts an agent program, sends it your prompts, and shows the conversation. Prompt Studio installs this extension by default.
Install and sign in
Prompt Studio installs a private OpenCode CLI with this extension. It uses an existing CLI on the runtime’s PATH first, then its private copy. You do not need a global Node.js installation or a separate terminal to set up the private CLI.
- Enable OpenCode in Settings → Project → Extensions.
- Open a chat and choose Sign in in the session background, or run
/login. - Choose your provider and sign-in method in the session background. Complete browser sign-in or enter the requested key or code.
- The session updates when the native CLI confirms sign-in. Choose a model and start chatting.
Cancelling sign-in stops its native worker. The CLI stores its own credentials; Prompt Studio does not copy them into extension settings. Installing the CLI does not sign you in automatically. The session background asks you to sign in and sending stays disabled when the native CLI reports that you are signed out. Use /logout to remove stored credentials; OpenCode asks which provider to disconnect. Credentials supplied by the runtime environment must be changed there. OpenCode lets you choose which model provider to connect.
Prompt Studio supports OpenCode 2.2.5 and newer. The extension bundles @opencode/cli 2.2.5. OpenCode 1 is no longer supported. An older CLI on PATH shows as unavailable with its version and the minimum required version. Update that CLI, or remove it from PATH to use the private installation. Private CLI versions update with the extension.
If you removed the extension, install it again from Settings → Project → Extensions or run pst extensions add harness-open-code.
Choose OpenCode
Prompt Studio shares one OpenCode server across projects that use this extension. It reconnects to its authenticated server while the runtime is running. If Prompt Studio starts the server, disabling the extension in its last active project or shutting down the runtime stops that server. Disabling one project stops its turns while other projects can keep working. Servers started outside Prompt Studio stay running.
Native command definitions are cached for up to 30 seconds per working directory and refreshed after a native command runs. An untouched new conversation does not keep polling command discovery.
- In a new session, open the model menu in the message box, switch the harness to OpenCode, and pick a model. Prompt Studio remembers your choice for the next session in the project. A session keeps its agent once it has started.
- To make it the project default, open Settings → Workbench → Runtime and choose it under Default model.
- Planner actions that start agent work, such as Run attempt, let you choose the agent in their form.
- From a terminal, pass its ID to
pst sessions create:
pst sessions create --prompt "Review this repository" \
--agent pstdio.harness-open-code.harness.opencode --model <model>
If neither CLI installation can run, OpenCode shows as unavailable in the model menu.
Models and thinking
The model menu lists enabled models from OpenCode 2’s native model catalog (opencode api GET /api/model --standalone). Add or remove providers in OpenCode to change the list.
The Thinking option picks the model’s thinking level: None, Minimal, Low, Medium, High, XHigh, or Max. The default is Medium. Each model offers only the levels it supports, and models without levels hide the option.
How it runs
- Prompt Studio talks to a local OpenCode server on
127.0.0.1. It starts an authenticated server withopencode serveon port 4096, and tries the next ports up to 4115 when a port is taken. - OpenCode works in the session’s folder. Prompt Studio does not change OpenCode’s permission settings, so your OpenCode configuration decides what it may do without asking.
- When OpenCode asks you a question, the session waits until you answer it in Prompt Studio. Choices keep OpenCode’s custom-answer setting, including its default Other option. Answers go to the selected question when several are pending.
- After Prompt Studio restarts, it can reconnect to an OpenCode session that is still running.
- Before a session starts in a new workspace, Prompt Studio copies the project’s skills into
.agents/skillsin that workspace. To add them to the project folder as well, runpst agents setup pstdio.harness-open-code.harness.opencode.
Account quotas
Run pst harness-open-code quotas to inspect native OpenCode Go quota windows and account budgets through api GET /api/experimental/usage/limits --standalone. Budget IDs use a budget. prefix so a budget named weekly, rolling, or monthly keeps its own chart and history. The command starts no agent turn. Provider accounts without limits in that endpoint return unavailable; it does not estimate subscription quotas from local token usage.
Restart after quota reset
In this extension’s settings, enable Restart after quota reset to resume conversations stopped by quota errors. The setting is off by default and applies only to this device. Sessions resumes the unchanged failed conversation 15 seconds after the latest exhausted quota window resets. It checks the preference and native quota again before continuing. Manual stops, archived conversations, changed runs and unrelated failures stay stopped. A running host is required; queued restarts survive host restart. Unknown reset times cannot schedule a restart.
Updated at: 2026-11-17