Skip to content

fix(engine): stop failed missions from respawning (#2736) - #2760

Merged
serrrfirat merged 2 commits into
stagingfrom
fix/2736-mission-thread-failures
Apr 21, 2026
Merged

serrrfirat merged 2 commits into
stagingfrom
fix/2736-mission-thread-failures

Conversation

@serrrfirat

Copy link
Copy Markdown
Collaborator

Summary

  • mark missions as Failed when a mission thread ends in a terminal failure or hits max iterations
  • keep the existing completion path unchanged so successful missions still transition to Completed
  • add regression tests proving failed/max-iteration missions do not immediately re-fire

Root cause

Mission thread failures were recorded in approach_history, but the mission lifecycle itself stayed Active. Because active cron/event missions remain eligible for future firings, the scheduler kept spawning fresh threads after each broken run, inflating the Missions count.

Testing

  • cargo test -p ironclaw_engine failed_outcome_marks_mission_failed_and_blocks_refire -- --nocapture
  • cargo test -p ironclaw_engine max_iterations_marks_mission_failed_and_blocks_refire -- --nocapture
  • cargo test -p ironclaw_engine outcome_processing_detects_goal_achieved -- --nocapture
  • cargo fmt --all --check

Closes #2736

@github-actions github-actions Bot added size: M 50-199 changed lines risk: low Changes to docs, tests, or low-risk modules contributor: core 20+ merged PRs labels Apr 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the mission processing logic to set the mission status to Failed when a thread outcome results in a failure or reaches maximum iterations. This change prevents the scheduler from continuously re-firing broken missions, resolving a reported runaway-loop issue. Additionally, unit tests were added to verify that these outcomes correctly block subsequent refires. I have no feedback to provide.

@henrypark133 henrypark133 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings:

  1. High - crates/ironclaw_engine/src/runtime/mission.rs:2260, crates/ironclaw_engine/src/runtime/mission.rs:517, crates/ironclaw_engine/src/types/mission.rs:267, src/channels/web/handlers/engine.rs:193: the fix stops refiring by marking failed/max-iteration missions Failed, but Failed is terminal, fire_mission refuses terminal missions, and the only exposed recovery control still calls resume_mission, which only accepts Paused. That means the mission is no longer resumable through the public API after one failed run, despite the intended "stop until resumed" behavior.

Summary:

  • Recommended verdict: Request changes
  • Residual risk: I did not run the local test suite; this review is based on code inspection plus the current PR checks.

@serrrfirat
serrrfirat requested a review from henrypark133 April 21, 2026 08:00

@serrrfirat serrrfirat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the latest mission changes. Allowing resume_mission to recover both Paused and Failed missions closes the API dead-end from the earlier review, and the new regression tests around failed/max-iteration outcomes cover the re-fire guard well.

One low-severity follow-up: when process_mission_outcome flips a mission to Failed, it leaves the mission id in the in-memory active / last_fire_attempt bookkeeping, unlike the pause/complete paths. Status checks still prevent refires, so this looks harmless, but it does leave stale runtime bookkeeping around until restart.

@serrrfirat
serrrfirat merged commit edbf0ea into staging Apr 21, 2026
18 checks passed
@serrrfirat
serrrfirat deleted the fix/2736-mission-thread-failures branch April 21, 2026 10:56
@henrypark133 henrypark133 mentioned this pull request Apr 29, 2026
This was referenced May 7, 2026
theredspoon pushed a commit to theredspoon/ironclaw that referenced this pull request Jun 21, 2026
…ai#2760)

* fix(engine): stop failed missions from respawning (nearai#2736)

* fix(engine): address henrypark133 review — allow failed mission resume (nearai#2760)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: low Changes to docs, tests, or low-risk modules size: M 50-199 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Bash 4/20] Failed mission creates runaway threads and inflates Missions count

2 participants