Skip to content

fix(session): encode persisted output formats#37541

Open
edwardgushchin wants to merge 1 commit into
anomalyco:devfrom
edwardgushchin:output-format-encoding
Open

fix(session): encode persisted output formats#37541
edwardgushchin wants to merge 1 commit into
anomalyco:devfrom
edwardgushchin:output-format-encoding

Conversation

@edwardgushchin

@edwardgushchin edwardgushchin commented Jul 17, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #26929

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Persisted V1 messages hydrate output formats as plain objects. The response encoder previously used Schema.Class, which requires class instances and returned HTTP 400 when history contained either a text or json_schema format.

This changes those two wire schemas to Schema.Struct, preserving the JSON shape while allowing persisted plain objects to encode. It also adds an endpoint regression test that saves both formats, reloads them through the database, and reads them through GET /session/:id/message.

This supersedes the encoding portion of #29632. Credit to @trevorWieland for the original diagnosis and fix.

How did you verify your code works?

  • bun test --timeout 60000 test/server/session-messages.test.ts in packages/opencode — 6 passed
  • bun typecheck in packages/opencode
  • bun typecheck in packages/schema
  • Focused oxlint and Prettier checks
  • Built the Windows x64 executable and verified a live save/read round trip for both output formats

The repo-wide pre-push typecheck cannot complete in this Windows checkout because the existing packages/enterprise/src/custom-elements.d.ts symlink is checked out as literal text; both changed packages typecheck successfully.

Screenshots / recordings

Not applicable; this is an HTTP response-encoding fix with no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

GET /session/:id/message returns 400 when messages contain format with inline JSON schema

1 participant