Skip to content

feat(tasks): wire agent server event ingest#2111

Open
tatoalo wants to merge 1 commit intofeat/tasks-event-stream-senderfrom
feat/tasks-agent-server-event-ingest
Open

feat(tasks): wire agent server event ingest#2111
tatoalo wants to merge 1 commit intofeat/tasks-event-stream-senderfrom
feat/tasks-agent-server-event-ingest

Conversation

@tatoalo
Copy link
Copy Markdown
Contributor

@tatoalo tatoalo commented May 8, 2026

Problem

once the backend provides a sandbox event ingest token, the agent server needs to opt into the new sender while preserving the existing local SSE behavior and task completion signaling

Changes

  • read POSTHOG_TASK_RUN_EVENT_INGEST_TOKEN from the agent server env
  • construct the task run event stream sender when the ingest token is present
  • enqueue broadcast and terminal task events into the sender while still serving existing SSE clients
  • drain the sender during agent shutdown and task completion paths

Copy link
Copy Markdown
Contributor Author

tatoalo commented May 8, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@tatoalo tatoalo marked this pull request as ready for review May 8, 2026 15:38
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 8, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/agent/src/server/agent-server.test.ts:272-449
**Repeated `AgentServer` setup violates OnceAndOnlyOnce**

The three `signalTaskComplete` tests each repeat an identical 20+ line `new AgentServer({...}) as unknown as { eventStreamSender, posthogAPI, signalTaskComplete }` cast. Extracting a shared helper (e.g. `createSignalTaskCompleteTestServer()`) would remove the duplication and make future type-shape changes a single-line fix instead of three.

Reviews (1): Last reviewed commit: "feat(tasks): wire agent server event ing..." | Re-trigger Greptile

Comment thread packages/agent/src/server/agent-server.test.ts
@tatoalo tatoalo force-pushed the feat/tasks-agent-server-event-ingest branch from 0da1757 to 99cb219 Compare May 8, 2026 15:50
@tatoalo tatoalo force-pushed the feat/tasks-event-stream-sender branch from ba262d3 to 70c5092 Compare May 8, 2026 15:50
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 8, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/agent/src/server/agent-server.ts:1808-1813
`TASK_COMPLETE` is included in the union type but `enqueueTaskTerminalEvent` is only ever called with `ERROR` in this PR (and nowhere else in the codebase). Listing a type option that is never exercised is a superfluous part — if it becomes needed later it can be added then.

```suggestion
  private enqueueTaskTerminalEvent(
    method: typeof POSTHOG_NOTIFICATIONS.ERROR,
    params: Record<string, unknown>,
  ): void {
```

Reviews (2): Last reviewed commit: "feat(tasks): wire agent server event ing..." | Re-trigger Greptile

@tatoalo tatoalo self-assigned this May 8, 2026
@tatoalo tatoalo requested a review from a team May 8, 2026 16:53
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.

1 participant