Parent issue
#744 — loop_guard fallback directive after non-retryable failures
Problem
When the loop_guard detects a non-retryable failure (e.g., "command not found", "permission denied"), it blocks retries but does not emit a fallback directive — the agent gets no structured guidance on what to do instead.
Proposed change (this slice only)
Add a fallback_directive field to ToolGuardrailDecision in agent/tool_guardrails.py:
- When a non-retryable failure is detected, populate
fallback_directive with a structured hint
- The directive describes the recommended alternative action (e.g., "use search_files instead", "use vision_analyze for binary files", "install missing package first")
- Emit this field in the guardrail decision output so the agent loop can consume it
Scope
- Add the field to the dataclass/model
- Populate it in the existing non-retryable failure detection paths
- Estimated diff: ~30-60 lines
- Files:
agent/tool_guardrails.py, possibly agent/tool_diagnostics.py
Dependencies
- None (field addition is self-contained; wiring into the agent loop is a separate child issue)
Testing
- Unit test: non-retryable failure produces a non-empty
fallback_directive
- Unit test: retryable failure produces empty/null
fallback_directive
Parent issue
#744 — loop_guard fallback directive after non-retryable failures
Problem
When the loop_guard detects a non-retryable failure (e.g., "command not found", "permission denied"), it blocks retries but does not emit a fallback directive — the agent gets no structured guidance on what to do instead.
Proposed change (this slice only)
Add a
fallback_directivefield toToolGuardrailDecisioninagent/tool_guardrails.py:fallback_directivewith a structured hintScope
agent/tool_guardrails.py, possiblyagent/tool_diagnostics.pyDependencies
Testing
fallback_directivefallback_directive