Skip to content

fix(agent): resolve stuck "Starting agent" step on agent-proxy leg#3045

Merged
charlesvien merged 1 commit into
mainfrom
fix/agent-emit-agent-step-completed-progress
Jul 1, 2026
Merged

fix(agent): resolve stuck "Starting agent" step on agent-proxy leg#3045
charlesvien merged 1 commit into
mainfrom
fix/agent-emit-agent-step-completed-progress

Conversation

@charlesvien

Copy link
Copy Markdown
Member

Problem

With durable streaming (agent-proxy) on and the write-leg feature flag enabled, the setup checklist's "Starting agent" step spins forever even though the agent responds normally.

The setup progress steps (sandbox, clone, checkout, agent) are emitted by the orchestrator into Django. The agent's own events (_posthog/run_started, message chunks) go through the agent-proxy ingest. A client reading the live proxy stream only receives agent-ingested events, so it never sees the orchestrator's _posthog/progress {step:"agent", status:"completed"}. The three earlier steps render as done only because they were already Django-persisted when the client fetched its single bootstrap snapshot; the durable read leg never re-reads Django mid-run, so the later "agent" completion is invisible. run_started does arrive over the proxy (which is why responses stream and the gate at buildConversationItems.ts syncProgressCard is released), but there is no completed status to reveal, so the row stays on its present-tense in-progress label "Starting agent".

Changes

agent-server.ts now emits its own _posthog/progress {group:"setup:<runId>", step:"agent", status:"completed", label:"Started agent"} right after _posthog/run_started, mirroring that notification's dual write (broadcast over the ingest path plus logWriter.appendRawLine for snapshot/resume replay). It rides the same leg as run_started (proxy or Django), so the proxy read leg finally receives the completion and the step resolves. On the Django leg it is an idempotent, last-write-wins duplicate of the orchestrator's event.

Note: the label is fixed to "Started agent" to match the existing convention. If the orchestrator uses a different completed label there may be a cosmetic last-writer-wins on the label text, but the step resolves either way. The full fix is to have the orchestrator ingest its lifecycle events into the proxy so the proxy stream mirrors the whole run stream; this PR is the in-repo unblock.

How did you test this?

  • Added a unit test in agent-server.test.ts asserting the agent emits the completed _posthog/progress for the "agent" step after session initialization.
  • pnpm --filter @posthog/agent test -- 827 passing (77 in agent-server.test.ts).
  • pnpm --filter @posthog/agent typecheck -- clean.
  • biome lint on both touched files -- clean (one pre-existing unrelated warning at line 1304).

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 07c335f.

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "emit completed agent-step progress on ru..." | Re-trigger Greptile

Comment thread packages/agent/src/server/agent-server.test.ts
@charlesvien charlesvien force-pushed the fix/agent-emit-agent-step-completed-progress branch from b572f5b to 07c335f Compare July 1, 2026 05:11
@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jul 1, 2026
@charlesvien charlesvien enabled auto-merge (squash) July 1, 2026 05:12

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The fix is purely additive — it broadcasts one extra _posthog/progress notification after session initialization and mirrors it to the log writer. No data models, API contracts, or existing code paths are modified. The bot's inline comment about the weak label assertion was marked resolved; while the suggestion (pin to the exact string) wasn't applied, this is a test-quality concern rather than a production risk.

@charlesvien charlesvien merged commit 4ee525d into main Jul 1, 2026
26 checks passed
@charlesvien charlesvien deleted the fix/agent-emit-agent-step-completed-progress branch July 1, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant