fix(anthropic): prevent NOT_GIVEN sentinel leak in tools event guard#4290
fix(anthropic): prevent NOT_GIVEN sentinel leak in tools event guard#4290cschanhniem wants to merge 1 commit into
Conversation
The tools guard in emit_input_events() used which lets
the Anthropic SDK's sentinel through when tools is omitted.
This matches ANTHROPIC_NOT_GIVEN which is not None, causing the sentinel
to be placed in the MessageEvent body as {tools: NOT_GIVEN}. The OTLP
log exporter then fails to encode the unrepresentable type, dropping the
entire batch.
The branch immediately above uses a truthiness check which
correctly drops NOT_GIVEN (bool(NOT_GIVEN) is False). This fix aligns
the tools guard with that pattern. NOT_GIVEN and empty lists are both
falsy, so the event is correctly skipped in both cases.
Fixes traceloop#4230
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIn ChangesFix NOT_GIVEN sentinel leak in tools event emission
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
|
|
|
Just saw the CLA check — will sign the CLA now so this can move forward. |
Fixes #4230
The tools guard in
emit_input_events()usedis not Nonewhich lets the Anthropic SDK'sNOT_GIVENsentinel through whentoolsis omitted.NOT_GIVENsatisfiesis not None, causing it to be placed in the MessageEvent body as{"tools": NOT_GIVEN}. The OTLP log exporter then fails to encode the unrepresentable type with:This drops the entire log batch and produces recurring traceback noise.
The
systembranch immediately above uses a truthiness check which correctly dropsNOT_GIVEN(bool(NOT_GIVEN)isFalse). This fix aligns thetoolsguard with that pattern.NOT_GIVENand empty lists are both falsy, so the event is correctly skipped in both cases.Change:
if kwargs.get("tools") is not None:→if kwargs.get("tools"):Summary by CodeRabbit