Skip to content

fix(pydantic-ai): trace fallback model attempts - #1047

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi/issue-1042-vcr-tests-1af7bc7c
Nov 2, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi/issue-1042-vcr-tests-1af7bc7c

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

🤖 This text was AI-generated.

When a Pydantic AI agent retries a failed request with a model instance,
the fallback can run without a model span. The agent span can also retain
the original model and provider after a different model answers.

Before: failed primary span → untraced fallback; agent shows primary
After:  failed primary span → fallback span; agent shows answering model

Wrap models resolved for retry and update agent metadata from the final
response. Keep the provider reported by the response when a model ID uses
an alias such as openai-responses.

Closes #1042

> 🤖 **This text was AI-generated.**

When a Pydantic AI agent retries a failed request with a model instance,
the fallback can run without a model span. The agent span can also retain
the original model and provider after a different model answers.

```text
Before: failed primary span → untraced fallback; agent shows primary
After:  failed primary span → fallback span; agent shows answering model
```

Wrap models resolved for retry and update agent metadata from the final
response. Keep the provider reported by the response when a model ID uses
an alias such as `openai-responses`.

Closes #1042
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T16:17:14.720165Z 03f19e4 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f69e9b3636

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit bd70cd5 into main Nov 2, 2026
98 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi/issue-1042-vcr-tests-1af7bc7c branch November 2, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pydantic_ai: trace ModelFallback attempts and attribute model spans correctly (2.64+)

1 participant