minor tweaks and bug fixes

This commit is contained in:
Ash Prabaker 2025-11-03 18:52:55 +00:00
parent 44c6f5503a
commit 56aa8ee570
No known key found for this signature in database
2 changed files with 16 additions and 8 deletions

View file

@ -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:

View file

@ -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