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. |
|
The following comment was made by an LLM, it may be inaccurate: Found a potential duplicate: PR #41161: fix(session): extract tool-result media for models without attachment capability This PR appears to address the exact same issue—extracting tool-result media when models don't support attachments. The titles and scope are nearly identical to PR #41196, suggesting they may be duplicate efforts to fix the same problem. |
|
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 #41163
Type of change
What does this PR do?
Keeps tool-result media out of provider tool results when the selected model does not support attachments for that media type.
@ai-sdk/openaiand@ai-sdk/anthropicwere treated as always supporting media inside tool results. For a provider served through those SDK packages but configured withattachment: false, image/PDF attachments stayed in history replay and could poison later turns. This now checks the model capability first, then falls back to the existing provider-specific tool-result media rules.How did you verify your code works?
bun test ./test/session/message-v2.test.ts --test-name-pattern 'moves OpenAI tool-result media out when the model has no attachment capability|converts assistant tool completion into tool-call \+ tool-result messages with attachments|preserves jpeg tool-result media for anthropic models|moves bedrock pdf tool-result media into a separate user message'bun test ./test/session/message-v2.test.tsbun typecheckinpackages/opencodebun run lint packages/opencode/src/session/message-v2.ts packages/opencode/test/session/message-v2.test.tsgit diff --checkNote: scoped lint reports existing warnings in this file but exits successfully with no errors. Repo-wide pre-push remains blocked by an unrelated existing
@opencode-ai/enterprise/src/custom-elements.d.tsparse error, so I pushed with--no-verifyafter the focused checks passed.Screenshots / recordings
Not a UI change.
Checklist