Skip to content

fix: align session and message API payloads with OpenCode schema#5

Open
AhmedB479 wants to merge 3 commits into
ssccio:mainfrom
AhmedB479:fix/session-and-message-api-payload
Open

fix: align session and message API payloads with OpenCode schema#5
AhmedB479 wants to merge 3 commits into
ssccio:mainfrom
AhmedB479:fix/session-and-message-api-payload

Conversation

@AhmedB479

@AhmedB479 AhmedB479 commented May 27, 2026

Copy link
Copy Markdown

Problem

Two API payload mismatches were causing 400 BadRequest errors when communicating with the OpenCode server.

Fix 1 — Session creation (POST /session)
The session endpoint expects id for the model identifier, but the node was sending modelID:

// Before (broken)
{ "model": { "providerID": "anthropic", "modelID": "claude-3-5-sonnet-20241022" } }

// After (fixed)
{ "model": { "providerID": "anthropic", "id": "claude-3-5-sonnet-20241022" } }

Fix 2 — Message sending (POST /session/{id}/message)
The message endpoint does not accept a model field — the session already knows its model. Sending it caused a 400 rejection:

// Before (broken)
{ "parts": [...], "model": { ... }, "agent": "chat" }

// After (fixed)
{ "parts": [...], "agent": "chat" }

Bonus fixes

  • Added jest.config.js with ts-jest preset so the test suite can actually run (it was broken out of the box due to missing Jest config)
  • Added !jest.config.js exception to .gitignore since *.js was swallowing it
  • Updated the session creation test assertion to expect the corrected id field

Test plan

  • npm run type-check passes
  • npm test passes

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