Skip to content
Merged
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
6 changes: 4 additions & 2 deletions python/packages/claude/agent_framework_claude/_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,11 @@ def _prepare_client_options(self, resume_session_id: str | None = None) -> SDKOp
opts["cwd"] = cwd
if permission_mode := self._settings.get("permission_mode"):
opts["permission_mode"] = permission_mode
if max_turns := self._settings.get("max_turns"):
max_turns = self._settings.get("max_turns")
if max_turns is not None:
opts["max_turns"] = max_turns
if max_budget_usd := self._settings.get("max_budget_usd"):
max_budget_usd = self._settings.get("max_budget_usd")
if max_budget_usd is not None:
opts["max_budget_usd"] = max_budget_usd

# Apply default options
Expand Down
19 changes: 19 additions & 0 deletions python/packages/claude/tests/test_claude_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,25 @@ def test_prepare_client_options_with_settings(self, monkeypatch: pytest.MonkeyPa
assert call_kwargs.get("model") == "opus"
assert call_kwargs.get("max_turns") == 15

def test_prepare_client_options_preserves_explicit_zero_limits(self) -> None:
"""Test that explicit zero limit values are preserved."""
agent = ClaudeAgent(
default_options={
"max_turns": 0,
"max_budget_usd": 0.0,
}
)

with patch("agent_framework_claude._agent.SDKOptions") as mock_opts:
mock_opts.return_value = MagicMock()
agent._prepare_client_options() # type: ignore[reportPrivateUsage]
call_kwargs = mock_opts.call_args[1]

assert "max_turns" in call_kwargs
assert call_kwargs["max_turns"] == 0
assert "max_budget_usd" in call_kwargs
assert call_kwargs["max_budget_usd"] == 0.0

def test_prepare_client_options_with_instructions(self) -> None:
"""Test building options with instructions parameter."""
agent = ClaudeAgent(instructions="Be helpful")
Expand Down
Loading