Skip to content

fix(instrumentation-utils): Add missing modality field to block mappers document cases#921

Merged
dvirski merged 3 commits intotraceloop:mainfrom
dvirski:fix(instrumentation-utils)-add-modality-field-document-blocks
Apr 6, 2026
Merged

fix(instrumentation-utils): Add missing modality field to block mappers document cases#921
dvirski merged 3 commits intotraceloop:mainfrom
dvirski:fix(instrumentation-utils)-add-modality-field-document-blocks

Conversation

@dvirski
Copy link
Copy Markdown
Contributor

@dvirski dvirski commented Apr 6, 2026

Summary by CodeRabbit

  • Improvements
    • Document content is now more consistently identified and handled across sources, improving reliability when uploading or referencing documents.
  • Tests
    • Test expectations and fixtures updated to reflect the consistent document classification.
  • Chores
    • Test fixtures and inline comments cleaned up for clarity and formatting.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

Warning

Rate limit exceeded

@dvirski has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 39 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 1 minutes and 39 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0029a70-0e37-432e-b57d-54680bf1540f

📥 Commits

Reviewing files that changed from the base of the PR and between e248a32 and ddb9a14.

📒 Files selected for processing (4)
  • packages/instrumentation-anthropic/test/content-block-mapper.test.ts
  • packages/instrumentation-anthropic/test/mapper-fixtures.json
  • packages/instrumentation-openai/test/message-helpers.test.ts
  • packages/instrumentation-utils/src/content-block-mappers.ts
📝 Walkthrough

Walkthrough

Anthropic and OpenAI content-block mappers were changed to always emit modality: "document" for document-related parts (blobs, URIs, file references). Tests and fixtures were updated to expect this field; inline comments were adjusted to note modality accepts arbitrary strings.

Changes

Cohort / File(s) Summary
Mapper Logic
packages/instrumentation-utils/src/content-block-mappers.ts
Anthropic and OpenAI mapping logic updated to include modality: "document" for document-related parts (blob/base64, uri with mime_type, file/file_id). Inline comments adjusted to state modality can be arbitrary strings and that these parts represent document content.
Anthropic Tests
packages/instrumentation-anthropic/test/content-block-mapper.test.ts
Updated expectations to assert modality: "document" for mapped document parts (blob, uri, file). Minor test description and assertion adjustments.
Anthropic Fixtures
packages/instrumentation-anthropic/test/mapper-fixtures.json
Fixtures expanded/rewrapped for readability; _comment text and temperature formatting adjusted; expected outputs now include modality: "document" for document inputs.
OpenAI Tests
packages/instrumentation-openai/test/message-helpers.test.ts
Updated expectations to include modality: "document" for OpenAI file/file_data mappings (file reference and inline blob).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through maps with joyful thrum,
Adding "document" to each little crumb,
Blobs and URIs and files in a row,
Now tidy and clear wherever they go,
A rabbit's stamp makes the mappings hum. 📄✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding the missing modality field to document cases in block mappers across both Anthropic and OpenAI instrumentation packages.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 `@packages/instrumentation-anthropic/test/content-block-mapper.test.ts`:
- Around line 213-220: Remove the stray semicolon that precedes the test
declaration so the test starts with the `it("document/file result has modality:
document", ...)` call; edit the test block containing `it("document/file result
has modality: document"...` (which uses `mapAnthropicContentBlock`) to delete
the leading `;` so the empty statement is removed and formatting/Prettier errors
are resolved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4ebc73ba-4e3c-4662-89fd-3668901cbd0c

📥 Commits

Reviewing files that changed from the base of the PR and between 9bcef8d and e248a32.

📒 Files selected for processing (3)
  • packages/instrumentation-anthropic/test/content-block-mapper.test.ts
  • packages/instrumentation-anthropic/test/mapper-fixtures.json
  • packages/instrumentation-openai/test/message-helpers.test.ts

@dvirski dvirski force-pushed the fix(instrumentation-utils)-add-modality-field-document-blocks branch from c96aee7 to ddb9a14 Compare April 6, 2026 11:56
@dvirski dvirski merged commit ed41ff2 into traceloop:main Apr 6, 2026
6 checks passed
@dvirski dvirski deleted the fix(instrumentation-utils)-add-modality-field-document-blocks branch April 6, 2026 11:59
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