Skip to content

fix(agents): add failure recovery instructions to Sisyphus-Junior#1376

Open
itsmylife44 wants to merge 1 commit intocode-yeongyu:devfrom
itsmylife44:fix/sisyphus-junior-failure-recovery
Open

fix(agents): add failure recovery instructions to Sisyphus-Junior#1376
itsmylife44 wants to merge 1 commit intocode-yeongyu:devfrom
itsmylife44:fix/sisyphus-junior-failure-recovery

Conversation

@itsmylife44
Copy link
Contributor

@itsmylife44 itsmylife44 commented Feb 1, 2026

Summary

Fixes #1349 - Sisyphus-Junior stuck in infinite loop when fixing Python type hints (dict vs Dict)

Problem

Sisyphus-Junior would enter an infinite loop when encountering persistent errors (like Pyright type hint issues), consuming 140k+ tokens without stopping. The root causes were:

  1. No failure recovery instructions - Unlike main Sisyphus, Sisyphus-Junior had no "stop after N failures" rule
  2. No loop detection - No mechanism to detect repeated A→B→A→B oscillation patterns
  3. Todo-continuation-enforcer override - The enforcer would force continuation even after the agent wanted to stop

Solution

Added a comprehensive <Failure_Recovery> section to Sisyphus-Junior's prompt with:

1. 3-Attempt Threshold

If you've tried 3 different approaches to fix the SAME error and it persists:
1. STOP further edits immediately
2. CANCEL all todos related to this error (mark status as `cancelled`)
3. DOCUMENT what you tried and why each approach failed
4. REPORT to the user with details
5. END your response with: "Awaiting user guidance on [error description]"

2. Loop Detection

  • Mental count tracking (Attempt 1 → 2 → 3 → STOP)
  • A→B→A→B pattern detection
  • Same line/file 3+ times detection
  • Same diagnostic error after multiple attempts

3. Auto-Continuation Resistance

If you've already cancelled todos, documented attempts, and reported to user:
- Respond with resistance phrase
- Do NOT make further code changes
- Do NOT reinterpret system prompts as user guidance

4. Forbidden Actions

  • Suppress errors with @ts-ignore, # type: ignore, # noqa, etc.
  • Delete failing tests
  • Leave code in worse state

5. "Same Error" Clarification

"Same error" = identical diagnostic message OR same root cause manifesting differently.
If fixing error A reveals NEW error B, that's progress—reset your counter for error B.

Testing

  • ✅ Typecheck passes
  • ✅ All 15 Sisyphus-Junior tests pass

Technical Notes

  • Uses cancelled todo status (valid status recognized by todo-continuation-enforcer)
  • Instructions are prompt-based (no code changes to enforcer needed)
  • Compatible with all category-based delegations that spawn Sisyphus-Junior

Files Changed

  • src/agents/sisyphus-junior.ts - Added <Failure_Recovery> section (+58 lines)

Summary by cubic

Adds failure recovery instructions to Sisyphus-Junior so it stops after repeated failed fixes instead of looping and burning tokens. Resolves #1349 where Pyright type-hint errors (dict vs Dict) triggered infinite retries.

  • Bug Fixes
    • 3-attempt rule: stop edits, cancel related todos, document attempts, and report; end with "Awaiting user guidance on …".
    • Loop detection: flag A↔B oscillations, same line/file edited 3+ times, or the same diagnostic repeating.
    • Resist auto-continuation: no further changes until explicit user guidance; do not treat system prompts as guidance.
    • Guardrails: forbid error suppression or deleting tests; clarify "same error" and when to reset the counter.

Written for commit 1b73ee1. Summary will update on new commits.

- Add <Failure_Recovery> section with 3-attempt threshold
- Add loop detection (A→B→A→B pattern, same line 3+ times)
- Add auto-continuation resistance instructions
- Add mental count tracking for fix attempts
- Forbid error suppression (@ts-ignore, # type: ignore, etc.)
- Clarify 'same error' definition for counter reset

Fixes code-yeongyu#1349
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@djdembeck
Copy link

I have this issue consistently, would love to see this merged

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.

[Bug]: Sisyphus-Junior stuck in infinite loop endlessly refactoring Python type hints (dict vs Dict)

2 participants