Skip to content

Conversation

samuelcolvin
Copy link
Member

should improve performance a tiny bit, and also will make it easier to replace last_messages.

Copy link
Contributor

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

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

Seems like a good idea to abstract away some of the observability logic. It's a little bit unfortunate that we have to "pass around" this observer through function calls, but I don't have a better proposal at the moment.

I'd be in favor of moving the changes to RunContext into a different PR.

Would love to have a quick call (maybe Monday) to ask a few more questions here just to improve my understanding - motivation for this abstraction pattern, etc.

Comment on lines +56 to +63
prompt: str
"""The original user prompt passed to the run."""
model_selection_mode: ModelSelectionMode
"""Dependencies for the agent."""
retry: int = 0
"""Number of retries so far."""
run_step: int = 0
"""The current step in the run."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome to add these, but can we do it in a different PR that focuses just on this enhancement?

Comment on lines +33 to +41
ModelSelectionMode = Literal['from-agent', 'custom', 'override']
"""How the [model][pydantic_ai.models.Model] was selected for the run.
Meanings:
- `'from-agent'`: The model set on the agent was used
- `'custom'`: The model was set via the `model` kwarg, e.g. on [`run`][pydantic_ai.Agent.run]
- `'override'`: The model was set by the [`override`][pydantic_ai.Agent.override] function.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Bikeshedding a bit here, could we be even more explicit?

Like agent, run-kwarg, and override? Feel free to take or leave these particular suggestions.

I'm hesitant to use "from" with agent, but not any of the others, and "custom" seems not specific enough...

deps = self._get_deps(deps)
new_message_index = len(message_history) if message_history else 0
run_context = RunContext(deps, [], None, model_used, user_prompt, model_selection_mode)
# noinspection PyTypeChecker
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could name this observability?

@samuelcolvin
Copy link
Member Author

Overall I don't think this is a good idea, but there are a few good bits we should take out into a new PR.

@samuelcolvin
Copy link
Member Author

replaced by #570.

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