Commit Graph

6 Commits

Author SHA1 Message Date
Magnus Müller
4ac49de9cf fix(code-use): prevent done() execution inside conditional blocks
Previously, done() calls inside if/else/elif blocks would only show a warning
but still execute, potentially causing tasks to never complete if the condition
wasn't met. This changes the behavior to raise a RuntimeError, forcing the LLM
to restructure code properly.

The proper pattern is:
```python
# Validate and set result variables
if condition:
    result = "success"
else:
    result = "failure"

# Then call done() unconditionally
await done(result, success=True)
```

Changes:
- Upgraded warning to RuntimeError in namespace.py
- Added comprehensive test suite with 5 test cases
- Tests cover if/else/elif blocks and verify standalone done() still works

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 10:03:10 -07:00
Magnus Müller
32999fc570 More robust check for is wrapped => 2025-10-21 21:25:51 -07:00
Magnus Müller
1535bb1aa5 Typo 2025-10-21 20:05:42 -07:00
Magnus Müller
1f35dc3c84 Linter 2025-10-21 20:03:01 -07:00
Magnus Müller
0fd93c6c97 Linter 2025-10-21 20:02:50 -07:00
Magnus Müller
9caa248316 Merge code7 branch changes 2025-10-21 18:55:54 -07:00