fix(agent): resolve stuck "Starting agent" step on agent-proxy leg#3045
Merged
Merged
Conversation
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "emit completed agent-step progress on ru..." | Re-trigger Greptile |
b572f5b to
07c335f
Compare
There was a problem hiding this comment.
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.
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.
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_starteddoes arrive over the proxy (which is why responses stream and the gate atbuildConversationItems.tssyncProgressCardis 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.tsnow 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 pluslogWriter.appendRawLinefor snapshot/resume replay). It rides the same leg asrun_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?
agent-server.test.tsasserting the agent emits the completed_posthog/progressfor the "agent" step after session initialization.pnpm --filter @posthog/agent test-- 827 passing (77 inagent-server.test.ts).pnpm --filter @posthog/agent typecheck-- clean.biome linton both touched files -- clean (one pre-existing unrelated warning at line 1304).Automatic notifications