Skip to content

feat(agent): expose advisor_20260301 capability on AgentDefinition#880

Open
MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
MukundaKatta:feat/agent-definition-advisor
Open

feat(agent): expose advisor_20260301 capability on AgentDefinition#880
MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
MukundaKatta:feat/agent-definition-advisor

Conversation

@MukundaKatta
Copy link
Copy Markdown

Why

ClaudeAgentOptions(agents={...}) lets users declare sub-agents, but
AgentDefinition has no way to attach the advisor_20260301 server-side
tool. Today, anyone who wants the executor/advisor pattern (Sonnet runs
the loop, Opus is consulted at decision points) has to drop a leaf
sub-agent down to the raw anthropic SDK and lose Hooks, Tool Search,
output_format json_schema coercion, OTEL trace propagation, and the
SDK's per-sub-agent cost telemetry.

Closes #875.

What

  • Adds advisor: bool | AdvisorToolConfig | None = None to AgentDefinition
    • None (default) -> field omitted from the wire payload
    • True -> ask the CLI to enable the advisor with default config and
      add the advisor-tool-2026-03-01 beta header
    • AdvisorToolConfig dict -> forwarded verbatim
  • Adds AdvisorToolConfig (TypedDict, total=False) mirroring the API's
    BetaAdvisorTool20260301Param shape: model, max_uses, caching,
    allowed_callers
  • Exports AdvisorToolConfig from the package root so callers can type
    their config dicts

The serializer in _internal/client.py and client.py already strips
None and asdict()-deep-copies dict values, so no transport-layer
changes are needed for the field to flow through.

The docstring is explicit that this requires a Claude Code CLI build
that wires advisor configuration through to per-sub-agent API calls -
older CLIs silently ignore unknown AgentDefinition fields, so the
addition is forward-compatible and backward-safe.

Tested

  • Unit tests added in tests/test_types.py::TestAgentDefinition:
    • advisor=None -> field omitted from payload
    • advisor=True -> payload["advisor"] is True
    • advisor=False -> payload["advisor"] is False (lets a sub-agent
      explicitly opt out of an advisor a profile would otherwise inherit)
    • advisor={...} (full config) -> dict forwarded verbatim, snake_case
      keys preserved, no key rewriting
    • from claude_agent_sdk import AdvisorToolConfig works
  • Tests follow the existing TestAgentDefinition._serialize pattern,
    which mirrors the exact {k: v for k, v in asdict(agent_def).items() if v is not None} transform used by the live serializers.

API references

Adds `advisor: bool | AdvisorToolConfig | None` to `AgentDefinition` so
sub-agents declared via `ClaudeAgentOptions(agents={...})` can attach
the `advisor_20260301` server-side tool without dropping to the raw
`anthropic` SDK. Defaults to `None`, omitted from the wire payload.

When set to `True`, signals the CLI to enable the advisor with default
config and add the `advisor-tool-2026-03-01` beta header. When set to
an `AdvisorToolConfig` dict (model / max_uses / caching / allowed_callers),
the dict is forwarded verbatim — keys mirror the API's
`BetaAdvisorTool20260301Param` schema.

Older CLIs silently ignore the field, matching how unknown
`AgentDefinition` fields are handled today.

Closes anthropics#875.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Expose advisor_20260301 on AgentDefinition

1 participant