Skip to content

Python: fix(claude): preserve explicit zero limit options - #9159

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
suhasagg:repro-claude-zero-options
Oct 12, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
suhasagg:repro-claude-zero-options

Conversation

@suhasagg

Copy link
Copy Markdown
Contributor

Motivation & Context

ClaudeAgent._prepare_client_options() currently uses truthiness checks when forwarding max_turns and max_budget_usd to SDKOptions.

Because 0 and 0.0 are falsy in Python, explicitly configured zero values are silently omitted. This conflates an explicitly supplied numeric value with an unset (None) option.

This change ensures that explicitly supplied zero values are preserved while maintaining the existing behavior for unset options.

The issue has been independently reproduced by the repository's automated triage workflow.

Description & Review Guide

  • What are the major changes?

    • Replace truthiness checks for max_turns and max_budget_usd with explicit None checks.
    • Add a focused regression test verifying that max_turns=0 and max_budget_usd=0.0 are forwarded to SDKOptions.
  • What is the impact of these changes?

    • Explicitly configured zero values are no longer silently discarded.
    • Unset (None) values continue to be omitted as before.
    • No public API or method signatures are changed.
    • Existing non-zero configuration behavior remains unchanged.
  • What do you want reviewers to focus on?

    • Whether explicit None checks are the appropriate way to distinguish unset configuration from explicitly supplied numeric values.
    • Whether the regression test sufficiently covers both affected options.

Related Issue

Fixes #9157

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the [Contribution Guidelines](https://github.com/microsoft/agent-framework/blob/main/CONTRIBUTING.md)
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The narrow fix correctly distinguishes zero from unset values, with regression coverage for both affected options.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes #9157 by preserving explicit zero-valued limits when configuring the Python Claude SDK.

Changes:

  • Uses explicit None checks for max_turns and max_budget_usd.
  • Adds regression coverage for both zero-valued options.
File Description
python/​packages/​claude/​tests/​test_claude_agent.py Tests forwarding of explicit zero limits.
python/​packages/​claude/​agent_framework_claude/​_agent.py Preserves zero values while continuing to omit unset options.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Merged via the queue into microsoft:main with commit 967d2c6 Oct 12, 2026
49 of 50 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — c568faae Deployed Oct 7, 2026 by suhasagg via team_check #6269
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: ClaudeAgent drops explicit zero values for max_turns and max_budget_usd

3 participants