fix(translation): map anthropic metadata.user_id to Chat user - #553
fix(translation): map anthropic metadata.user_id to Chat user#553bgrins wants to merge 1 commit into
Conversation
Signed-off-by: Brian Grinstead <briangrinstead@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughThe OpenAI Chat request translator now maps metadata containing only ChangesMetadata translation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized metadata mapping preserves explicit user values and is covered by passing checks and tests; no actionable merge-blocking risk remains. Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
What
Translates Anthropic
metadata.user_idto Chat'suserfield in the openai_chat request codec instead of passingmetadatathrough untouched. Anthropic metadata is a different shape than Chat metadata (a string map attached to stored completions), and some endpoints reject the unknown shape. Other metadata objects continue to pass through.Why
Anthropic clients attach
metadata.user_idto requests, so pointing one at certain Chat upstreams through Switchyard fails on the first call:How tested
uv run ruff check .cleanuv run mypy switchyardcleanuv run pytest tests/greencargo fmt --all --checkclean;cargo clippy -p switchyard-translation --all-targets -- -D warningscleancargo test -p switchyard-translationgreen — 145 tests"user":"user_abc123", nometadata), returns a completion frombig-pickle. Have also tested long Claude Agent SDK -> Switchyard -> opencode sessions on a wheel built from this branch (without the fix every session dies on its first request).Checklist
snake_caseof the primary class. (Rust-only change)switchyard/__init__.py.__all__if intended for downstream use. (n/a)anthropic_openai_compatible_extensions_are_preserved_for_openai_chatnow asserts the mapping)--helpupdated if customer-facing surface changed. (n/a)Signed-off-by: Your Name <email>) per the DCO.Notes for reviewers
useris set withor_insert, so an explicituseralready on the request wins.Summary by CodeRabbit