Skip to content

fix: accept list-form system_prompt in ClaudeAgentOptions#1040

Open
ashishpatel26 wants to merge 1 commit into
anthropics:mainfrom
ashishpatel26:fix/issue-899-list-form-system-prompt
Open

fix: accept list-form system_prompt in ClaudeAgentOptions#1040
ashishpatel26 wants to merge 1 commit into
anthropics:mainfrom
ashishpatel26:fix/issue-899-list-form-system-prompt

Conversation

@ashishpatel26

Copy link
Copy Markdown

Summary

Resolves #899

The Anthropic Messages API supports system as either a string or a list[dict] (multi-block with cache_control support). The SDK previously only accepted strings for system_prompt.

Changes Made

  • src/claude_agent_sdk/types.py: broaden system_prompt type to str | list[dict[str, Any]] | SystemPromptPreset | SystemPromptFile | None
  • src/claude_agent_sdk/_internal/transport/subprocess_cli.py: serialize list-form system prompt to JSON when building CLI args
  • tests/test_transport.py: tests for list-form system_prompt CLI arg serialization

Testing

  • Tests for list-form system_prompt CLI arg serialization (multi-block and single-block)
  • Regression guard: existing string-form tests still pass
  • Regression guard: None system_prompt still emits empty --system-prompt arg
  • All 94 existing tests pass

Related Issue

Closes #899

…#899)

The Anthropic Messages API supports system as either a string or a list
of content blocks (for cache_control etc.). The SDK previously only
accepted strings for system_prompt.

- types.py: broaden system_prompt type to str | list[dict[str, Any]] | SystemPromptPreset | SystemPromptFile | None
- subprocess_cli.py: serialize list-form system prompt to JSON when building CLI args
- tests/test_transport.py: tests for list-form, string, and None system_prompt CLI arg handling
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.

subprocess CLI rejects list-form system_prompt (Anthropic API supports it)

1 participant