Skip to content

Coach: extra static headers for OpenAI-compatible endpoints - #386

Merged
DuarteSantos8 merged 1 commit into
DuarteSantos8:mainfrom
janviernine:feat/compatible-custom-headers
Oct 9, 2026
Merged

DuarteSantos8 merged 1 commit into
DuarteSantos8:mainfrom
janviernine:feat/compatible-custom-headers

Conversation

@janviernine

Copy link
Copy Markdown
Contributor

Closes #385.

Some OpenAI-compatible gateways refuse every call without extra headers — opencode Go 400s without x-opencode-session (docs). This adds an optional headers map to the compatible endpoint config:

  • Write path (api/coach/routes.js + validateHeaders in api/coach/core/providers.js): max 8 entries, token-shaped names, values ≤500 chars; authorization/content-type/host and friends refused. Stored plaintext next to baseUrl (routing aids, not credentials); empty clears. Same fixed-endpoint gate as baseUrl; combined baseUrl+headers POST keeps both.
  • Send path (api/coach/core/adapters/http.js): merged under auth framing on models, check, test and job calls; reserved names re-filtered at send time so a stored map can never override auth.
  • UI: Extra headers field on the Endpoint step (Name: value lines, parsed client-side, empty clears).
  • Docs: one paragraph in docs/AI_COACH.md.

Tests: wire-level adapter assertions (headers ride on models+invoke, auth wins over a smuggled map), route accept/refuse/clear+persist, textarea parse round-trip. All green; full-file suites match clean-tree baselines exactly (the 1 routes + 16 jobs/coach failures reproduce on unmodified main — pre-existing/environmental).

Out of scope: Responses-API protocol support — separate feature.

…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.
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.

Compatible endpoint: allow custom static headers (e.g. opencode Go's x-opencode-session)

2 participants