Skip to content

Conversation

@omeraplak
Copy link
Member

@omeraplak omeraplak commented Feb 10, 2026

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

Deduplicates conversation step rows by id before Supabase upsert to prevent Postgres conflict errors. Preserves last-write-wins behavior for steps.

  • Bug Fixes
    • Deduplicate by id in saveConversationSteps; upsert receives one row per id (latest wins).
    • Upsert continues with onConflict: "id" and ignoreDuplicates: false.
    • Added a test to confirm only the latest duplicate is persisted and a single upsert occurs.

Written for commit 7936e41. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where storing multiple conversation steps with the same identifier in a single batch would cause database errors. The system now properly deduplicates entries while maintaining the last-write-wins behavior, ensuring reliable persistence of conversation data.

@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: 7936e41

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@voltagent/supabase Patch

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

@joggrbot

This comment has been minimized.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

This change fixes a behavioral issue where multiple conversation steps with identical IDs in a single persistence batch caused Postgres ON CONFLICT errors. The solution deduplicates step records by ID before upserting to Supabase, retaining only the last record per ID and preserving last-write-wins semantics.

Changes

Cohort / File(s) Summary
Changelog
.changeset/odd-ants-guess.md
Documents patch-level update noting the behavioral fix for conversation step persistence and deduplication logic.
Memory Adapter Implementation
packages/supabase/src/memory-adapter.ts
Adds deduplication logic in saveConversationSteps using a Map to retain only the last row per ID; emits debug log when rows are removed.
Memory Adapter Tests
packages/supabase/src/memory-adapter.spec.ts
Introduces type import for ConversationStepRecord and adds a new "Conversation Step Operations" test suite verifying deduplication behavior; test suite appears duplicated within the file.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A hop through dedup land, where step IDs align,
No more Postgres conflicts when records combine,
The last-write-wins hops on with grace,
Batches cleaned up—no duplicates to face! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description includes most required sections with an auto-generated summary, but the 'What is the current behavior?' and 'What is the new behavior?' sections are empty, and the 'fixes (issue)' reference is incomplete. Fill in the current and new behavior sections with specific details, and replace the 'fixes (issue)' placeholder with the actual issue number or link.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: deduplicating conversation step rows before Supabase upsert, which directly addresses the Postgres conflict error prevention.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/supabase-conversation-step

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
packages/supabase/src/memory-adapter.spec.ts (1)

365-413: Good test coverage for the deduplication path.

The test correctly validates last-write-wins semantics by asserting that only the second (tool_result) row survives deduplication, and that upsert options are set correctly.

Consider adding a companion test for the no-duplicate path (all unique IDs) to confirm that rows pass through unchanged and no debug log is emitted.

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

@cloudflare-workers-and-pages
Copy link

Deploying voltagent with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7936e41
Status: ✅  Deploy successful!
Preview URL: https://d8af86bb.voltagent.pages.dev
Branch Preview URL: https://fix-supabase-conversation-st.voltagent.pages.dev

View logs

@omeraplak omeraplak merged commit 9757223 into main Feb 10, 2026
23 checks passed
@omeraplak omeraplak deleted the fix/supabase-conversation-step branch February 10, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant