Skip to content

fix: pass embedding providerMetadata to usageHandler - #393

Merged
robelest merged 2 commits into
convex:mainfrom
awpogodin:fix/embedding-usage-provider-metadata
Oct 20, 2026
Merged

robelest merged 2 commits into
convex:mainfrom
awpogodin:fix/embedding-usage-provider-metadata

Conversation

@awpogodin

Copy link
Copy Markdown
Contributor

embedMany calls usageHandler with providerMetadata: undefined for embeddings, although the AI SDK embedMany result carries the provider's metadata. Data the provider reports for the call — for example its cost, which some providers return in providerMetadata — is lost, so usage tracking for embeddings can only count tokens.

This passes result.providerMetadata through, the same way it is already passed for language model steps.

  • src/vercel/client/search.ts: providerMetadata: result.providerMetadata
  • src/vercel/client/search.test.ts: a test with MockEmbeddingModelV4 that checks the usage handler receives the metadata
  • CHANGELOG.md: entry under Unreleased

Verified with npm run build, npm run typecheck, npm run lint and npm test (415 tests).

🤖 Generated with Claude Code

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

Copy link
Copy Markdown

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

Re-trigger cubic

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: convex/coderabbit/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 04c856af-1fbc-4c2f-969f-5af7c4586993
📥 Commits

Reviewing files that changed from the base of the PR and between 7a4f06e and ff998d0.

📒 Files selected for processing: 3
  • CHANGELOG.md
  • src/vercel/client/search.test.ts
  • src/vercel/client/search.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: get-convex/coderabbit/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f89a1f6f-248a-4838-a3ec-59cbfa4caf61
📥 Commits

Reviewing files that changed from the base of the PR and between ced1068 and 7a4f06e.

📒 Files selected for processing (1)
  • src/vercel/client/search.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📝 Walkthrough

embedMany now passes the embedding result’s provider metadata to the usage handler. A new test checks that the handler receives the model ID, provider metadata, and input-token usage.

Suggested reviewers: robelest

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 7a4f0

Embedding usage reporting now forwards provider metadata, with a regression test checking that it reaches the handler. No material merge risk is evident.

Security architecture risk: ⚪ Minimal · up to 25a96

The change populates an existing usage-report field without changing callback authority, user or thread identity, or embedding storage behavior. No material security risk was identified in the changed library path.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed exposure is the additional provider-origin data delivered to applications with embedding usage reporting configured. The helper adds no new caller, callback authority, direct persistence sink, or identity scope. Downstream behavior of application-supplied handlers remains outside the available source evidence.

Trust Boundaries and Controls

  • observed — Provider metadata crosses into the preconfigured usage callback as a separate data field. Within embedMany it does not select or override the callback context, user, thread, agent, model, or provider. The existing language-model reporting path provides counterevidence against this being a new metadata trust boundary.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: passing embedding provider metadata to the usage handler.
Description check ✅ Passed The description explains the metadata loss, the code and test changes, and the reported verification. It is directly related to the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@awpogodin
awpogodin force-pushed the fix/embedding-usage-provider-metadata branch 2 times, most recently from ced1068 to 7a4f06e Compare October 7, 2026 08:14
robelest added a commit to awpogodin/agent that referenced this pull request Oct 20, 2026

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

Copy link
Copy Markdown

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

Re-trigger cubic

@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@convex-dev/agent@393

commit: ff998d0

@robelest
robelest force-pushed the fix/embedding-usage-provider-metadata branch from 6503999 to 7a4f06e Compare October 20, 2026 02:30
awpogodin and others added 2 commits October 19, 2026 22:30
embedMany called the usage handler with `providerMetadata: undefined`,
dropping what the embedding provider reported, such as the call's cost,
although the AI SDK result carries it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robelest
robelest force-pushed the fix/embedding-usage-provider-metadata branch from 7a4f06e to ff998d0 Compare October 20, 2026 02:31
@robelest
robelest merged commit eda442d into convex:main Oct 20, 2026
4 checks passed
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.

2 participants