Skip to content

fix(python): use 'is not None' check for excluded_tools in session methods#596

Merged
patniko merged 1 commit intomainfrom
fix/excluded-tools-empty-list
Feb 27, 2026
Merged

fix(python): use 'is not None' check for excluded_tools in session methods#596
patniko merged 1 commit intomainfrom
fix/excluded-tools-empty-list

Conversation

@patniko
Copy link
Contributor

@patniko patniko commented Feb 27, 2026

Fix truthy check for excluded_tools in create_session and resume_session that silently dropped empty lists ([]), preventing callers from explicitly clearing excluded tools.

This is the remaining half of #487available_tools was already fixed on main.

Closes #487

…thods

Fix truthy check for excluded_tools in create_session and resume_session
that silently dropped empty lists ([]), preventing callers from explicitly
clearing excluded tools.

This is the remaining half of #487 — available_tools was already fixed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 27, 2026 03:40
@patniko patniko requested a review from a team as a code owner February 27, 2026 03:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the Python SDK where truthy checks for excluded_tools in create_session and resume_session methods would silently drop empty lists ([]), preventing callers from explicitly clearing excluded tools. This is the second half of the fix for #487, as available_tools was already corrected to use is not None checks.

Changes:

  • Updated excluded_tools conditional checks from truthy (if excluded_tools:) to explicit None checks (if excluded_tools is not None:) in both create_session and resume_session methods

@github-actions
Copy link

Cross-SDK Consistency Review ✅

I've reviewed this PR for consistency across all SDK implementations (Node.js, Python, Go, .NET).

Finding: No consistency issues detected

This PR fixes a Python-specific bug where the truthy check if excluded_tools: incorrectly dropped empty lists ([]), preventing callers from explicitly clearing excluded tools. The fix changes it to if excluded_tools is not None:, which aligns Python's behavior with the other SDKs:

SDK Handling Supports [] empty list?
Node.js Direct passthrough (excludedTools: config.excludedTools) ✅ Yes
Go Direct assignment (req.ExcludedTools = config.ExcludedTools) ✅ Yes
.NET Direct passthrough (config.ExcludedTools) ✅ Yes
Python After this PR: if excluded_tools is not None: ✅ Yes (fixed)

All SDKs now consistently support the use case from #487: explicitly passing an empty list/array to clear default tools, while also correctly handling None/null/undefined to omit the field.

Verified locations:

  • Node.js: nodejs/src/client.ts lines 539, 619
  • Go: go/client.go lines 494, 591
  • .NET: dotnet/src/Client.cs lines 392, 483
  • Python: python/copilot/client.py lines 500, 678 (this PR)

This PR maintains cross-SDK consistency and completes the fix started in #487. 👍

AI generated by SDK Consistency Review Agent

@patniko patniko merged commit 23a9134 into main Feb 27, 2026
30 checks passed
@patniko patniko deleted the fix/excluded-tools-empty-list branch February 27, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants