From 9f24145b4159f6bddb4393c314844f65bad95487 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 10:00:34 +0000 Subject: [PATCH 1/3] Initial plan From 85bd88b9c21dc63f0753d46a62b7a2e50bc438a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 10:10:27 +0000 Subject: [PATCH 2/3] Document ToolCall.execute availability from dspy 3.0.4b2 Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com> --- docs/docs/learn/programming/tools.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/docs/learn/programming/tools.md b/docs/docs/learn/programming/tools.md index 2492ac56b8..408a5e008d 100644 --- a/docs/docs/learn/programming/tools.md +++ b/docs/docs/learn/programming/tools.md @@ -66,6 +66,9 @@ react_agent = dspy.ReAct( For more control over the tool calling process, you can manually handle tools using DSPy's tool types. +!!! note "Version Requirement" + The `ToolCall.execute()` method used in the examples below is available from **dspy 3.0.4b2** onwards. If you're using version 3.0.3 or earlier, you'll need to upgrade to use this feature. + ### Basic Setup ```python @@ -134,6 +137,9 @@ print(str(tool)) # Full tool description ### Understanding `dspy.ToolCalls` +!!! note "Version Requirement" + The `ToolCall.execute()` method is available from **dspy 3.0.4b2** onwards. If you're using an earlier version, you'll need to upgrade to use this feature. + The `dspy.ToolCalls` type represents the output from a model that can make tool calls. Each individual tool call can be executed using the `execute` method: ```python From 1723bc5ab0c0a68c0051ad428f1bdffb73c0b9c7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 1 Nov 2025 04:19:35 +0000 Subject: [PATCH 3/3] Add workaround for pre-3.0.4b2 versions in code examples Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com> --- docs/docs/learn/programming/tools.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/docs/learn/programming/tools.md b/docs/docs/learn/programming/tools.md index 408a5e008d..757421de01 100644 --- a/docs/docs/learn/programming/tools.md +++ b/docs/docs/learn/programming/tools.md @@ -111,6 +111,7 @@ response = predictor( for call in response.outputs.tool_calls: # Execute the tool call result = call.execute() + # For versions earlier than 3.0.4b2, use: result = tools[call.name](**call.args) print(f"Tool: {call.name}") print(f"Args: {call.args}") print(f"Result: {result}") @@ -159,6 +160,10 @@ for call in response.outputs.tool_calls: # Option 3: Pass Tool objects as a list result = call.execute(functions=[dspy.Tool(weather), dspy.Tool(calculator)]) + # Option 4: For versions earlier than 3.0.4b2 (manual tool lookup) + # tools_dict = {"weather": weather, "calculator": calculator} + # result = tools_dict[call.name](**call.args) + print(f"Result: {result}") ```