Skip to content

fix: correct boolean parsing in parse_llm_output#1

Open
Joshh99 wants to merge 1 commit intowwcohen:mainfrom
Joshh99:fix-boolean-parsing-bug
Open

fix: correct boolean parsing in parse_llm_output#1
Joshh99 wants to merge 1 commit intowwcohen:mainfrom
Joshh99:fix-boolean-parsing-bug

Conversation

@Joshh99
Copy link

@Joshh99 Joshh99 commented Jan 9, 2026

Problem: bool('False') returns True in Python because any non-empty string is truthy. This caused @subagent functions returning bool to always return True when LLM generated 'False'.

Solution: Special-case boolean type conversion to explicitly check for 'true'/'false' strings (case-insensitive).

Test: Added examples/test_boolean_fix.py to demonstrate the fix with mock LLM

- Fixed boolean parsing bug where bool('False') returned True
- Added proper handling for complex types (tuple, list, dict)
- Complex types now use ast.literal_eval instead of type constructor
- Prevents tuple(string) from converting character-by-character

Comprehensive test suite (test_type_parsing.py) now covers:
- Boolean parsing with various string formats
- Tuple/list/dict parsing with ast.literal_eval
- Integration tests with mock LLM calls

Resolves parsing issues in @subagent decorator for all return types.
@Joshh99 Joshh99 force-pushed the fix-boolean-parsing-bug branch from 71ccc5f to 42f80ea Compare January 19, 2026 14:42
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.

1 participant