Skip to content
Closed
Changes from all commits
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
15 changes: 7 additions & 8 deletions src/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ class ToolsToFinalOutputResult:
"""


AgentInstructionsFunction: TypeAlias = Callable[
[RunContextWrapper[TContext], "Agent[TContext]"],
Copy link
Member

Choose a reason for hiding this comment

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

We don't want to make this Agent[TContext] type be a string just for extracting the type here

MaybeAwaitable[str],
]


class StopAtTools(TypedDict):
stop_at_tool_names: list[str]
"""A list of tool names, any of which will stop the agent from running further."""
Expand Down Expand Up @@ -143,14 +149,7 @@ class Agent(AgentBase, Generic[TContext]):
See `AgentBase` for base parameters that are shared with `RealtimeAgent`s.
"""

instructions: (
str
| Callable[
[RunContextWrapper[TContext], Agent[TContext]],
MaybeAwaitable[str],
]
| None
) = None
instructions: str | AgentInstructionsFunction | None = None
"""The instructions for the agent. Will be used as the "system prompt" when this agent is
invoked. Describes what the agent should do, and how it responds.

Expand Down