Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: fix tool rule serialization for rules with extra fields getting dropped (#1441)

Sarah Woodersdb6455303bd4
diff --git a/letta/serialize_schemas/marshmallow_agent.py b/letta/serialize_schemas/marshmallow_agent.py
index 12ce873d7..834f7545f 100644
--- a/letta/serialize_schemas/marshmallow_agent.py
+++ b/letta/serialize_schemas/marshmallow_agent.py
@@ -32,6 +32,7 @@ class MarshmallowAgentSchema(BaseSchema):
llm_config = LLMConfigField()
embedding_config = EmbeddingConfigField()
+
tool_rules = ToolRulesField()
messages = fields.List(fields.Nested(SerializedMessageSchema))
diff --git a/letta/serialize_schemas/pydantic_agent_schema.py b/letta/serialize_schemas/pydantic_agent_schema.py
index 5cd1805f0..8d11b7811 100644
--- a/letta/serialize_schemas/pydantic_agent_schema.py
+++ b/letta/serialize_schemas/pydantic_agent_schema.py
@@ -1,4 +1,4 @@
-from typing import Any, Dict, List, Optional
+from typing import Any, Dict, List, Optional, Union
from pydantic import BaseModel, Field
@@ -45,11 +45,31 @@ class ToolEnvVarSchema(BaseModel):
value: str
-class ToolRuleSchema(BaseModel):
+# Tool rules
+
+
+class BaseToolRuleSchema(BaseModel):
tool_name: str
type: str
+class ChildToolRuleSchema(BaseToolRuleSchema):
+ children: List[str]
+
+
+class MaxCountPerStepToolRuleSchema(BaseToolRuleSchema):
+ max_count_limit: int
+
+
+class ConditionalToolRuleSchema(BaseToolRuleSchema):
+ default_child: Optional[str]
+ child_output_mapping: Dict[Any, str]
+ require_output_mapping: bool
+
+
+ToolRuleSchema = Union[BaseToolRuleSchema, ChildToolRuleSchema, MaxCountPerStepToolRuleSchema, ConditionalToolRuleSchema]
+
+
class ParameterProperties(BaseModel):
type: str
description: Optional[str] = None