Skip to content

docs/api: clarify that session.prompt does not parse slash commands (use session.command for /goal) #64995

Description

@reisi007

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

  1. Create a session:
    opencode api post /api/session --data '{"title":"repro","model":{"id":"hy4-flash-free","providerID":"opencode-go"},"location":{"directory":"/path/to/project"}}'
  2. 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]"}.
  3. Wrong endpoint — send the TUI form as prompt text:
    opencode api post /api/session/<sessionID>/prompt --data '{"text":"/goal alle änderungen … ci grün"}'
    The request succeeds; the message is stored as type: "user" with the literal /goal … text and delivery: "steer". No goal is set.
  4. Correct endpoint — invoke the registered command:
    opencode api post /api/session/<sessionID>/command --data '{"name":"goal","text":"alle änderungen … ci grün"}'
    The goal is set; the assistant immediately starts working on the objective.

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}/prompt stating that slash commands are not parsed there and that POST /api/session/{sessionID}/command must be used instead (with name and text). Optionally, reject or warn on text starting with / to surface the mistake.
  • Original title claimed a bug; corrected after verifying session.command sets the goal successfully.

Activity

  1. opencodejr commented on Nov 19, 2026

    @opencodejr
    Contributor

    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.prompt is 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 /goal itself and calls the command endpoint, which is why typing it there works. Plugin command executors also pass the user's text on to session.prompt, so having that endpoint interpret slashes would be a behaviour change. Your request is either to let session.prompt route a leading registered /command the way the TUI does, or to document clearly that it never does and point callers to session.command. Maintainers will consider it.

    Until then, POST /api/session/{sessionID}/command with {"name":"goal","text":"…"}, as you found, is the way to run commands over the API.

    Related issues:

  2. added
    area/sdk-api
    type/feature
    version/v2
    on Nov 19, 2026
  3. changed the title [-]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)[/+] on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/sdk-apiplatform/macostype/featureversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions