Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
...cool cool
  • Loading branch information
mwildehahn committed Oct 1, 2025
commit 1fd362764345eb2e60e5875668eb0e53c068c46c
4 changes: 2 additions & 2 deletions pydantic_ai_slim/pydantic_ai/agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ def _append_instruction(self, instruction: _system_prompt.SystemPromptFunc[Agent
instructions_list = [self._instructions, instruction]
elif callable(self._instructions):
instructions_list = [self._instructions, instruction]
else: # pragma: no cover
instructions_list = [*self._instructions, instruction]
else:
instructions_list = [*self._instructions, instruction] # pragma: no cover
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry for continuing to come up with more ways to refactor this, but what do you think about making self._instructions and self._override_instructions always hold a list[str | _system_prompt.SystemPromptFunc[AgentDepsT]], and change __init__ and override to store list(instructions) so that any single items automatically get wrapped in a list, and this method and the one above can be much simpler?


self._instructions = instructions_list

Expand Down