Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/claude_agent_sdk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 36 additions & 0 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down