Skip to content

fix(agent-runner): reconcile orphaned running conversations - #665

Merged
pikann merged 4 commits into
Paca-AI:masterfrom
kayahk:fix/orphaned-running-conversations
Oct 29, 2026
Merged

pikann merged 4 commits into
Paca-AI:masterfrom
kayahk:fix/orphaned-running-conversations

Conversation

@kayahk

@kayahk kayahk commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #664

What changed

  • Add startup reconciliation for running conversations whose ephemeral sandbox is no longer live.
  • Fail them with a conditional update and publish the terminal status event, allowing the API to advance queued triggers.
  • Exclude non-LLM and static-environment conversations; give fresh dispatches a five-minute grace window; leave all rows untouched if backend listing fails.
  • Implement live conversation discovery for Kubernetes Jobs and Docker containers.

Verification

  • go test ./... in services/agent-runner — passed.
  • go vet ./... in services/agent-runner — passed.
  • git diff --check — passed.

The targeted regression tests cover stale/live/grace/environment/ACP decisions and Kubernetes active-vs-failed Job discovery. No live cluster test was run; the startup behavior is guarded against backend-list and conditional-update failures.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes

Reviewed the full two-commit PR (startup reconciliation of orphaned running conversations, plus the follow-up that ignores terminal sandbox Jobs), and traced the decision logic, both sandbox backends, and the publishing path against handler.publishTerminalStatus and services/realtime's router.

  • Startup reconciliation — reconcileRunningConversationsOnStartup lists running rows, diffs them against the backend's live set, and fails orphans via FailIfNotTerminal then publishes terminal status. Backgrounded and fail-safe on listing/update errors, matching the issue's acceptance criteria.
  • Pure decision function — shouldReapRunningConversation correctly leaves non-llm, environment-backed, live-sandbox, and within-grace rows untouched; table-tested.
  • Backend live sets — Docker (running containers by labelConvID) and Kubernetes (non-terminal managed Jobs) implementations are correct, and only the two Managers implement Backend. Build and targeted tests pass locally.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

Re-reviewed the delta since the prior pullfrog review (head eae7dc9), which is the single follow-up commit 9cc3690 plus its new test.

  • Routed orphan-failure events through the realtime context resolver — reconcileRunningConversationsOnStartup now calls GetConversationRealtimeContext and passes the resolved ownerAccountID into PublishRealtime, matching handler.publishTerminalStatus. Global-chat and owner-private project-chat failures now reach the owner room; shared project chats keep their project authz. On lookup failure the event is skipped, but PublishConversationStatus still fires so the queue still advances.
  • Added reconcile_realtime_test.go — new scenario test covering global / owner-private / shared project routing plus the lookup-failure path; it is gated on PACA_RECONCILE_TEST_DSN so it is skipped in CI.

The prior inline thread on the nil-actor routing is resolved by this commit.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pikann pikann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thank you for the contribution! 🚀

@pikann
pikann merged commit 9788ff7 into Paca-AI:master Oct 29, 2026
5 checks passed
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] agent-runner restart leaves running conversations orphaned and stalls the agent queue

2 participants