Skip to content

feat(agentloop): Stagnations-Erkennung + adaptives Stop-Budget (issue #150)#223

Merged
Delqhi merged 1 commit into
mainfrom
feat/issue-150-stall
Jun 16, 2026
Merged

feat(agentloop): Stagnations-Erkennung + adaptives Stop-Budget (issue #150)#223
Delqhi merged 1 commit into
mainfrom
feat/issue-150-stall

Conversation

@Delqhi

@Delqhi Delqhi commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Implements issue #150 (Loop Engineering: Lücke 1). Detects when the stop-gate returns identical OpenCriteria for N consecutive turns and escalates early — saves budget on stuck workers.

What ships

  • cmd/sin-code/internal/agentloop/loop.go: new Loop.StallThreshold field + Loop.MaxStopRejects field + stall-detection logic in the reject-block
  • cmd/sin-code/internal/ledger/store.go: new TypeStallDetected entry type
  • cmd/sin-code/internal/hooks/hooks.go: new StopStalled event
  • cmd/sin-code/internal/agentloop/loop_stall_test.go: 3 new tests

Acceptance criteria (from #150)

  • Identical OpenCriteria over StallThreshold turns → early abort with 'stalled' error
  • Changing criteria reset the stall counter (TestStopGate_Stall_ChangingCriteriaResets)
  • StallThreshold=0 disables detection, backwards-compatible (TestStopGate_Stall_Disabled)
  • go test ./cmd/sin-code/internal/agentloop/... all green

Hard mandates honored

  • M2 (single binary, no CGO): no new deps
  • M3 (verify gate sacred): stall fires after the verify-gate, never short-circuits it
  • M7 (race-clean): 3/3 new tests pass under go test -race -count=1

Diffstat

 4 files changed, 132 insertions(+), 4 deletions(-)

Closes

…150)

What ships:
  - cmd/sin-code/internal/agentloop/loop.go:
    - New Loop.StallThreshold field: 0 disables (backwards-compatible);
      recommended 3.
    - New Loop.MaxStopRejects field: hard cap on stop-gate rejections,
      default 3.
    - State: stopRejects counter + lastCritFingerprint (joined OpenCriteria
      with \x1f separator) + stallCount.
    - Reject-block: tracks consecutive identical OpenCriteria, escalates
      early with 'stop-gate stalled' error when stallCount >= StallThreshold.
      Fires hooks.StopStalled + records ledger.TypeStallDetected.
    - Reject-block: enforces MaxStopRejects with explicit error message.
  - cmd/sin-code/internal/ledger/store.go: new EntryType TypeStallDetected.
  - cmd/sin-code/internal/hooks/hooks.go: new event hooks.StopStalled.
  - cmd/sin-code/internal/agentloop/loop_stall_test.go: 3 new tests
    (escalate, change-resets, disabled).

Acceptance criteria (from #150):
  - [x] Identical OpenCriteria over StallThreshold turns -> early
        abort with 'stalled' error.
  - [x] Changing criteria reset the stall counter.
  - [x] StallThreshold=0 disables detection (backwards-compatible).
  - [x] go test ./cmd/sin-code/internal/agentloop/... all green.

Hard mandates honored:
  - M2 (single binary, no CGO): no new deps.
  - M3 (verify gate sacred): stall fires after the verify-gate, never
    short-circuits it.
  - M7 (race-clean): 3/3 new tests pass under go test -race -count=1.

Refs: #150
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sin-code Ready Ready Preview, Comment, Open in v0 Jun 16, 2026 7:55pm

@Delqhi
Delqhi merged commit 24db15b into main Jun 16, 2026
5 of 11 checks passed
@github-actions

Copy link
Copy Markdown

🏆 CEO Audit — A+ (100.0/100)

Metric Value
Grade A+
Score 100.0/100
Critical findings 0
High findings 0
Profile QUICK
Min grade gate B

📥 Download full report (Markdown)
📊 Download SARIF (for Code Scanning)

Run ~/.config/opencode/skills/ceo-audit/scripts/audit.sh . --profile=QUICK locally to reproduce.

@github-actions

Copy link
Copy Markdown

🏆 CEO Audit — A+ (100.0/100)

Metric Value
Grade A+
Score 100.0/100
Critical findings 0
High findings 0
Medium findings 0
Profile QUICK
Min grade gate B

📥 Download full report (Markdown)

Run ID: 27644103698 · Commit: ${github.sha}

Run ~/.config/opencode/skills/ceo-audit/scripts/audit.sh . --profile=QUICK locally to reproduce.

@Delqhi
Delqhi deleted the feat/issue-150-stall branch June 16, 2026 19:55
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