Skip to content

Commit 3cd7853

Browse files
committed
Change variable name
1 parent 8997abc commit 3cd7853

File tree

6 files changed

+16
-28
lines changed

6 files changed

+16
-28
lines changed

pydantic_ai_slim/pydantic_ai/agent/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
from ..toolsets.combined import CombinedToolset
6666
from ..toolsets.function import FunctionToolset
6767
from ..toolsets.prepared import PreparedToolset
68-
from .abstract import AbstractAgent, EventStreamHandler, InstructionsInput, RunOutputDataT
68+
from .abstract import AbstractAgent, EventStreamHandler, Instructions, RunOutputDataT
6969
from .wrapper import WrapperAgent
7070

7171
if TYPE_CHECKING:
@@ -163,7 +163,7 @@ def __init__(
163163
model: models.Model | models.KnownModelName | str | None = None,
164164
*,
165165
output_type: OutputSpec[OutputDataT] = str,
166-
instructions: InstructionsInput = None,
166+
instructions: Instructions = None,
167167
system_prompt: str | Sequence[str] = (),
168168
deps_type: type[AgentDepsT] = NoneType,
169169
name: str | None = None,
@@ -189,7 +189,7 @@ def __init__(
189189
model: models.Model | models.KnownModelName | str | None = None,
190190
*,
191191
output_type: OutputSpec[OutputDataT] = str,
192-
instructions: InstructionsInput = None,
192+
instructions: Instructions = None,
193193
system_prompt: str | Sequence[str] = (),
194194
deps_type: type[AgentDepsT] = NoneType,
195195
name: str | None = None,
@@ -213,7 +213,7 @@ def __init__(
213213
model: models.Model | models.KnownModelName | str | None = None,
214214
*,
215215
output_type: OutputSpec[OutputDataT] = str,
216-
instructions: InstructionsInput = None,
216+
instructions: Instructions = None,
217217
system_prompt: str | Sequence[str] = (),
218218
deps_type: type[AgentDepsT] = NoneType,
219219
name: str | None = None,
@@ -351,7 +351,7 @@ def __init__(
351351
self._override_tools: ContextVar[
352352
_utils.Option[Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]]]
353353
] = ContextVar('_override_tools', default=None)
354-
self._override_instructions: ContextVar[_utils.Option[InstructionsInput]] = ContextVar(
354+
self._override_instructions: ContextVar[_utils.Option[Instructions]] = ContextVar(
355355
'_override_instructions', default=None
356356
)
357357

@@ -369,7 +369,7 @@ def _get_instructions_literal_and_functions(
369369

370370
def _instructions_literal_and_functions(
371371
self,
372-
instructions: InstructionsInput,
372+
instructions: Instructions,
373373
) -> tuple[str | None, list[_system_prompt.SystemPromptRunner[AgentDepsT]]]:
374374
literal_parts: list[str] = []
375375
functions: list[_system_prompt.SystemPromptRunner[AgentDepsT]] = []
@@ -736,7 +736,7 @@ def override(
736736
model: models.Model | models.KnownModelName | str | _utils.Unset = _utils.UNSET,
737737
toolsets: Sequence[AbstractToolset[AgentDepsT]] | _utils.Unset = _utils.UNSET,
738738
tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] | _utils.Unset = _utils.UNSET,
739-
instructions: InstructionsInput | _utils.Unset = _utils.UNSET,
739+
instructions: Instructions | _utils.Unset = _utils.UNSET,
740740
) -> Iterator[None]:
741741
"""Context manager to temporarily override agent dependencies, model, toolsets, tools, and instructions.
742742

pydantic_ai_slim/pydantic_ai/agent/abstract.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"""A function that receives agent [`RunContext`][pydantic_ai.tools.RunContext] and an async iterable of events from the model's streaming response and the agent's execution of tools."""
6262

6363

64-
InstructionsInput = (
64+
Instructions = (
6565
str
6666
| _system_prompt.SystemPromptFunc[AgentDepsT]
6767
| Sequence[str | _system_prompt.SystemPromptFunc[AgentDepsT]]
@@ -690,7 +690,7 @@ def override(
690690
model: models.Model | models.KnownModelName | str | _utils.Unset = _utils.UNSET,
691691
toolsets: Sequence[AbstractToolset[AgentDepsT]] | _utils.Unset = _utils.UNSET,
692692
tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] | _utils.Unset = _utils.UNSET,
693-
instructions: InstructionsInput | _utils.Unset = _utils.UNSET,
693+
instructions: Instructions | _utils.Unset = _utils.UNSET,
694694
) -> Iterator[None]:
695695
"""Context manager to temporarily override agent dependencies, model, toolsets, tools, and instructions.
696696

pydantic_ai_slim/pydantic_ai/agent/wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
ToolFuncEither,
2121
)
2222
from ..toolsets import AbstractToolset
23-
from .abstract import AbstractAgent, EventStreamHandler, InstructionsInput, RunOutputDataT
23+
from .abstract import AbstractAgent, EventStreamHandler, Instructions, RunOutputDataT
2424

2525

2626
class WrapperAgent(AbstractAgent[AgentDepsT, OutputDataT]):
@@ -214,7 +214,7 @@ def override(
214214
model: models.Model | models.KnownModelName | str | _utils.Unset = _utils.UNSET,
215215
toolsets: Sequence[AbstractToolset[AgentDepsT]] | _utils.Unset = _utils.UNSET,
216216
tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] | _utils.Unset = _utils.UNSET,
217-
instructions: InstructionsInput | _utils.Unset = _utils.UNSET,
217+
instructions: Instructions | _utils.Unset = _utils.UNSET,
218218
) -> Iterator[None]:
219219
"""Context manager to temporarily override agent dependencies, model, toolsets, tools, and instructions.
220220

pydantic_ai_slim/pydantic_ai/durable_exec/dbos/_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
usage as _usage,
1515
)
1616
from pydantic_ai.agent import AbstractAgent, AgentRun, AgentRunResult, EventStreamHandler, RunOutputDataT, WrapperAgent
17-
from pydantic_ai.agent.abstract import InstructionsInput
17+
from pydantic_ai.agent.abstract import Instructions
1818
from pydantic_ai.exceptions import UserError
1919
from pydantic_ai.models import Model
2020
from pydantic_ai.output import OutputDataT, OutputSpec
@@ -705,7 +705,7 @@ def override(
705705
model: models.Model | models.KnownModelName | str | _utils.Unset = _utils.UNSET,
706706
toolsets: Sequence[AbstractToolset[AgentDepsT]] | _utils.Unset = _utils.UNSET,
707707
tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] | _utils.Unset = _utils.UNSET,
708-
instructions: InstructionsInput | _utils.Unset = _utils.UNSET,
708+
instructions: Instructions | _utils.Unset = _utils.UNSET,
709709
) -> Iterator[None]:
710710
"""Context manager to temporarily override agent dependencies, model, toolsets, tools, and instructions.
711711

pydantic_ai_slim/pydantic_ai/durable_exec/temporal/_agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
models,
2222
usage as _usage,
2323
)
24-
from pydantic_ai.agent import AbstractAgent, AgentRun, AgentRunResult, EventStreamHandler, RunOutputDataT, WrapperAgent
25-
from pydantic_ai.agent.abstract import InstructionsInput
24+
from pydantic_ai.agent import AbstractAgent, AgentRun, AgentRunResult, EventStreamHandler, WrapperAgent
25+
from pydantic_ai.agent.abstract import Instructions, RunOutputDataT
2626
from pydantic_ai.exceptions import UserError
2727
from pydantic_ai.models import Model
2828
from pydantic_ai.output import OutputDataT, OutputSpec
@@ -749,7 +749,7 @@ def override(
749749
model: models.Model | models.KnownModelName | str | _utils.Unset = _utils.UNSET,
750750
toolsets: Sequence[AbstractToolset[AgentDepsT]] | _utils.Unset = _utils.UNSET,
751751
tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] | _utils.Unset = _utils.UNSET,
752-
instructions: InstructionsInput | _utils.Unset = _utils.UNSET,
752+
instructions: Instructions | _utils.Unset = _utils.UNSET,
753753
) -> Iterator[None]:
754754
"""Context manager to temporarily override agent dependencies, model, toolsets, tools, and instructions.
755755

tests/test_override_instructions.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,6 @@ def override_fn() -> str:
159159
assert 'BASE' not in req.instructions
160160

161161

162-
def test_override_instructions_ignores_unknown_types():
163-
"""Override ignores instruction entries it does not understand."""
164-
agent = Agent('test')
165-
166-
with agent.override(instructions=['ONLY_LITERAL', object()]):
167-
with capture_run_messages() as messages:
168-
agent.run_sync('Hi', model=TestModel(custom_output_text='ok'))
169-
170-
req = _first_request(messages)
171-
assert req.instructions == 'ONLY_LITERAL'
172-
173-
174162
@pytest.mark.anyio
175163
async def test_override_concurrent_isolation():
176164
"""Test that concurrent overrides are isolated from each other."""

0 commit comments

Comments
 (0)