fix: convert media content to provider format before recording - #18
fix: convert media content to provider format before recording#18callingmedic911 wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughBoundPrompt.format now post-processes prepared messages to convert internal media content_part_type objects into provider-formatted objects by re-invoking the LLM adapter; package version bumped to 0.6.2 and tests updated/added to assert provider-formatted media in recorded messages. Changes
Sequence Diagram(s)sequenceDiagram
participant BoundPrompt
participant PrepareMessages
participant LLMAdapter
participant Provider
BoundPrompt->>PrepareMessages: prepareMessages(prompt, boundValues)
PrepareMessages-->>BoundPrompt: preparedMessages (may contain content_part_type)
alt contains content_part_type
BoundPrompt->>LLMAdapter: format([singlePreparedMessage])
LLMAdapter->>Provider: emit provider-formatted content
Provider-->>LLMAdapter: provider-formatted blocks
LLMAdapter-->>BoundPrompt: formattedMessageArray
BoundPrompt->>BoundPrompt: replace original message with first formatted block
end
BoundPrompt-->>Client: allMessages (provider-formatted)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip CodeRabbit can approve the review once all CodeRabbit's comments are resolved.Enable the |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/resources/prompts.ts`:
- Around line 495-498: The predicate that checks for "content_part_type" can
throw if msg.content contains primitives; update the Array.isArray(msg.content)
&& msg.content.some(...) check to first guard each element (the part variable)
is a non-null object before using the in operator—e.g. ensure typeof part ===
"object" && part !== null && "content_part_type" in part inside the callback
used by msg.content.some so primitives and nulls are skipped safely.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6b9f463c-6d6a-4f27-a56a-867c0eee46ef
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
CHANGELOG.mdpackage.jsonsrc/resources/prompts.tstest/resources/prompts.test.tstest/sdk.test.ts
Summary
bind()contain internal content objects (content_part_type: "text","media_base64", etc.) that aren't in any provider format the backend accepts.allMessages()returned these raw messages, causing recording API validation failures for prompts with media inputs.format(), media messages are now re-run through the adapter individually to produce provider-formatted content while preserving messages the adapter would otherwise drop (e.g. system for Responses API).Test plan
media messages in allMessages have provider formatverifies no internal fields leak and content blocks have propertypediscriminatorsHandles images for OpenAItest updated to expect provider formatSummary by CodeRabbit
Bug Fixes
Tests