Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: Add toggle on llm config for parallel tool calling [LET-5610] (#5542)
Matthew Zhou396959da2f7c
diff --git a/fern/openapi.json b/fern/openapi.jsonindex ef1ca9500..62c4f0e0e 100644--- a/fern/openapi.json+++ b/fern/openapi.json@@ -14935,6 +14935,36 @@{}],"nullable": true+ },+ "parallel_tool_calls": {+ "oneOf": [+ {+ "type": "boolean"+ },+ {+ "type": "string",+ "format": "null",+ "nullable": true+ },+ {+ "type": "array",+ "items": {+ "oneOf": [+ {+ "type": "boolean"+ },+ {+ "type": "string",+ "format": "null",+ "nullable": true+ }+ ],+ "nullable": true+ }+ },+ {}+ ],+ "nullable": true}},"required": [@@ -26223,6 +26253,12 @@],"title": "Hidden","description": "If set to True, the agent will be hidden."+ },+ "parallel_tool_calls": {+ "type": "boolean",+ "title": "Parallel Tool Calls",+ "description": "If set to True, enables parallel tool calling. Defaults to False.",+ "default": false}},"type": "object",@@ -29530,6 +29566,12 @@"title": "Hidden","description": "If set to True, the agent will be hidden."},+ "parallel_tool_calls": {+ "type": "boolean",+ "title": "Parallel Tool Calls",+ "description": "If set to True, enables parallel tool calling. Defaults to False.",+ "default": false+ },"deployment_id": {"type": "string","title": "Deployment Id",@@ -30269,6 +30311,19 @@],"title": "Tier","description": "The cost tier for the model (cloud only)."+ },+ "parallel_tool_calls": {+ "anyOf": [+ {+ "type": "boolean"+ },+ {+ "type": "null"+ }+ ],+ "title": "Parallel Tool Calls",+ "description": "If set to True, enables parallel tool calling. Defaults to False.",+ "default": false}},"type": "object",@@ -36764,6 +36819,12 @@],"title": "Hidden","description": "If set to True, the agent will be hidden."+ },+ "parallel_tool_calls": {+ "type": "boolean",+ "title": "Parallel Tool Calls",+ "description": "If set to True, enables parallel tool calling. Defaults to False.",+ "default": false}},"type": "object",@@ -37984,6 +38045,12 @@"title": "Hidden","description": "If set to True, the agent will be hidden."},+ "parallel_tool_calls": {+ "type": "boolean",+ "title": "Parallel Tool Calls",+ "description": "If set to True, enables parallel tool calling. Defaults to False.",+ "default": false+ },"id": {"type": "string","title": "Id",diff --git a/letta/agents/letta_agent_v3.py b/letta/agents/letta_agent_v3.pyindex d73f26f4f..d159a193c 100644--- a/letta/agents/letta_agent_v3.py+++ b/letta/agents/letta_agent_v3.py@@ -372,11 +372,11 @@ class LettaAgentV3(LettaAgentV2):isinstance(request_data.get("tool_choice"), dict)and "disable_parallel_tool_use" in request_data["tool_choice"]):- # Gate parallel tool use on both: no tool rules and no approval-required tools- if no_tool_rules and not has_approval_tools:+ # Gate parallel tool use on both: no tool rules and no approval-required tools and toggled on+ if no_tool_rules and not has_approval_tools and self.agent_state.llm_config.parallel_tool_calls:request_data["tool_choice"]["disable_parallel_tool_use"] = Falseelse:- # Explicitly disable when approvals exist (TODO support later) or tool rules present+ # Explicitly disable when approvals exist (TODO support later) or tool rules present or llm_config toggled offrequest_data["tool_choice"]["disable_parallel_tool_use"] = Trueexcept Exception:# if this fails, we simply don't enable parallel tool usediff --git a/letta/schemas/agent.py b/letta/schemas/agent.pyindex 657916fe5..8b11afcfe 100644--- a/letta/schemas/agent.py+++ b/letta/schemas/agent.py@@ -256,6 +256,7 @@ class CreateAgent(BaseModel, validate_assignment=True): #None,description="If set to True, the agent will be hidden.",)+ parallel_tool_calls: bool = Field(False, description="If set to True, enables parallel tool calling. Defaults to False.")@field_validator("name")@classmethod@@ -371,6 +372,7 @@ class UpdateAgent(BaseModel):None,description="If set to True, the agent will be hidden.",)+ parallel_tool_calls: bool = Field(False, description="If set to True, enables parallel tool calling. Defaults to False.")model_config = ConfigDict(extra="ignore") # Ignores extra fieldsdiff --git a/letta/schemas/llm_config.py b/letta/schemas/llm_config.pyindex e46362d5b..bebfb950f 100644--- a/letta/schemas/llm_config.py+++ b/letta/schemas/llm_config.py@@ -80,6 +80,7 @@ class LLMConfig(BaseModel):# FIXME hack to silence pydantic protected namespace warningmodel_config = ConfigDict(protected_namespaces=())+ parallel_tool_calls: Optional[bool] = Field(False, description="If set to True, enables parallel tool calling. Defaults to False.")@model_validator(mode="before")@classmethoddiff --git a/tests/integration_test_send_message_v2.py b/tests/integration_test_send_message_v2.pyindex 196338cf9..5e98d27a1 100644--- a/tests/integration_test_send_message_v2.py+++ b/tests/integration_test_send_message_v2.py@@ -543,6 +543,8 @@ async def test_parallel_tool_call_anthropic(if llm_config.model_endpoint_type != "anthropic":pytest.skip("Parallel tool calling test only applies to Anthropic models.")+ # change llm_config to support parallel tool calling+ llm_config.parallel_tool_calls = Trueagent_state = await client.agents.modify(agent_id=agent_state.id, llm_config=llm_config)if send_type == "step":