Skip to content

Conversation

alexmojaki
Copy link
Contributor

No description provided.

model_settings,
models.ModelRequestParameters(),
)
model_response = await model_request(self.sampling_model, pai_messages, model_settings=model_settings)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This way logfire.instrument_pydantic_ai() will instrument the sampling model.

@alexmojaki alexmojaki requested a review from Copilot September 2, 2025 13:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR makes two minor improvements to the codebase: updates the Agent.__aenter__ method to return Self for better type precision, and simplifies MCP sampling model instrumentation by using the default model_request function instead of manual model calls.

  • Updates Agent.__aenter__ return type from AbstractAgent[AgentDepsT, OutputDataT] to Self
  • Replaces manual model request in MCP sampling callback with default instrumentation via model_request

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pydantic_ai_slim/pydantic_ai/agent/init.py Updates __aenter__ return type to Self and adds necessary import
pydantic_ai_slim/pydantic_ai/mcp.py Refactors sampling callback to use model_request function and adds import

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

github-actions bot commented Sep 2, 2025

Docs Preview

commit: 9b7654e
Preview URL: https://dafa3ee6-pydantic-ai-previews.pydantic.workers.dev

@alexmojaki alexmojaki requested a review from DouweM September 2, 2025 13:27
@alexmojaki alexmojaki merged commit ca079f5 into main Sep 2, 2025
59 of 61 checks passed
@alexmojaki alexmojaki deleted the alex/minor branch September 2, 2025 16:59
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.

2 participants