feat: add progress-aware run budgets - #86
Conversation
There was a problem hiding this comment.
Review Complete
I've reviewed all the changes in this PR and found the implementation to be solid and production-ready:
✅ src/agent/budget.rs - New budget controller module with comprehensive test coverage and correct logic
✅ src/agent/mod.rs - Proper integration of budget controller into reasoning loop
✅ src/bus.rs - Well-defined budget types with serialization support
✅ AGENTS.md - Documentation updated to reflect new budget system
No blocking issues found. The code correctly implements:
- Multi-dimensional budget tracking (turns, tokens, time, retries, recoveries)
- Observable progress detection with typed root-cause analysis
- Deterministic state machine with proper terminal state handling
- Warning emissions before exhaustion
- Comprehensive test coverage validating all critical paths
The implementation is ready to merge.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
Summary
max_iterationsas the absolute emergency LLM-turn ceiling while also tracking wall time, provider-reported tokens, provider retries, and context recoveries(tool, error code)root causes instead of parsing tool output prosestuck/repeated_root_causestuck/no_progresscompletedthrough prose aloneDefault policy
Regression coverage
Started -> Warning -> Terminated(Stuck)with one terminal eventStuck, notCompletedValidation
cargo fmt --checkcargo clippy --all-targets --all-features -- -D warningscargo test --all-features(432 library tests passed, 6 existing execution tests ignored; 2 binary tests passed)git diff --checkMandatory risk review
run_idandchat_id.Stuck.Integration note
RunLifecycleEventnow includesWarning, andRunBudgetSnapshotcarries the independent counters. Strict host parsers must add the warning variant before pinning this commit; that host-side work is T18.