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
3 changes: 2 additions & 1 deletion src/claude_agent_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
ToolUseBlock,
UserMessage,
UserPromptSubmitHookInput,
)

EffortLevel,)

Comment on lines +145 to 147
# MCP Server Support

Expand Down
17 changes: 16 additions & 1 deletion src/claude_agent_sdk/_internal/transport/subprocess_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Comment on lines +233 to +242
# 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])
Comment on lines +234 to +247
Comment on lines +244 to +247
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(
Expand Down
6 changes: 4 additions & 2 deletions src/claude_agent_sdk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
SettingSource = Literal["user", "project", "local"]


EffortLevel: TypeAlias = EffortLevel

Comment on lines +35 to +36
class SystemPromptPreset(TypedDict):
"""System prompt preset configuration."""

Expand Down Expand Up @@ -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
Comment on lines 99 to 102


Expand Down Expand Up @@ -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.
Expand Down
Loading