mirror of
https://github.com/anthropics/claude-code-sdk-python.git
synced 2025-12-23 09:19:52 +00:00
minor tweaks and bug fixes
This commit is contained in:
parent
44c6f5503a
commit
56aa8ee570
2 changed files with 16 additions and 8 deletions
|
|
@ -212,14 +212,7 @@ class SubprocessCLITransport(Transport):
|
|||
# Flag with value
|
||||
cmd.extend([f"--{flag}", str(value)])
|
||||
|
||||
# Add prompt handling based on mode
|
||||
if self._is_streaming:
|
||||
# Streaming mode: use --input-format stream-json
|
||||
cmd.extend(["--input-format", "stream-json"])
|
||||
else:
|
||||
# String mode: use --print with the prompt
|
||||
cmd.extend(["--print", "--", str(self._prompt)])
|
||||
|
||||
# Add options that must come before prompt delimiter
|
||||
if self._options.max_thinking_tokens is not None:
|
||||
cmd.extend(
|
||||
["--max-thinking-tokens", str(self._options.max_thinking_tokens)]
|
||||
|
|
@ -230,9 +223,22 @@ class SubprocessCLITransport(Transport):
|
|||
["--first-turn-tool-choice", json.dumps(self._options.first_turn_tool_choice)]
|
||||
)
|
||||
|
||||
if self._options.final_turn_tool_choice is not None:
|
||||
cmd.extend(
|
||||
["--final-turn-tool-choice", json.dumps(self._options.final_turn_tool_choice)]
|
||||
)
|
||||
|
||||
if self._options.ensure_tool_usage:
|
||||
cmd.append("--ensure-tool-usage")
|
||||
|
||||
# Add prompt handling based on mode (must come last for --print mode)
|
||||
if self._is_streaming:
|
||||
# Streaming mode: use --input-format stream-json
|
||||
cmd.extend(["--input-format", "stream-json"])
|
||||
else:
|
||||
# String mode: use --print with the prompt
|
||||
cmd.extend(["--print", "--", str(self._prompt)])
|
||||
|
||||
# Check if command line is too long (Windows limitation)
|
||||
cmd_str = " ".join(cmd)
|
||||
if len(cmd_str) > _CMD_LENGTH_LIMIT and self._options.agents:
|
||||
|
|
|
|||
|
|
@ -562,6 +562,8 @@ class ClaudeAgentOptions:
|
|||
max_thinking_tokens: int | None = None
|
||||
# Tool choice for first turn only
|
||||
first_turn_tool_choice: ToolChoice | None = None
|
||||
# Tool choice for final turn before ending
|
||||
final_turn_tool_choice: ToolChoice | None = None
|
||||
# Ensure at least one tool is used before conversation ends
|
||||
ensure_tool_usage: bool = False
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue