Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/agent/src/server/agent-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,38 @@ describe("AgentServer HTTP Mode", () => {
{ timeout: 15000, interval: 100 },
);
}, 30000);

it("emits a completed _posthog/progress for the agent step after session initialization", async () => {
await createServer().start();

// Resolves the setup card's "agent" step on the agent-proxy read leg,
// where the orchestrator's Django-only progress event never arrives.
await vi.waitFor(
() => {
const allEntries = appendLogCalls.flat() as Array<{
notification?: {
method?: string;
params?: Record<string, unknown>;
};
}>;
const agentProgress = allEntries.find(
(e) =>
e?.notification?.method === "_posthog/progress" &&
e?.notification?.params?.step === "agent",
);
expect(agentProgress).toBeDefined();
expect(agentProgress?.notification?.params).toMatchObject({
group: "setup:test-run-id",
step: "agent",
status: "completed",
});
expect(typeof agentProgress?.notification?.params?.label).toBe(
"string",
);
Comment thread
charlesvien marked this conversation as resolved.
},
{ timeout: 15000, interval: 100 },
);
}, 30000);
});

describe("getInitialPromptOverride", () => {
Expand Down
22 changes: 22 additions & 0 deletions packages/agent/src/server/agent-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,28 @@ export class AgentServer {
JSON.stringify(runStartedNotification),
);

// Mirror the "agent" setup step onto the ingest leg the client is reading;
// the orchestrator's completed progress only lands in Django.
const agentStartedProgress = {
jsonrpc: "2.0" as const,
method: POSTHOG_NOTIFICATIONS.PROGRESS,
params: {
group: `setup:${payload.run_id}`,
step: "agent",
status: "completed",
label: "Started agent",
},
};
this.broadcastEvent({
type: "notification",
timestamp: new Date().toISOString(),
notification: agentStartedProgress,
});
this.session.logWriter.appendRawLine(
payload.run_id,
JSON.stringify(agentStartedProgress),
);

// Signal in_progress so the UI can start polling for updates
this.posthogAPI
.updateTaskRun(payload.task_id, payload.run_id, {
Expand Down
Loading