Repository navigation
fix(core): degrade malformed tool-result content instead of crashing prepare - #50776
twotimemonger wants to merge 2 commits into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
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:
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. |
Issue for this PR
Closes #50775
Type of change
What does this PR do?
unsupportedPartsandboundImagesassume everytool-resultwithresult.type === "content"has an arrayvalue. When one shows up without it, the.mapthrows out ofprepareand the whole session drain dies with it, leaving the session permanently stuck (every subsequent prompt hits the same part).This replaces such parts with a short text placeholder instead of throwing, and skips them in the image-byte accounting.
One thing worth calling out: just passing the part through doesn't work here, because
Message.makere-validates the message right after and throws on the schema violation anyway. Swapping in a valid text result is the only way I found that actually lets the turn continue.How did you verify your code works?
Added two tests in
packages/core/test/session-model-request.test.tsfeeding a malformed tool-result part (content result withvalue: undefined) through both functions; they used to throwTypeError: part.result.value.map is not a function, now they degrade to the placeholder.bun test test/session-model-request.test.tspasses (8/8, existing tests unaffected).Screenshots / recordings
Not a UI change.
Checklist