From 11fe1aa376f7d9ece4d445533c7c6ee71fd150e8 Mon Sep 17 00:00:00 2001 From: Rocky Date: Sun, 10 May 2026 06:34:32 +0000 Subject: [PATCH 1/2] Export EffortLevel TypeAlias and use it in types (fixes #938)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/claude_agent_sdk/__init__.py | 3 ++- src/claude_agent_sdk/types.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/claude_agent_sdk/__init__.py b/src/claude_agent_sdk/__init__.py index d66541f5..32230df6 100644 --- a/src/claude_agent_sdk/__init__.py +++ b/src/claude_agent_sdk/__init__.py @@ -142,7 +142,8 @@ ToolUseBlock, UserMessage, UserPromptSubmitHookInput, -) + + EffortLevel,) # MCP Server Support diff --git a/src/claude_agent_sdk/types.py b/src/claude_agent_sdk/types.py index 12cdc214..a21fe764 100644 --- a/src/claude_agent_sdk/types.py +++ b/src/claude_agent_sdk/types.py @@ -32,6 +32,8 @@ SettingSource = Literal["user", "project", "local"] +EffortLevel: TypeAlias = EffortLevel + class SystemPromptPreset(TypedDict): """System prompt preset configuration.""" @@ -96,7 +98,7 @@ class AgentDefinition: initialPrompt: str | None = None # noqa: N815 maxTurns: int | None = None # noqa: N815 background: bool | None = None - effort: Literal["low", "medium", "high", "xhigh", "max"] | int | None = None + effort: EffortLevel | int | None = None permissionMode: PermissionMode | None = None # noqa: N815 @@ -1864,7 +1866,7 @@ class ClaudeAgentOptions: See https://docs.anthropic.com/en/docs/build-with-claude/adaptive-thinking. """ - effort: Literal["low", "medium", "high", "xhigh", "max"] | None = None + effort: EffortLevel | None = None """Controls how much effort Claude puts into its response. Works with adaptive thinking to guide thinking depth. From 6b9963bd0ac3324aaafb5bc5275a5d05cb9124c4 Mon Sep 17 00:00:00 2001 From: Rocky Date: Sun, 10 May 2026 06:36:43 +0000 Subject: [PATCH 2/2] Support list-form system_prompt by writing temp JSON file and using --system-prompt-file (fixes #899)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../_internal/transport/subprocess_cli.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/claude_agent_sdk/_internal/transport/subprocess_cli.py b/src/claude_agent_sdk/_internal/transport/subprocess_cli.py index 665e481f..00ab7f0b 100644 --- a/src/claude_agent_sdk/_internal/transport/subprocess_cli.py +++ b/src/claude_agent_sdk/_internal/transport/subprocess_cli.py @@ -230,7 +230,22 @@ def _build_command(self) -> list[str]: cmd.extend(["--system-prompt", self._options.system_prompt]) else: sp = self._options.system_prompt - if sp.get("type") == "file": + # Support list-of-content-blocks form for system_prompt (Anthropic API accepts this). + if isinstance(sp, list): + # Write JSON array to a temporary file and pass via --system-prompt-file so + # the CLI can forward the structured content as-is. + import tempfile + + tmp = tempfile.NamedTemporaryFile("w", delete=False, suffix=".json", encoding="utf-8") + json.dump(sp, tmp) + tmp.flush() + tmp.close() + # Ensure the temporary file is removed when the Python process exits + import atexit, os + + atexit.register(lambda p=tmp.name: os.remove(p) if os.path.exists(p) else None) + cmd.extend(["--system-prompt-file", tmp.name]) + elif sp.get("type") == "file": cmd.extend(["--system-prompt-file", cast(SystemPromptFile, sp)["path"]]) elif sp.get("type") == "preset" and "append" in sp: cmd.extend(