Skip to content

Coach: retry compatible jobs through the Responses API on protocol 400 - #387

Open
janviernine wants to merge 4 commits into
DuarteSantos8:mainfrom
janviernine:feat/coach-responses-fallback
Open

janviernine wants to merge 4 commits into
DuarteSantos8:mainfrom
janviernine:feat/coach-responses-fallback

Conversation

@janviernine

Copy link
Copy Markdown

Includes #386's commits — merge that first, or review stacked; the new work is the top commit only (58ef043).

Some gateways serve a model ONLY at /v1/responses: opencode Go's muse-spark-*-contributor answers the Chat shape with 400 Model does not support this protocol (verified live). This retries once through a Responses shape, inside one invoke:

  • New api/coach/core/adapters/responses.js: input array (shared system prompt + user prompt), json_schema text format, output_text parsing with refusal-as-error and max-output truncation, same contract as openai.js.
  • Transport (http.js): the invoke loop now works through an active shape; on exactly that 400 it swaps shape and re-POSTs once. Extra headers ride along untouched. List models and check are unaffected.
  • Wire-up (compatible.js only — minimal blast radius): spec.responsesFallback.
  • Docs: two lines in docs/AI_COACH.md.

Tests: retry fires once on the protocol 400 (URL, input shape, schema format, headers on both calls); any other 400 stays final; refusals read as errors; truncation fails as provider. File suite: 24/24 green; repo-wide baselines match the clean tree (pre-existing failures disclosed in #386).

…ntos8#385)

Gateways that demand routing/session headers (opencode Go's
x-opencode-session) 400 every call without them. Adds an optional
headers map to the compatible endpoint config: validated at write
(max 8, token names, auth/transport names refused), merged under
auth framing at send time on models, check, test and jobs.

Admin card gains an Extra headers field (Name: value lines, empty
clears); docs/AI_COACH.md notes it. Tests: wire-level adapter
assertions, route accept/refuse/clear, textarea parse helpers.
Some gateways serve a model ONLY at /v1/responses (opencode Go's
muse-spark-*-contributor answers the Chat shape with 400 Model does
not support this protocol). The compatible adapter now retries once
through a Responses shape: input array, json_schema text format,
output_text parsing with refusal/truncation handling. Extra headers
ride along on the second shape, so gateway routing still applies.
List models is untouched.

This branch has not been deployed

No deployments
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