diff --git a/src/claude_agent_sdk/types.py b/src/claude_agent_sdk/types.py index 3ea89d5a..37fbc5ea 100644 --- a/src/claude_agent_sdk/types.py +++ b/src/claude_agent_sdk/types.py @@ -47,6 +47,7 @@ class AgentDefinition: prompt: str tools: list[str] | None = None model: Literal["sonnet", "opus", "haiku", "inherit"] | None = None + memory: Literal["user", "project", "local"] | None = None # Permission Update types (matching TypeScript SDK) diff --git a/tests/test_types.py b/tests/test_types.py index 95a88bfa..a0ce0bbf 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -159,6 +159,42 @@ def test_claude_code_options_with_model_specification(self): assert options.permission_prompt_tool_name == "CustomTool" +class TestAgentDefinition: + """Test AgentDefinition configuration.""" + + def test_agent_definition_defaults(self): + """Test AgentDefinition with required fields only.""" + from dataclasses import asdict + + from claude_agent_sdk.types import AgentDefinition + + agent = AgentDefinition(description="Test agent", prompt="You are a test agent") + assert agent.tools is None + assert agent.model is None + assert agent.memory is None + + # Verify None fields are excluded from serialized dict + d = {k: v for k, v in asdict(agent).items() if v is not None} + assert "memory" not in d + assert "tools" not in d + + def test_agent_definition_with_memory(self): + """Test AgentDefinition with memory field.""" + from dataclasses import asdict + + from claude_agent_sdk.types import AgentDefinition + + agent = AgentDefinition( + description="Memory agent", + prompt="You are an agent with memory", + memory="project", + ) + assert agent.memory == "project" + + d = {k: v for k, v in asdict(agent).items() if v is not None} + assert d["memory"] == "project" + + class TestHookInputTypes: """Test hook input type definitions."""