Skip to content

fix: route muse-spark to /v1/responses (Zen requires Responses API) - #2

Open
ConTresillo wants to merge 1 commit into
12errh:mainfrom
ConTresillo:fix/muse-spark-responses-routing
Open

ConTresillo wants to merge 1 commit into
12errh:mainfrom
ConTresillo:fix/muse-spark-responses-routing

Conversation

@ConTresillo

Copy link
Copy Markdown

Fixes Muse Spark always showing as flaky / Test ✕ in the dashboard.

Root cause: Upstream Zen moved muse-spark-1.2/1.3-contributor-free to the Responses API. POST /zen/v1/chat/completions now returns 500 {"type":"error","message":"Internal server error"} for those IDs (repro 100%, issues #44659 #44847 #45744), while POST /zen/v1/responses with {"input":"hi"}\ returns 200. Docs at https://opencode.ai/docs/zen now list Spark under /v1/responses. Zen-proxy previously always hit /chat/completions, so Spark was bucketed as flaky and dashboard Test never succeeded even though the model is healthy.

Validated that the local \opencode serve\ path (\C:\DevLearning\opencode-as-cloudllm\ gateway via \POST /session\ -> /session/:id/message) still works for Spark — this is why the same model works in that project but not via zen-proxy's remote Zen path. Direct upstream probing confirms: \muse-spark-*\ -> 500 on chat, 200 on responses;
emotron-3.5\ intermittent timeout; \deepseek-v4-flash-free\ -> 400 model unavailable.

Fix:

  • Route /muse-spark/i\ models to \POST {upstream}/responses\ with \chatMessagesToInput()\ translation and back-translation via
    esponsesOutputToText()\ -> OpenAI \chat.completion\ shape (so existing /v1/chat/completions\ clients keep working).
  • Ignore tiny \max_tokens\ for Responses models. Spark uses ~900 reasoning tokens for a trivial prompt; forwarding \max_output_tokens:5\ truncates to empty \output_text. Only forward when >=256.
  • Apply same routing to auto-sync probing and /api/test, so sync now marks Spark as \working\ instead of \ laky.

Verified:

  • After fix, \GET /api/status\ working list includes both Spark variants (before: 3 working / 5 flaky).
  • \POST /v1/chat/completions\ with \model=muse-spark-1.2-contributor-free\ -> 200 \Hello there, it's lovely to meet you!\ via zen-proxy (previously 500).
  • \model=muse-spark-1.3-contributor-free\ -> 200 as well.

muse-spark-1.2/1.3-contributor-free now return 500 on
POST /zen/v1/chat/completions and 200 on POST /zen/v1/responses
per opencode.ai/docs/zen (issues #44659, #44847, #45744).
Previously zen-proxy always hit /chat/completions, so Spark was
bucketed as flaky and dashboard Test never succeeded.

- Route /muse-spark/i models to /responses with chat->input
  translation (chatMessagesToInput) and back-translation
  (responsesOutputToText -> chat.completion shape)
- Ignore tiny max_tokens (<256) for Responses models; Spark uses
  ~900 reasoning tokens for a trivial prompt and truncates to
  empty output_text when max_output_tokens is small
- Probe and /api/test also use the correct endpoint, so
  auto-sync now marks Spark as working instead of flaky
- Verified via zen-proxy: POST /v1/chat/completions with
  model=muse-spark-1.2/1.3-contributor-free -> 200 with text,
  and sync working list now includes both Spark variants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant