Skip to content

fix(session): coerce legacy string tool-part input - #44705

Closed
LovePlayCode wants to merge 3 commits into
anomalyco:devfrom
LovePlayCode:tool-input-migration
Closed

LovePlayCode wants to merge 3 commits into
anomalyco:devfrom
LovePlayCode:tool-input-migration

Conversation

@LovePlayCode

Copy link
Copy Markdown

Issue for this PR

Closes #44688

Type of change

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

What does this PR do?

1.14 stored some tool-part state.input values as JSON strings. 1.18 encodes messages with Schema.Record, so GET /session/:id/message 400s the whole transcript.

Hydrate now parses those strings (invalid JSON / non-objects become {}). A data migration rewrites the stored part rows the same way.

How did you verify your code works?

  • bun typecheck in packages/core and packages/opencode
  • bun test test/session/message-v2.test.ts in packages/opencode (hydrate + HTTP encode)
  • bun test test/database-migration.test.ts in packages/core (SQL backfill)

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

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

Made with Cursor

Upgrades from 1.14 stored tool state.input as a JSON string, which made GET /session/:id/message fail schema encode for the whole transcript.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

PR #44535 - fix(session): stop creating phantom "unknown" tool parts on re-emitted deltas
#44535

This PR is related because it also addresses tool-part handling in sessions, though it focuses on preventing creation of phantom tool parts rather than coercing legacy string inputs.

The other PRs found (like #37541 and #41830) address broader session message encoding and structure, but are less directly related to the specific legacy string coercion issue that PR #44705 is fixing.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing data migration for tool-part state.input on upgrade 1.14.28 → 1.18.18

1 participant