Fix unhandled OSError in subprocess and unsafe dict access in subagent (#159)

- agents/s01_agent_loop.py: Add FileNotFoundError/OSError handling in run_bash()
- agents/s04_subagent.py: Same fix + use .get() for block.input['prompt']
  (consistent with .get() already used for 'description' on line 157)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Zhang
2026-04-01 21:00:47 +08:00
committed by GitHub
parent 117e59c541
commit 6511c98631
2 changed files with 7 additions and 2 deletions

View File

@@ -73,6 +73,8 @@ def run_bash(command: str) -> str:
return out[:50000] if out else "(no output)"
except subprocess.TimeoutExpired:
return "Error: Timeout (120s)"
except (FileNotFoundError, OSError) as e:
return f"Error: {e}"
# -- The core pattern: a while loop that calls tools until the model stops --