Skip to content
refs

Track work-cycle review and outcome events in PostHog

Aman Kumarcommitted Oct 9, 20264f72cdeparent 693f06f

Capture human direction of live agents, resolved review threads, human pushes to task branches, and task-linked pull requests closed without a merge. Make the execution context a required parameter of agent sessions and mentions. Plannotator review returned no changes requested. All 106 tests, typecheck, production build, and diff checks pass.

4 decisions

Treat one task as one work cycle, identified by repo_id and task_number, and derive review rounds and outcomes from ordered events.

Why

  • Task numbers are stable and already on every work event
  • A separate cycle ID adds no information while one task holds one cycle of work

Assumes

  • The first agent.directed on a task is usually the assignment, not a redirect

Touches

  • analytics.ts
  • product-analytics.md

Capture agent.directed inside deliverMentions, only for a person naming a live agent session.

Why

  • Every path that directs an agent goes through deliverMentions
  • Mentions of no live session do not direct work

Touches

  • mentions.ts

Count a human push to an existing tasks/<n> branch as work.corrected and a task-linked pull request closed without a merge as work.rejected.

Why

  • These are the cheapest server-side signals of human correction and negative outcomes
  • Neither sends code, text, or branch names

Assumes

  • Pilot interviews confirm rejection reasons and correction size

Touches

  • index.ts

Pass the execution context as a required parameter to agentSessions and deliverMentions.

Why

  • Optional context silently dropped analytics in some paths

Touches

  • sessions.ts
  • mentions.ts
  • mcp.ts
10 files changed · +123 −33
apps/backend/analytics.ts+3 −1
apps/backend/index.ts+28 −11
apps/backend/mcp.ts+2 −2
apps/backend/mentions.ts+8 −3
apps/backend/sessions.ts+6 −6
apps/backend/test/direction-analytics.test.ts+49 −0
apps/backend/test/permissions.test.ts+5 −5
apps/backend/test/presence.test.ts+4 −4
apps/backend/test/sessions.test.ts+1 −1
docs/product-analytics.md+17 −0