Skip to content

agents

Class info

Classes

Name Children Inherits
AgentDefinition
clawd_code_sdk.models.agents
User-facing agent definition configuration.
    AgentInfo
    clawd_code_sdk.models.agents
    Information about an available subagent that can be invoked via the Agent tool.
      AgentWireDefinition
      clawd_code_sdk.models.agents
      Wire-format agent definition matching the CLI control protocol.
        ToolsPreset
        clawd_code_sdk.models.agents
        Tools preset configuration.

          🛈 DocStrings

          Agent definitions and preset configurations.

          AgentDefinition

          Bases: ClaudeCodeBaseModel

          User-facing agent definition configuration.

          Accepts ergonomic Python inputs (e.g. dict-style mcp_servers) and converts to the wire format via to_wire().

          Source code in src/clawd_code_sdk/models/agents.py
          class AgentDefinition(ClaudeCodeBaseModel):
              """User-facing agent definition configuration.
          
              Accepts ergonomic Python inputs (e.g. dict-style mcp_servers)
              and converts to the wire format via ``to_wire()``.
              """
          
              description: str = Field(..., title="Agent Description", examples=["QA Assistant"])
              """A brief description of the agent's purpose."""
          
              prompt: str = Field(..., title="Agent Prompt", examples=["Do XY"])
              """The prompt to use for this agent."""
          
              tools: list[ToolName | str] | None = Field(default=None, title="Agent Tools", examples=["Bash"])
              """The tools this agent has access to."""
          
              model: ModelName | Literal["inherit"] | str | None = Field(  # noqa: PYI051
                  default=None,
                  title="Agent Model",
                  examples=["sonnet"],
              )
              """The model to use for this agent."""
          
              memory: SettingSource | None = Field(
                  default=None,
                  title="Agent Memory",
                  examples=["user", "project"],
              )
              """Persistent cross-session memory scope for this agent."""
              mcp_servers: Mapping[str, McpServerConfigForProcessTransport | None] | None = None
              """MCP servers for this agent.
          
              Maps server names to configs. Use ``None`` as the value to reference
              a server already configured in settings::
              """
          
              disallowed_tools: list[ToolName | str] | None = Field(
                  default=None,
                  title="Disallowed Tools",
                  examples=["Bash"],
              )
              """Tools this agent is not allowed to use."""
          
              critical_system_reminder_experimental: str | None = Field(
                  default=None,
                  title="Critical System Reminder",
                  alias="criticalSystemReminder_EXPERIMENTAL",
              )
              """Critical system reminder message to display to the user."""
          
              skills: list[str] | None = Field(default=None, title="Skills", examples=["my-skill"])
              """Skills this agent has."""
          
              initial_prompt: str | None = Field(default=None, title="Initial Prompt")
              """Auto-submitted as the first user turn when this agent is the main thread agent.
          
              Slash commands are processed. Prepended to any user-provided prompt.
              """
          
              max_turns: int | None = Field(default=None, title="Max Turns")
              """Maximum number of agentic turns (API round-trips) before stopping."""
          
              background: bool | None = Field(default=None, title="Run in Background")
              """Whether this agent runs in the background."""
          
              hooks: AgentHooksConfig | None = Field(default=None, title="Agent Hooks")
              """Hook configurations for this agent."""
          
              effort: ReasoningEffort | int | None = Field(
                  default=None,
                  title="Reasoning effort",
                  examples=["high"],
              )
              """Effort level for thinking depth."""
          
              permission_mode: PermissionMode | None = Field(
                  default=None,
                  title="Permission Mode",
                  examples=["bypassPermissions"],
              )
              """Permission mode for this agent."""
          
              isolation: Literal["worktree"] | None = Field(
                  default=None,
                  title="Isolation Mode",
                  examples=["worktree"],
              )
              """Isolation mode. ``"worktree"`` runs the agent in a separate git worktree."""
          
              auto_compact_window: int | None = Field(default=None, title="Auto-Compact Window")
              """Token count at which this agent compacts its own conversation as a subagent.
          
              Only lowers the inherited window. No effect on the main session agent."""
          
              omit_claude_md: bool | None = Field(default=None, title="Omit CLAUDE.md")
              """Run without user/project/local CLAUDE.md files when running as a subagent."""
          
              observer: str | None = Field(default=None, title="Observer Agent")
              """Agent type(s) (comma-separated, max 4) auto-spawned as background observers."""
          
              observer_message: str | None = Field(default=None, title="Observer Message")
              """Supplemental postamble appended to each activity digest sent to the observer."""
          
              def to_wire(self) -> dict[str, Any]:
                  """Serialize to the wire-format dict for the CLI control protocol.
          
                  Converts dict-style mcp_servers to the array format the CLI expects:
                  ``{"git": config}`` -> ``[{"git": config}]``
          
                  Returns a camelCase dict with None values excluded.
                  """
                  model = self.to_wire_model()
                  return model.model_dump(by_alias=True, exclude_none=True)
          
              def to_wire_model(self) -> AgentWireDefinition:
                  """Serialize to the wire-format dict for the CLI control protocol.
          
                  Converts dict-style mcp_servers to the array format the CLI expects:
                  ``{"git": config}`` -> ``[{"git": config}]``
          
                  Returns a camelCase dict with None values excluded.
                  """
                  mcp = [
                      name if config is None else {name: config}
                      for name, config in (self.mcp_servers or {}).items()
                  ]
                  return AgentWireDefinition(
                      description=self.description,
                      prompt=self.prompt,
                      tools=self.tools,
                      model=self.model,
                      memory=self.memory,
                      mcp_servers=mcp or None,
                      disallowed_tools=self.disallowed_tools,
                      critical_system_reminder_experimental=self.critical_system_reminder_experimental,
                      skills=self.skills,
                      initial_prompt=self.initial_prompt,
                      max_turns=self.max_turns,
                      background=self.background,
                      hooks=self.hooks,
                      effort=self.effort,
                      permission_mode=self.permission_mode,
                      isolation=self.isolation,
                      auto_compact_window=self.auto_compact_window,
                      omit_claude_md=self.omit_claude_md,
                      observer=self.observer,
                      observer_message=self.observer_message,
                  )
          

          auto_compact_window class-attribute instance-attribute

          auto_compact_window: int | None = Field(default=None, title='Auto-Compact Window')
          

          Token count at which this agent compacts its own conversation as a subagent.

          Only lowers the inherited window. No effect on the main session agent.

          background class-attribute instance-attribute

          background: bool | None = Field(default=None, title='Run in Background')
          

          Whether this agent runs in the background.

          critical_system_reminder_experimental class-attribute instance-attribute

          critical_system_reminder_experimental: str | None = Field(
              default=None, title="Critical System Reminder", alias="criticalSystemReminder_EXPERIMENTAL"
          )
          

          Critical system reminder message to display to the user.

          description class-attribute instance-attribute

          description: str = Field(..., title='Agent Description', examples=['QA Assistant'])
          

          A brief description of the agent's purpose.

          disallowed_tools class-attribute instance-attribute

          disallowed_tools: list[ToolName | str] | None = Field(
              default=None, title="Disallowed Tools", examples=["Bash"]
          )
          

          Tools this agent is not allowed to use.

          effort class-attribute instance-attribute

          effort: ReasoningEffort | int | None = Field(
              default=None, title="Reasoning effort", examples=["high"]
          )
          

          Effort level for thinking depth.

          hooks class-attribute instance-attribute

          hooks: AgentHooksConfig | None = Field(default=None, title='Agent Hooks')
          

          Hook configurations for this agent.

          initial_prompt class-attribute instance-attribute

          initial_prompt: str | None = Field(default=None, title='Initial Prompt')
          

          Auto-submitted as the first user turn when this agent is the main thread agent.

          Slash commands are processed. Prepended to any user-provided prompt.

          isolation class-attribute instance-attribute

          isolation: Literal["worktree"] | None = Field(
              default=None, title="Isolation Mode", examples=["worktree"]
          )
          

          Isolation mode. "worktree" runs the agent in a separate git worktree.

          max_turns class-attribute instance-attribute

          max_turns: int | None = Field(default=None, title='Max Turns')
          

          Maximum number of agentic turns (API round-trips) before stopping.

          mcp_servers class-attribute instance-attribute

          mcp_servers: Mapping[str, McpServerConfigForProcessTransport | None] | None = None
          

          MCP servers for this agent.

          Maps server names to configs. Use None as the value to reference a server already configured in settings::

          memory class-attribute instance-attribute

          memory: SettingSource | None = Field(
              default=None, title="Agent Memory", examples=["user", "project"]
          )
          

          Persistent cross-session memory scope for this agent.

          model class-attribute instance-attribute

          model: ModelName | Literal["inherit"] | str | None = Field(
              default=None, title="Agent Model", examples=["sonnet"]
          )
          

          The model to use for this agent.

          observer class-attribute instance-attribute

          observer: str | None = Field(default=None, title='Observer Agent')
          

          Agent type(s) (comma-separated, max 4) auto-spawned as background observers.

          observer_message class-attribute instance-attribute

          observer_message: str | None = Field(default=None, title='Observer Message')
          

          Supplemental postamble appended to each activity digest sent to the observer.

          omit_claude_md class-attribute instance-attribute

          omit_claude_md: bool | None = Field(default=None, title='Omit CLAUDE.md')
          

          Run without user/project/local CLAUDE.md files when running as a subagent.

          permission_mode class-attribute instance-attribute

          permission_mode: PermissionMode | None = Field(
              default=None, title="Permission Mode", examples=["bypassPermissions"]
          )
          

          Permission mode for this agent.

          prompt class-attribute instance-attribute

          prompt: str = Field(..., title='Agent Prompt', examples=['Do XY'])
          

          The prompt to use for this agent.

          skills class-attribute instance-attribute

          skills: list[str] | None = Field(default=None, title='Skills', examples=['my-skill'])
          

          Skills this agent has.

          tools class-attribute instance-attribute

          tools: list[ToolName | str] | None = Field(default=None, title='Agent Tools', examples=['Bash'])
          

          The tools this agent has access to.

          to_wire

          to_wire() -> dict[str, Any]
          

          Serialize to the wire-format dict for the CLI control protocol.

          Converts dict-style mcp_servers to the array format the CLI expects: {"git": config} -> [{"git": config}]

          Returns a camelCase dict with None values excluded.

          Source code in src/clawd_code_sdk/models/agents.py
          def to_wire(self) -> dict[str, Any]:
              """Serialize to the wire-format dict for the CLI control protocol.
          
              Converts dict-style mcp_servers to the array format the CLI expects:
              ``{"git": config}`` -> ``[{"git": config}]``
          
              Returns a camelCase dict with None values excluded.
              """
              model = self.to_wire_model()
              return model.model_dump(by_alias=True, exclude_none=True)
          

          to_wire_model

          to_wire_model() -> AgentWireDefinition
          

          Serialize to the wire-format dict for the CLI control protocol.

          Converts dict-style mcp_servers to the array format the CLI expects: {"git": config} -> [{"git": config}]

          Returns a camelCase dict with None values excluded.

          Source code in src/clawd_code_sdk/models/agents.py
          def to_wire_model(self) -> AgentWireDefinition:
              """Serialize to the wire-format dict for the CLI control protocol.
          
              Converts dict-style mcp_servers to the array format the CLI expects:
              ``{"git": config}`` -> ``[{"git": config}]``
          
              Returns a camelCase dict with None values excluded.
              """
              mcp = [
                  name if config is None else {name: config}
                  for name, config in (self.mcp_servers or {}).items()
              ]
              return AgentWireDefinition(
                  description=self.description,
                  prompt=self.prompt,
                  tools=self.tools,
                  model=self.model,
                  memory=self.memory,
                  mcp_servers=mcp or None,
                  disallowed_tools=self.disallowed_tools,
                  critical_system_reminder_experimental=self.critical_system_reminder_experimental,
                  skills=self.skills,
                  initial_prompt=self.initial_prompt,
                  max_turns=self.max_turns,
                  background=self.background,
                  hooks=self.hooks,
                  effort=self.effort,
                  permission_mode=self.permission_mode,
                  isolation=self.isolation,
                  auto_compact_window=self.auto_compact_window,
                  omit_claude_md=self.omit_claude_md,
                  observer=self.observer,
                  observer_message=self.observer_message,
              )
          

          AgentInfo

          Bases: ClaudeCodeBaseModel

          Information about an available subagent that can be invoked via the Agent tool.

          Source code in src/clawd_code_sdk/models/agents.py
          class AgentInfo(ClaudeCodeBaseModel):
              """Information about an available subagent that can be invoked via the Agent tool."""
          
              name: str
              """Agent type identifier (e.g., "Explore")."""
          
              description: str
              """Description of when to use this agent."""
          
              model: Model | str | None = None
              """Model alias this agent uses. If omitted, inherits the parent's model."""
          

          description instance-attribute

          description: str
          

          Description of when to use this agent.

          model class-attribute instance-attribute

          model: Model | str | None = None
          

          Model alias this agent uses. If omitted, inherits the parent's model.

          name instance-attribute

          name: str
          

          Agent type identifier (e.g., "Explore").

          AgentWireDefinition

          Bases: ClaudeCodeBaseModel

          Wire-format agent definition matching the CLI control protocol.

          This is the strict camelCase representation sent over the wire in the initialize request.

          The CLI's public Zod schema (sdk.d.ts) only defines::

          description, prompt, tools, disallowedTools, model, mcpServers,
          criticalSystemReminder_EXPERIMENTAL, skills, maxTurns
          

          However, the CLI's internal parse schema (Rff / parseAgentFromJson) also accepts these additional fields, which are fully functional::

          memory, background, hooks, effort, permissionMode, isolation
          
          Source code in src/clawd_code_sdk/models/agents.py
          class AgentWireDefinition(ClaudeCodeBaseModel):
              """Wire-format agent definition matching the CLI control protocol.
          
              This is the strict camelCase representation sent over the wire
              in the initialize request.
          
              The CLI's *public* Zod schema (``sdk.d.ts``) only defines::
          
                  description, prompt, tools, disallowedTools, model, mcpServers,
                  criticalSystemReminder_EXPERIMENTAL, skills, maxTurns
          
              However, the CLI's *internal* parse schema (``Rff`` / ``parseAgentFromJson``)
              also accepts these additional fields, which are fully functional::
          
                  memory, background, hooks, effort, permissionMode, isolation
              """
          
              description: str
              prompt: str
              tools: list[ToolName | str] | None = None
              model: ModelName | Literal["inherit"] | str | None = None  # noqa: PYI051
              memory: SettingSource | None = None
              mcp_servers: Sequence[AgentMcpServerSpec] | None = None
              disallowed_tools: list[ToolName | str] | None = None
              critical_system_reminder_experimental: str | None = Field(
                  default=None, serialization_alias="criticalSystemReminder_EXPERIMENTAL"
              )
              skills: list[str] | None = None
              initial_prompt: str | None = None
              max_turns: int | None = None
              background: bool | None = None
              hooks: AgentHooksConfig | None = None
              effort: ReasoningEffort | int | None = None
              permission_mode: PermissionMode | None = None
              isolation: Literal["worktree"] | None = None
              auto_compact_window: int | None = None
              omit_claude_md: bool | None = Field(default=None, serialization_alias="omitClaudeMd")
              observer: str | None = None
              observer_message: str | None = None
          

          ToolsPreset

          Bases: TypedDict

          Tools preset configuration.

          Source code in src/clawd_code_sdk/models/agents.py
          class ToolsPreset(TypedDict):
              """Tools preset configuration."""
          
              type: Literal["preset"]
              preset: Literal["claude_code"]