Skip to content

chore: [vent] cursor-agent crashes (exits non-zero, zero assistant output) immediately… - #693

Merged
getappz merged 5 commits into
masterfrom
task/240-vent-cursor-agent-crashes-exits-non-zero
Sep 16, 2026
Merged

getappz merged 5 commits into
masterfrom
task/240-vent-cursor-agent-crashes-exits-non-zero

Conversation

@getappz

@getappz getappz commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Good — the agentflare-jobs/src/sandbox.rs edit net-zero'd out (I added then removed the diagnostic probe test), so only the real fix remains.

Status

Root cause, found by live reproduction (not guesswork): I ran the actual production dispatch path — agentflare_jobs::sandbox::wrap() building the real bwrap argv, the real cursor-agent binary, the real review-only prompt text — in this sandbox. cursor-agent printed its system/init message, echoed the prompt, then died non-zero with zero assistant turns, stderr: ActionRequiredError: You've hit your usage limit ... set a Spend Limit to continue. That's an exact match for the vent's symptom.

This means problem #1 isn't actually "review-only prompt shape breaks cursor-agent" — it's a plain account/model usage-limit lockout that happens to have hit on review-only-routed items. I traced the escalation path end-to-end (HeadlessOutcome::Failed → workflow last_error → "Workflow failed due to step dependency failure: ..." → classify_and_cooldown → auth_runner::is_rate_limited → per-agent cooldown → dispatch_failure_ceiling's consecutive-failure cap in dashboard/orphan_reconcile.rs) and confirmed all of it is already wired up in this codebase (problem #2's infrastructure already exists, likely from later items #164/#173/#506). The one real gap: is_rate_limited's pattern list didn't cover cursor-agent's own wording standalone (only "usage limit" happened to match by luck), and there was no test locking in the specific "step dependency failure" wrapper (a different message shape than the one existing test covers).

Changes:

  • src/auth_runner.rs: added "spend limit" to RATE_LIMIT_PATTERNS, plus a test with the exact reproduced cursor-agent error text.
  • src/cli/work.rs: added a regression test proving classify_and_cooldown correctly cools down cursor when the real usage-limit error arrives wrapped in the "Workflow failed due to step dependency failure: ..." message (previously only the "One or more steps failed: ..." wrapper had coverage).

Verified: cargo fmt --check clean; cargo clippy --workspace --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedantic (CI's exact flags) clean; 9/9 auth_runner tests, 80/80 cli::work tests, 7/7 agentflare-jobs::sandbox tests pass.

Concern: I did not find or fix a code defect causing the silent infinite loop itself — that machinery looks correctly implemented already. If items are still observed looping past the cap in production, the gap is likely somewhere I didn't trace (e.g., a dispatch path that bypasses agentflare_jobs::Queue), and would need a fresh incident log to pin down.


Opened by claude-code on flared:51bb8de6c33b for item #240 via agentflare.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of account-exhaustion messages containing “spend limit,” correctly classifying them as rate-limited.
    • Workflow failures caused by agent usage limits now trigger the standard 30-minute cooldown.
    • Added coverage for usage-limit messages occurring within dependency-failure reports, ensuring retry timing and cooldowns are applied consistently.

…ded then removed the diagnostic probe test), so only the real fix remains.

## Status

**Root cause, found by live reproduction** (not guesswork): I ran the *actual* production dispatch path — `agentflare_jobs::sandbox::wrap()` building the real `bwrap` argv, the real `cursor-agent` binary, the real review-only prompt text — in this sandbox. `cursor-agent` printed its `system`/`init` message, echoed the prompt, then died non-zero with **zero assistant turns**, stderr: `ActionRequiredError: You've hit your usage limit ... set a Spend Limit to continue`. That's an exact match for the vent's symptom.

This means problem #1 isn't actually "review-only prompt shape breaks cursor-agent" — it's a plain account/model usage-limit lockout that happens to have hit on review-only-routed items. I traced the escalation path end-to-end (`HeadlessOutcome::Failed` → workflow `last_error` → `"Workflow failed due to step dependency failure: ..."` → `classify_and_cooldown` → `auth_runner::is_rate_limited` → per-agent cooldown → `dispatch_failure_ceiling`'s consecutive-failure cap in `dashboard/orphan_reconcile.rs`) and confirmed all of it is already wired up in this codebase (problem #2's infrastructure already exists, likely from later items #164/#173/#506). The one real gap: `is_rate_limited`'s pattern list didn't cover cursor-agent's own wording standalone (only "usage limit" happened to match by luck), and there was no test locking in the specific "step dependency failure" wrapper (a different message shape than the one existing test covers).

**Changes:**
- `src/auth_runner.rs`: added `"spend limit"` to `RATE_LIMIT_PATTERNS`, plus a test with the exact reproduced cursor-agent error text.
- `src/cli/work.rs`: added a regression test proving `classify_and_cooldown` correctly cools down `cursor` when the real usage-limit error arrives wrapped in the `"Workflow failed due to step dependency failure: ..."` message (previously only the `"One or more steps failed: ..."` wrapper had coverage).

**Verified:** `cargo fmt --check` clean; `cargo clippy --workspace --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedantic` (CI's exact flags) clean; 9/9 `auth_runner` tests, 80/80 `cli::work` tests, 7/7 `agentflare-jobs::sandbox` tests pass.

**Concern:** I did not find or fix a code defect causing the *silent infinite loop* itself — that machinery looks correctly implemented already. If items are still observed looping past the cap in production, the gap is likely somewhere I didn't trace (e.g., a dispatch path that bypasses `agentflare_jobs::Queue`), and would need a fresh incident log to pin down.

Agentflare-Branch: task/240-vent-cursor-agent-crashes-exits-non-zero
Agentflare-Item: 240
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 3dfce2f1-b464-4156-a164-62a517bec0ce

📥 Commits

Reviewing files that changed from the base of the PR and between 941c7f2 and df745a3.

📒 Files selected for processing (2)
  • src/auth_runner.rs
  • src/cli/work.rs

Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

The rate-limit classifier now recognizes Cursor-agent messages containing “spend limit”. Tests verify direct classification and the standard 30-minute workflow cooldown.

Changes

Cursor-agent rate-limit detection

Layer / File(s) Summary
Spend-limit pattern and classification tests
src/auth_runner.rs
The rate-limit patterns include "spend limit". Tests cover Cursor-agent usage-limit and standalone spend-limit messages.
Workflow cooldown validation
src/cli/work.rs
A regression test verifies a 30-minute retry delay and persisted cooldown for Cursor-agent usage-limit errors wrapped in a workflow dependency-failure message.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to df745

The change adds coverage for Cursor-agent spend-limit failures and preserves cooldown handling, with no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately identifies the cursor-agent failure symptoms addressed by the pull request. It is somewhat incident-focused rather than fix-focused, but it remains specific and related to the cha…
Description check ✅ Passed The description explains the root cause, changes, tests, verification results, and remaining concern. It does not follow the exact template headings or checklist format, but it provides the required i…
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/240-vent-cursor-agent-crashes-exits-non-zero

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

@getappz

getappz commented Sep 16, 2026

Copy link
Copy Markdown
Owner Author

Tracking this PR for automated review (flared:51bb8de6c33b).

@getappz
getappz merged commit 18b0090 into master Sep 16, 2026
16 checks passed
@getappz
getappz deleted the task/240-vent-cursor-agent-crashes-exits-non-zero branch September 16, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant