Deduplicate logic for getting request model in `openai-agents`
Remove duplication between
https://github.com/getsentry/sentry-python/blob/53188b322fc96dab0c4b064945b62e773fada63c/sentry_sdk/integrations/openai_agents/spans/ai_client.py#L26-L29
and
https://github.com/getsentry/sentry-python/blob/53188b322fc96dab0c4b064945b62e773fada63c/sentry_sdk/integrations/openai_agents/utils.py#L59-L62
Agentic systems are turning into always-on factories: one request fans out into model calls, tool calls, policy checks, and storage.
The hard part is rarely tokens/sec — it is control-plane reliability:
- Fan-out control — hard cap on tools/steps per request before external writes
- Durable id + idempotency — one write per business object (ledger / preflight)
- Observable long jobs — progress + cooperative cancel on multi-minute runs
- Expected vs actual — durable artifact id before marking success
- Policy before action — gate that can refuse known-bad side effects
If you share one sanitized failing run (expected vs actual + tool result), I can map which pillar is broken. Architecture only.
Hi! I'd be happy to take this one.
It looks like the model lookup can be moved into a small helper in utils.py and reused by both call sites, while keeping the current precedence between agent.model and _sentry_request_model.
I'll run the OpenAI Agents integration tests and add coverage if the existing tests don't exercise both paths. Does that sound good?
Hi — interested in taking this if it’s still free. Plan: extract the duplicated agent/request model resolution from spans/ai_client.py and utils.py into one helper (same precedence as today), call it from both sites, and add a focused unit test so the precedence can’t drift. Happy to keep the PR scoped to dedupe only (no behavior change). OK to assign?
Closing this because we won't set gen_ai.request.model in _set_agent_data() in the major anyway.