Skip to content

Slash commands (/ctx-*) fail in OpenCode web mode due to sentinel error pattern #1

Description

@RobinVivant

Description

The /ctx-* slash commands (ctx-status, ctx-recomp, ctx-aug, ctx-dream, ctx-flush) fail when OpenCode is running in web mode (opencode web --port <port>). The commands execute their logic and send a toast via /tui/show-toast, but the sentinel error they throw to prevent LLM forwarding causes the web server to report a failure to the browser UI.

Environment

  • OpenCode: web mode (opencode web --port 3456 --hostname 127.0.0.1)
  • Magic Context: @cortexkit/opencode-magic-context@0.7.3
  • OS: Ubuntu (cloud VM, headless)

Steps to Reproduce

  1. Run OpenCode in web mode: opencode web --port 3456
  2. Open a session in the browser
  3. Run any /ctx-* command (e.g. /ctx-status, /ctx-aug, /ctx-recomp)
  4. Command appears to fail in the UI

Expected Behavior

Commands should execute and display their output in the web UI, same as in TUI mode.

Actual Behavior

The web server catches the sentinel error (e.g. __CONTEXT_MANAGEMENT_CTX-AUG_HANDLED__) and returns a failed status. The toast sent to /tui/show-toast doesn't render in the web client.

From OpenCode logs:

INFO service=session.prompt command=ctx-aug parts=[] sessionID=ses_xxx command
ERROR service=server error=__CONTEXT_MANAGEMENT_CTX-AUG_HANDLED__ failed
INFO service=session.prompt command=ctx-recomp parts=[] sessionID=ses_xxx command
ERROR service=server error=__CONTEXT_MANAGEMENT_CTX-RECOMP_HANDLED__ failed

The toast request fires but targets the TUI endpoint:

INFO service=server method=POST path=/tui/show-toast request

Notes

  • The agent tools (ctx_reduce, ctx_expand, ctx_note, ctx_memory, ctx_search) work perfectly in web mode - only the slash commands are affected.
  • The sentinel error pattern works in TUI mode because the TUI swallows the error and renders the toast inline.
  • Web mode doesn't have a toast renderer, so the command output is lost and only the error surfaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions