fix: align OpenAI reasoning metadata handling with AI SDK#1017
fix: align OpenAI reasoning metadata handling with AI SDK#1017
Conversation
🦋 Changeset detectedLatest commit: f7fd0ef The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This comment has been minimized.
This comment has been minimized.
📝 WalkthroughWalkthroughThis patch updates OpenAI reasoning metadata handling in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying voltagent with
|
| Latest commit: |
f7fd0ef
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://49944eef.voltagent.pages.dev |
| Branch Preview URL: | https://fix-openai-reasoning-metadat.voltagent.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/core/src/agent/conversation-buffer.ts (1)
523-541: 🛠️ Refactor suggestion | 🟠 MajorReplace JSON.stringify with safeStringify at lines 526 and 540.
Lines 526 and 540 useJSON.stringifywhich can throw on cyclic references and violates the project guideline. UsesafeStringifyfrom@voltagent/internalinstead.🔧 Proposed fix
-import type { Logger } from "@voltagent/internal"; +import { safeStringify, type Logger } from "@voltagent/internal"; @@ - return `text:${part.text}:${JSON.stringify((part as any).providerMetadata ?? null)}`; + return `text:${part.text}:${safeStringify((part as any).providerMetadata ?? null)}`; @@ - return `${part.type}:${JSON.stringify(part)}`; + return `${part.type}:${safeStringify(part)}`;
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
What is the new behavior?
fixes (issue)
Notes for reviewers
Summary by cubic
Aligns OpenAI reasoning metadata handling with the AI SDK to prevent losing non-reasoning metadata and to keep distinct reasoning parts during merges. ConversationBuffer now includes the OpenAI reasoning itemId in part signatures, and the normalizer only strips reasoning-linked metadata when no reasoning context exists.
Written for commit f7fd0ef. Summary will update on new commits.
Summary by CodeRabbit