Skip to content

fix(harness): retain classified stop cause before host cleanup - #571

Draft
AmirrezaFarnamTaheri wants to merge 1 commit into
tinyhumansai:mainfrom
AmirrezaFarnamTaheri:fix/retain-classified-stop-cause
Draft

AmirrezaFarnamTaheri wants to merge 1 commit into
tinyhumansai:mainfrom
AmirrezaFarnamTaheri:fix/retain-classified-stop-cause

Conversation

@AmirrezaFarnamTaheri

@AmirrezaFarnamTaheri AmirrezaFarnamTaheri commented Oct 23, 2026 •

Copy link
Copy Markdown

Problem

FailureScopeMiddleware::after_agent calls the host policy's finish_run hook before retaining the current classified stop cause. A host may legitimately clear its stop latch in that hook, so a classified failure recorded by a host callback can disappear from AgentRun::failure_cause at the end of the run. OpenHuman's classified_stop_cause_survives_the_latch_cleanup_on_agent_finish regression test exposes this ordering bug.

Change

Capture current_halt_cause before finish_run clears per-run evidence, only when the run does not already carry a cause. Keep an already recorded loop/middleware cause authoritative, and retain the existing cleanup behavior.

The new owner tests cover latch cleanup, preserving an existing cause, and an unclassified run. The middleware documentation now states the finish ordering.

Validation

  • rustfmt --edition 2024 --config skip_children=true on both changed Rust files: passed.
  • git diff --check: passed.
  • The patch applies cleanly to the pinned downstream TinyAgents integration based on a5b4d0f6b8b962b28c4288a8518773743e252343.
  • Focused owner tests: 3 passed, 0 failed with cargo test --manifest-path vendor/tinyagents/Cargo.toml --locked -p tinyagents-harness --no-default-features --lib failure_scope::finish_tests, against the exact patch in the public downstream integration 266ab91419ed55f111aed97313ba1d0e52f7d010.

No host-side fallback or change to failure classification, stop budgets, or latch ownership is introduced.

Downstream regression: AmirrezaFarnamTaheri/openhuman#17

Capture a host's current halt cause during after_agent before finish_run
clears its per-run latch. Preserve an existing AgentRun cause and keep
cleanup behavior unchanged. Cover classified, existing, and unclassified
finalization paths with owner-level regressions.
@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

AmirrezaFarnamTaheri added a commit to AmirrezaFarnamTaheri/tinyagents that referenced this pull request Oct 23, 2026
Backport the owner fix proposed in tinyhumansai#571 so host
finish_run cleanup cannot erase AgentRun.failure_cause. Keep an existing
cause authoritative and retain latch cleanup.

Source-commit: 83b4604
Source-PR: tinyhumansai#571

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