fix(patrol): harden triage feedback loop safeguards#997
Merged
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
Reviewed by gpt-5.4-20260305 · 809,228 tokens |
150b45c to
d7f0fd6
Compare
d7f0fd6 to
96ecbe5
Compare
96ecbe5 to
f2d69a1
Compare
f2d69a1 to
c5a51a3
Compare
jrf0110
commented
Mar 11, 2026
jrf0110
commented
Mar 11, 2026
…p exclusion - Replace ineffective last_activity_at cooldown with a batch-bead-based cooldown: maybeDispatchTriageAgent now skips dispatch when a failed gt:triage batch bead exists within DISPATCH_COOLDOWN_MS. - Fix crash-loop exclusion to check the failed bead's labels instead of current_hook_bead_id (which is NULL after unhook), preventing unhooked triage agents from slipping through detection.
Escalations are agent/user-initiated and must not be silently dropped by the global cap, which exists to prevent feedback loops from patrol's automatic detections. Without this, low-severity escalations that don't notify the mayor would sit unprocessed with no triage follow-up.
The triage role is only used as a container dispatch-time signal by maybeDispatchTriageAgent, not as a user-facing role. Including it in AgentRole exposed it via the public API (POST /agents, POST /get-or-create-agent), allowing external callers to create agents that skip repo clone and cannot work normal coding beads.
c5a51a3 to
6eb2cf7
Compare
… filter - Exclude escalation-type triage requests from the global cap COUNT query so escalation backlog doesn't suppress patrol's automatic detections (crash_loop, stuck_agent, etc.). - Add second NOT EXISTS clause to detectCrashLoops that checks if the agent is currently hooked to a triage-labeled bead — covers the case where resolveTriage CLOSE_BEAD fails an ordinary bead with the triage agent as the actor.
markijbema
approved these changes
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #988, which merged the initial triage feedback loop fix. This PR addresses review feedback and additional edge cases found during code review:
last_activity_atupdate with a guard that checks for recently-failedgt:triagebatch beads (updated_at > cooldownCutoff), giving a realDISPATCH_COOLDOWN_MSbackoff between retry attempts.detectCrashLoopsto use two complementaryNOT EXISTSchecks — one on the failed bead's labels (stable after unhook) and one on the agent's current hook — preventing both triage batch bead failures and triage resolution actions (e.g.CLOSE_BEAD) from triggering crash-loop detection.MAX_OPEN_TRIAGE_REQUESTSgate and count, so escalation backlog doesn't suppress patrol's automatic detections and low-severity escalations always get triage follow-up.triagefrom publicAgentRoleenum: The triage role is only a container dispatch-time signal — keeping it in the public enum would let external API callers create agents that skip repo clone.Verification
pnpm typecheck— passesVisual Changes
N/A
Reviewer Notes
triagerole dispatch, global cap, crash-loop exclusion) was merged in fix(gastown): replace per-agent JWTs with per-container JWT #988. This PR only contains the fixes for issues identified during review of fix(patrol): harden triage feedback loop safeguards #997.NOT EXISTSuses two clauses: the first (bead labels) is stable post-unhook; the second (current hook) covers theresolveTriageCLOSE_BEAD path where an ordinary bead is failed by the triage agent.