Skip to content

fix(task): name a messageless error on a failed run - #644

Draft
revan-aleti wants to merge 1 commit into
mainfrom
revan/failure-error-class
Draft

revan-aleti wants to merge 1 commit into
mainfrom
revan/failure-error-class

Conversation

@revan-aleti

Copy link
Copy Markdown
Collaborator

Tl;dr

A failed run whose exception has no message (TimeoutError(), httpx.ConnectError('')) was recorded with an empty error. It now records the exception's class, and its cause's, so these failures can be told apart.

For Reviewers

  • The change: record_task_failure_sync writes failure_text(error) instead of str(error). When str(error) is non-empty, the stored text is unchanged. Only an empty message changes, to TimeoutError or TimeoutError (from ConnectionResetError: peer reset).
  • Subtle part: the cause comes from __cause__, else from __context__ unless __suppress_context__ is set (raise ... from None). It goes one level deep only.
  • How it was tested:
    • pytest tst/unit/task/task_failure_write_retry_test.py tst/unit/task/step_journal_test.py: 58 passed.
    • pytest -n 16 tst/unit: 13,503 passed, 7 skipped.
    • make lint: clean.
    • The new test_a_run_failed_by_a_messageless_error_records_its_class fails on the old code (error == '').

For Agents

  • What Changed:
    • src/agent_env/task/store.py adds failure_text(), and record_task_failure_sync uses it for the error field.
    • tst/unit/task/task_failure_write_retry_test.py adds a formatting test (message kept, bare class, explicit cause, implicit context, suppressed context) and an end-to-end write through LocalSqliteDocumentStore.
  • Constraints: a non-empty message is stored unchanged, because consumers match on error text. The task instance document shape doesn't change.
  • Not in Scope:
    • record_task_cancelled already falls back with str(exc) or "cancelled".
    • step_attempt_failures and context.metadata.failed_steps already carry the error class.
  • Assumptions: str() of an exception raised with no arguments is ''. That's Python semantics, and the reason those runs showed no error.

🤖 Generated with Claude Code

record_task_failure stored str(error), which is empty for TimeoutError(),
httpx.ConnectError('') and other exceptions without a message, so the run
was recorded as failed with no error text. Record the exception's class,
and its cause's, when the message is empty. Runs with a message record it
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant