Skip to content

bug: WorkBuddy and OpenCode report a missing Scope as a version mismatch #2321

Closed

Description

@Fengzdadi

Describe the bug

WorkBuddy and OpenCode report every HTTP 404 as version_mismatch. The Server returns 404 in two cases:

  • A route that does not exist returns an uncoded 404, {"detail":"Not Found"}. Only this case means that the plugin and the Server versions do not match.
  • A configured Scope that does not exist returns a coded 404, {"error":{"code":"scope_not_found",...}}. The Server returns it from POST /v1/scope-bindings/resolve, and also from /v1/context/prepare, /v1/sources/content, and /v1/memory/flush when the request names an unknown scope_id.

For a coded 404, the version-mismatch advice is wrong. The documented action for version_mismatch is to install the package and plugin from the same ref (for example, troubleshoot.md:402), and that does not help when the Scope itself is missing. The plugin contract also says that version_mismatch "MUST NOT be inferred from a direct resource lookup" (plugin-contract.md:34).

Where the mapping happens (master 0c1dfc28):

  • WorkBuddy hook. workbuddy_powercontext_hook.py:202 maps a Scope resolution 404 to version_mismatch, and :552-553 does the same for a prepare 404. The error code is lost before either mapping runs. ScopeBindingStatusError (scripts/workspace_scope.py:65-71, raised at :262) and _HttpStatusError (hook :99-102, raised at :490) keep only the status and never read the error body.
  • OpenCode statusline. src/tui.tsx:152-157 returns version_mismatch for any 404 and shows "PC version mismatch". This mapping applies to Scope resolution (scopeFailureOutcome) and to get_stats (statsFailureOutcome). The code is already available: ServerResponseError.code (src/errors.ts:55-66) holds error.code from the body, but httpOutcome reads only the status. In the get_stats path, src/invoke.ts:74 gives an uncoded 404 the fallback code not_found, so ToolResult.code alone cannot tell the two cases apart.

The other hosts already classify a 404 by its error code. Pi, OpenClaw, DSH, and Hermes report version_mismatch only for an uncoded 404 from a compatibility or availability path (isVersionMismatch / COMPATIBILITY_OR_AVAILABILITY_PATHS). Kimi Code and ZCode map 404 to not_found, never to version_mismatch. Claude Code and Codex treat a 404 from Scope resolution the same way, and #2317 fixes that.

Steps to reproduce

  1. Start a Server from master with the default settings (loopback, authentication off).
  2. Set a Scope ID that does not exist: POWERCONTEXT_WORKBUDDY_SCOPE_ID=scp_missing for WorkBuddy, or POWERCONTEXT_OPENCODE_SCOPE_ID=scp_missing for OpenCode.
  3. WorkBuddy: submit a prompt. OpenCode: open the TUI and look at the statusline.

To see the two response shapes directly (with authentication on, add the Authorization header to both requests):

curl -s -X POST http://127.0.0.1:8000/v1/scope-bindings/resolve -H 'content-type: application/json' -d '{"explicit_scope_id":"scp_missing"}'
# 404 {"error":{"code":"scope_not_found","message":"The requested Scope was not found.","details":null}}
curl -s -X POST http://127.0.0.1:8000/v1/no-such-route
# 404 {"detail":"Not Found"}

Expected behavior

Only a 404 without an error code is reported as version_mismatch. A coded 404 such as scope_not_found is reported as invalid_response and carries its status and code, the same classification that #2317 applies to Claude Code and Codex.

Actual behavior

Observed with both hosts' master code against a master Server:

  • WorkBuddy writes {"component":"powercontext.workbuddy.recall","event":"context_prepare","outcome":"version_mismatch","http_status":404} to stderr.
  • The OpenCode statusline shows "PC version mismatch".

Proposed fix

Classify a 404 by its error code, as #2317 does. Do not change the Server.

  • WorkBuddy. Read error.code from the body of an error response in both workspace_scope.py and _post_json, and keep it on ScopeBindingStatusError and _HttpStatusError. Map only a 404 without a code to version_mismatch; any other 404 becomes invalid_response. Add error_code to the diagnostic event when the code is present. A code is not content, so the event stays content-free.
  • OpenCode. Pass the error code into httpOutcome, using ServerResponseError.code for Scope resolution. For get_stats, carry the Server's code separately from the not_found fallback, or check error.code before errorResult rewrites it.
  • Docs and tests. Update the WorkBuddy failure table in both locales (workbuddy.md:291). The OpenCode test tests/tui.spec.tsx:265 currently expects "PC version mismatch" for a coded 404 ({"error":{"code":"failure"}}), so it has to change. Add a test for a coded 404 and for an uncoded 404 in each host.

In step 4 of #2250, WorkBuddy moves onto the Python lifecycle module and OpenCode onto the TypeScript one. That plan does not allow a move to change behavior, so this fix lands before the move, as #2317 does for Claude Code and Codex.

Environment

  • PowerContext version: master 0c1dfc28
  • Hosts: WorkBuddy, OpenCode

Related: #2317 (the same fix for Claude Code and Codex), #2250 (lifecycle plan).

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.

Activity

  1. moved this from Todo to In progress in PowerContexton Oct 31, 2026
  2. added a commit that references this issue on Oct 31, 2026
    58e74ab
  3. moved this from In progress to Done in PowerContexton Nov 3, 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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions