failure_evidence
failure_evidence
¶
Retry-prompt failure-evidence formatting (#201).
When a sheet is retried, the agent should be told specifically what failed
and directed to fix it, using the deterministic signals already captured on
SheetState at the time of failure — not the generic "study the workspace"
preamble. This closes a feedback loop that previously existed only for
observability: validation results, grounding guidance, error codes, and error
history were captured and surfaced to the dashboard/learning store, but never
fed back into the retry prompt where the agent could act on them.
Design (from the #201 multi-model lab + composer steer):
- Primary signal is structured validation detail + grounding guidance. The
ErrorClassifiererror code is routing metadata (rate-limit / auth / timeout) and says nothing actionable about the dominant failure mode — an agent whose output failed acommand_succeedsvalidation. Lead with what the validations actually reported. - Directive, not merely informative. Showing evidence does not ensure a fix. The block speaks imperatively ("you MUST make these pass"), and when the same error repeats it tells the agent to change strategy rather than retry the same approach. Concise — every character costs.
- The free-text content is UNTRUSTED, never instructions. Validation/command output can be repo-controlled; injected verbatim it could try to redirect the agent. A concise header marks the block as evidence subordinate to the task, and raw stderr is fenced as untrusted data and bounded.
- Structured-over-raw. stderr is the last resort, included only when there are no structured validation failures to point at, and truncated.
Classes¶
Functions:¶
format_failure_evidence
¶
format_failure_evidence(*, error_code=None, error_message=None, validation_details=None, grounding_guidance=None, stderr_tail=None, error_history=None, max_stderr_chars=_DEFAULT_MAX_STDERR_CHARS, observer_events=None, resources=None)
Render a bounded, directive failure-evidence block for a retry preamble.
Returns None when there is nothing useful to report, so the caller can
fall back to the generic retry preamble cleanly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error_code
|
str | None
|
Classified error code from the prior attempt (e.g. E601). |
None
|
error_message
|
str | None
|
Human-readable error summary. |
None
|
validation_details
|
list[ValidationDetailDict] | None
|
Structured per-validation results; only entries
with |
None
|
grounding_guidance
|
str | None
|
Recovery text from a failed grounding hook. |
None
|
stderr_tail
|
str | None
|
Tail of the prior attempt's stderr (fallback signal only). |
None
|
error_history
|
list[str] | None
|
Prior error codes, to surface a repeating failure. |
None
|
max_stderr_chars
|
int
|
Truncation ceiling for |
_DEFAULT_MAX_STDERR_CHARS
|
observer_events
|
list[dict[str, Any]] | None
|
Observer file/process events from the failed attempt's window (#133). Rendered as a compact, bounded runtime summary AFTER the primary signals; never produces a block on its own. |
None
|
resources
|
dict[str, Any] | None
|
Resource state near failure time (#133), e.g.
|
None
|
Returns:
| Type | Description |
|---|---|
str | None
|
A delimited |