Skip to content

Commit 8af17ca

Browse files
gmrKludex
andauthored
Add tool_call_id to RunContext and update context replacement (#998)
Co-authored-by: Marcelo Trylesinski <[email protected]>
1 parent 38e3f6c commit 8af17ca

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pydantic_ai_slim/pydantic_ai/tools.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class RunContext(Generic[AgentDepsT]):
4949
"""The original user prompt passed to the run."""
5050
messages: list[_messages.ModelMessage] = field(default_factory=list)
5151
"""Messages exchanged in the conversation so far."""
52+
tool_call_id: str | None = None
53+
"""The ID of the tool call."""
5254
tool_name: str | None = None
5355
"""Name of the tool being called."""
5456
retry: int = 0
@@ -301,7 +303,12 @@ def _call_args(
301303
if self._single_arg_name:
302304
args_dict = {self._single_arg_name: args_dict}
303305

304-
ctx = dataclasses.replace(run_context, retry=self.current_retry, tool_name=message.tool_name)
306+
ctx = dataclasses.replace(
307+
run_context,
308+
retry=self.current_retry,
309+
tool_name=message.tool_name,
310+
tool_call_id=message.tool_call_id,
311+
)
305312
args = [ctx] if self.takes_ctx else []
306313
for positional_field in self._positional_fields:
307314
args.append(args_dict.pop(positional_field))

0 commit comments

Comments
 (0)