Skip to content

fix(tracker-intake): exclude terminated sessions from seen issue set#2777

Open
anmol0b wants to merge 1 commit into
AgentWrapper:mainfrom
anmol0b:fix/tracker-intake-exclude-terminated-sessions
Open

fix(tracker-intake): exclude terminated sessions from seen issue set#2777
anmol0b wants to merge 1 commit into
AgentWrapper:mainfrom
anmol0b:fix/tracker-intake-exclude-terminated-sessions

Conversation

@anmol0b

@anmol0b anmol0b commented Jul 17, 2026

Copy link
Copy Markdown

Problem

seenIssueIDs in backend/internal/observe/trackerintake/observer.go built
its "already has a session" set from ListAllSessions, which returns every
session including terminated ones. Once any session — killed, crashed, or a
failed spawn — had ever existed for an issue, that issue's ID stayed in the
seen set forever. The intake poller would then skip the issue on every
subsequent poll, so it never got re-spawned. The issue stayed open in the
tracker, assigned, and silently unworked — no error, no log, no notification.

Fix

seenIssueIDs now also checks sess.IsTerminated, so only live sessions
count as "claiming" an issue:

if sess.IssueID != "" && !sess.IsTerminated {
    seen[sess.IssueID] = true
}

A killed/crashed/failed-spawn session now frees its issue for the next
intake cycle.

Tests

Added to observer_test.go:

  • TestSeenIssueIDsExcludesTerminatedSessions — a live session for an issue
    is still seen even when a terminated session for the same issue exists.
  • TestSeenIssueIDsIgnoresOnlyTerminatedSession — an issue with only a
    terminated session is not marked as seen.
  • TestPollRespawnsIssueAfterTerminatedSession — end-to-end: Poll spawns a
    new session for an issue whose only prior session is terminated.

All three fail on main and pass with the fix. Full package and full
backend suite pass (go test ./...).

Scope

This PR only touches seenIssueIDs's filtering logic and its tests. It does
not:

  • Touch the SQL layer (ListAllSessions / session_store.go) — the
    IsTerminated field is already scanned into domain.SessionRecord from
    the DB, so no query change was needed.
  • Fix bug(lifecycle): reaper cannot terminate dead sessions stuck in blocked/waiting_input state (sticky-state zombie sessions) #2745 (reaper cannot terminate sessions stuck in
    blocked/waiting_input). If a session is stuck rather than properly marked
    terminated, this fix does not help it — that's a separate root cause and
    separate PR.
  • Add any logging/alerting for the silent-skip condition described in the
    issue. Happy to follow up with that in a separate PR if wanted, but kept
    this one scoped to the single root cause.

Fixes #2746

@codebanditssss codebanditssss left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the tracker-intake lifecycle change and its regression coverage. Filtering terminated sessions out of the seen issue set correctly allows killed, crashed, or failed sessions to be retried while live sessions still prevent duplicate work. The focused tests and full backend test suite pass locally. Looks good to merge.

@somewherelostt

Copy link
Copy Markdown
Collaborator

Thanks for contributing to Agent Orchestrator.

This PR is being picked up by the current external contributor on-call pair:

If someone is already working on this, please continue as usual.
The on-call pair is added for visibility, tracking, and support, not to take over the work.
If you need help with review, direction, reproduction, or next steps, please tag @neversettle17-101 and @somewherelostt here.

For faster context or live questions, you can also join the AO Discord.

Join the session here:
https://discord.gg/H6ZDcUXmq

Come by if you want to see what is being built, ask questions, or just hang around with the community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants