Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(agent/llm): Include `id` in tool_calls in prompt

Reinier van der Leer8e464c53a884
diff --git a/autogpts/autogpt/autogpt/core/resource/model_providers/openai.py b/autogpts/autogpt/autogpt/core/resource/model_providers/openai.py
index 3b92cb32f3..3d9477fee4 100644
--- a/autogpts/autogpt/autogpt/core/resource/model_providers/openai.py
+++ b/autogpts/autogpt/autogpt/core/resource/model_providers/openai.py
@@ -758,6 +758,7 @@ def _functions_compat_fix_kwargs(
def _tool_calls_compat_extract_calls(response: str) -> Iterator[AssistantToolCall]:
import json
import re
+ import uuid
logging.debug(f"Trying to extract tool calls from response:\n{response}")
@@ -770,6 +771,7 @@ def _tool_calls_compat_extract_calls(response: str) -> Iterator[AssistantToolCal
tool_calls: list[AssistantToolCallDict] = json.loads(block.group(1))
for t in tool_calls:
+ t["id"] = str(uuid.uuid4())
t["function"]["arguments"] = str(t["function"]["arguments"]) # HACK
yield AssistantToolCall.parse_obj(t)
diff --git a/autogpts/autogpt/autogpt/core/resource/model_providers/schema.py b/autogpts/autogpt/autogpt/core/resource/model_providers/schema.py
index a600e64abb..43d4bd296e 100644
--- a/autogpts/autogpt/autogpt/core/resource/model_providers/schema.py
+++ b/autogpts/autogpt/autogpt/core/resource/model_providers/schema.py
@@ -77,13 +77,13 @@ class AssistantFunctionCallDict(TypedDict):
class AssistantToolCall(BaseModel):
- # id: str
+ id: str
type: Literal["function"]
function: AssistantFunctionCall
class AssistantToolCallDict(TypedDict):
- # id: str
+ id: str
type: Literal["function"]
function: AssistantFunctionCallDict