Repository navigation
Description
Summary
Correction to the initial report: this is not a functional bug — session.prompt is documented neither to parse nor to dispatch slash commands, and it always stores text as a plain user message. To invoke a registered command such as /goal over the HTTP API, callers must use POST /api/session/{sessionID}/command. That endpoint works correctly and does set the goal.
The remaining problem is discoverability/documentation: session.prompt silently accepts /goal … as ordinary text, so an API caller who mirrors the TUI input style gets no effect and no warning. This was verified in both directions.
Environment
- opencode version: 2.3.2
- OS: Darwin 27.2.0 (darwin arm64)
- Terminal: TERM_PROGRAM=Apple_Terminal, TERM=xterm-256color, COLORTERM=truecolor
- Shell: /bin/zsh
- Install/channel: release v2.3.2 (managed background service,
opencode api get /api/info→ 2.3.2) - Active plugins: None found in config
Reproduction
- Create a session:
opencode api post /api/session --data '{"title":"repro","model":{"id":"hy4-flash-free","providerID":"opencode-go"},"location":{"directory":"/path/to/project"}}' - Confirm the command exists with
opencode api get /api/command— it lists{"name":"goal","description":"keep working until an objective is met [pause|resume|clear]"}. - Wrong endpoint — send the TUI form as prompt text:
The request succeeds; the message is stored as
opencode api post /api/session/<sessionID>/prompt --data '{"text":"/goal alle änderungen … ci grün"}'
type: "user"with the literal/goal …text anddelivery: "steer". No goal is set. - Correct endpoint — invoke the registered command:
The goal is set; the assistant immediately starts working on the objective.
opencode api post /api/session/<sessionID>/command --data '{"name":"goal","text":"alle änderungen … ci grün"}'
Expected Behavior
The API surface should make the split explicit: session.prompt = plain message, session.command = command invocation. Ideally the API docs (https://opencode.ai/docs/api) would call out that a leading /command in prompt is not parsed, so callers do not mirror TUI input via /prompt.
Actual Behavior
Both endpoints accept a text field. Nothing in the session.prompt OpenAPI schema (text, files, agents, skills, metadata, delivery, resume) hints that slash-command syntax is not interpreted. Sending /goal … via /prompt produces a stored user message with no effect and no warning.
Evidence that /command works (assistant reasoning from the verification session):
"The user's objective (in German): 'alle änderungen sind entweder explizit verworfen oder in origin merge gemergt, ci grün' — 'All changes are either explicitly discarded or merged into origin/main, CI green.' So I need to look at the git state of the repository…"
Additional Context
- Frequency: consistently reproducible.
- Suggested fix: add a note to the API docs for
POST /api/session/{sessionID}/promptstating that slash commands are not parsed there and thatPOST /api/session/{sessionID}/commandmust be used instead (withnameandtext). Optionally, reject or warn ontextstarting with/to surface the mistake. - Original title claimed a bug; corrected after verifying
session.commandsets the goal successfully.
Activity
opencodejr commentedon Nov 19, 2026
Thanks for the detailed write-up and for including the workaround.
As far as I can tell from the code, this is how the API is currently designed rather than a bug.
session.promptis described as admitting one session input and scheduling the agent loop. Slash commands have their own endpoint,session.command("Execute a slash command callback immediately."). The TUI detects the leading/goalitself and calls the command endpoint, which is why typing it there works. Plugin command executors also pass the user's text on tosession.prompt, so having that endpoint interpret slashes would be a behaviour change. Your request is either to letsession.promptroute a leading registered/commandthe way the TUI does, or to document clearly that it never does and point callers tosession.command. Maintainers will consider it.Until then,
POST /api/session/{sessionID}/commandwith{"name":"goal","text":"…"}, as you found, is the way to run commands over the API.Related issues:
opencode run "/cmd"sends the command as plain text instead of running it.[-]api: session.prompt treats "/goal …" as plain message instead of invoking slash command[/-][+]docs/api: clarify that session.prompt does not parse slash commands (use session.command for /goal)[/+]