Skip to content

fix(handoff): enforce strict boolean return in _check_handoff_enabled #1377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

mshsheikh
Copy link
Contributor

This patch ensures _check_handoff_enabled() always returns a strict bool, regardless of what the agent’s is_enabled returns.

Problem:

Previously, is_enabled could return a non-boolean truthy/falsy value (e.g., None, 1, "yes"), which could lead to unpredictable behavior in downstream logic, especially in conditionals like:

if await self._check_handoff_enabled(...):

Fix:

Wrapped the result in bool():

if inspect.isawaitable(res):
    res = await res
return bool(res)

This guarantees boolean output while maintaining backward compatibility.

This patch ensures `_check_handoff_enabled()` always returns a strict `bool`, regardless of what the agent’s `is_enabled` returns.

### Problem:
Previously, `is_enabled` could return a non-boolean truthy/falsy value (e.g., `None`, `1`, `"yes"`), which could lead to unpredictable behavior in downstream logic, especially in conditionals like:
```python
if await self._check_handoff_enabled(...):
````

### Fix:

Wrapped the result in `bool()`:
```python
if inspect.isawaitable(res):
    res = await res
return bool(res)
```

This guarantees boolean output while maintaining backward compatibility.
@seratch
Copy link
Member

seratch commented Aug 11, 2025

Since the callable for is_enabled is supposed to return a boolean value, I don't think this change is necessary. Thanks for taking the time for this!

@seratch seratch closed this Aug 11, 2025
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