Skip to content

OpenRouter: GA client.responses is not traced by wrap_openrouter(), and client.beta.responses is not auto-instrumented #860

Description

In current openrouter releases (1.2.32 and 1.3.22), client.responses is the GA openrouter.responses.Responses, while client.beta.responses is a separate, deprecated openrouter.beta_responses.BetaResponses.

  • wrap_openrouter() in py/src/braintrust/integrations/openrouter/tracing.py only wraps client.beta.responses, so GA client.responses.send / send_async calls are never traced on wrapped clients.
  • auto_instrument() patches the GA Responses class but not BetaResponses, so client.beta.responses.send is never traced there.

Fix

  • In py/src/braintrust/integrations/openrouter/patchers.py, add patchers for BetaResponses.send / send_async, applied only when openrouter.beta_responses exists (so 0.6.0 keeps working).
  • Make wrap_openrouter() also wrap client.responses.
  • Add a cassette-backed client.responses.send test, and a Responses check in test_auto_openrouter.py (it only covers chat today).
  • Optional: add the new alignment field to _RESPONSES_RESPONSE_KEYS.

Parent: #858 (found while reviewing the 2026-10-05 weekly dependency update, #849).

🤖 Generated with Claude Code

Metadata

Metadata

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions