Repository navigation
Conversation
Signed-off-by: Brian Grinstead <[email protected]>
|
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 |
| .or_insert_with(|| value.clone()); | ||
| } | ||
| } | ||
| match extensions.get("metadata") { |
There was a problem hiding this comment.
I think this is a little risky because this extension map has already lost its source format. It could have come from Anthropic, Responses, or Chat, so metadata: {"user_id": ...} doesn’t necessarily mean Anthropic metadata.
There was a problem hiding this comment.
Do you think this should be done in a different place or have some other kind of conditional guard? It's a good point to at least fix the comments here, as the endpoint doesn't care what sort of metadata this is coming from (it just throws an error when you pass user_id).
There was a problem hiding this comment.
Actually, going to close this PR for now given #553 (comment). If you see this come up in practice feel free to reopen / update.
|
Huh, the original error I was seeing is now gone, so it seems like the provider has just added support for passing user_id in metadata. I don't know if there are others that still have the behavior from last week, but I don't think it's justified to land this anymore unless if there's evidence of requests failing in the wild. |
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