Map task run failure into the run-result envelope error field - #491
Merged
chubes4 merged 3 commits intoAug 26, 2026
Merged
Conversation
The task converter was the only run-result envelope producer whose `error` and `cancellation` fields were permanently empty. `to_run_result_envelope()` read `$normalized['error']`, `$normalized['cancellation']`, and `$normalized['evidence_refs']`, but `normalize_run()` whitelists keys and never emits any of those three — so they always fell through to empty defaults. A `STATUS_FAILED` task run stores its failure under `diagnostics` (see `agents_run_task`), which was never mapped to `envelope.error`, so failed task runs carried no error at all. Make the contract honest, mirroring the Runtime/Workflow producers that carry their own error map: - Map a failed run's `diagnostics` (error_code/error_message + raw diagnostics) into the canonical `envelope.error`, guaranteeing failed runs always carry a non-empty error. - Populate `cancellation` from the run status for cancelling/cancelled runs. - Drop the dead `evidence_refs` read (normalize_run has no such source). - Keep successful runs with empty error and empty cancellation. Adds smoke coverage asserting a failed run produces a non-empty error carrying the diagnostics, a cancelled run populates cancellation, and a successful run stays empty. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chubes4
marked this pull request as ready for review
August 26, 2026 21:51
This was referenced Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Task run results use the canonical run-result envelope, but failed task runs stored their failure details under
diagnosticswhile the converter always emitted an emptyerror. This left task failures inconsistent with the runtime and workflow envelope producers.Fix
errorfield.error_codeanderror_messagetoerror.codeanderror.message, preserving the raw diagnostics undererror.data.diagnostics.agents_task_run_failed/The task run failed.fallbacks when diagnostics are missing.errorempty.updated_atis the cancellation request time; no persisted request timestamp currently exists.evidence_refsread, which had no normalized source.Testing
php tests/run-result-envelope-smoke.php- 36 assertions passed.php tests/task-execution-smoke.php- 59 assertions passed; raw task behavior unchanged.composer test- passed.composer phpstan- no errors.git diff --check- clean.