Skip to content

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