Skip to content

fix(pydantic_ai): deduplicate tool spans from run_sync - #1142

Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
abhi-pydantic-double-logging
Nov 18, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
abhi-pydantic-double-logging

Conversation

@AbhiPrasad

Copy link
Copy Markdown
Member

🤖 This text was AI-generated.

Agent.run_sync() delegates to Agent.run(). The inner run traces each tool call, and the outer wrapper could reconstruct the same calls from the returned messages.

Before                           After
agent_run_sync                   agent_run_sync
|-- agent_run                    `-- agent_run
|   `-- calculate                    `-- calculate
`-- calculate (duplicate)

Record the result handled by the inner run so the outer wrapper can skip reconstruction of that result. Keep the fallback available for runs whose tool calls still need to be reconstructed from messages.

fixes #1137

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

Agent.run_sync() delegates to Agent.run(). The inner run traces each
tool call, and the outer wrapper could reconstruct the same calls from
the returned messages.

```text
Before                           After
agent_run_sync                   agent_run_sync
|-- agent_run                    `-- agent_run
|   `-- calculate                    `-- calculate
`-- calculate (duplicate)
```

Record the result handled by the inner run so the outer wrapper can
skip reconstruction of that result. Keep the fallback available for
runs whose tool calls still need to be reconstructed from messages.

Fixes #1137
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T17:03:29.550795Z 38d0157 PR opened
ℹ️ 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.

@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 9ef717b into main Nov 18, 2026
98 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi-pydantic-double-logging branch November 18, 2026 20:04
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 integration: Agent.run_sync() logs every tool call twice

1 participant