:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Self-driving inbox: agent remediation flow
Historical design for the original single-PR assignment API. The implementation contract is now documented in Signals work claims and pull requests.
Follow-on to PR #92769.
Goal
Let an internal task or an external coding agent claim an actionable report, show that work is underway, and optionally attach one implementation pull request. External-agent remediation must not require a task or any task-backed data.
Actor model
Assignments and report artefacts use four actor kinds:
user: a person acting directly through PostHog or the API.task: an internal PostHog task. This is the only actor kind that references the tasks product.agent: an external MCP coding agent acting on behalf of an authenticated user.system: an automated PostHog process.
For MCP requests without an internal task header, the backend derives the agent name from the MCP client identity forwarded by the MCP server. The authenticated user remains the principal. The client name is attribution metadata, not an authorization boundary.
Existing artefacts are not backfilled. A null actor kind on a legacy row is read as system.
Claim behavior
inbox-reports-claim accepts:
report_id- optional
pr_url - optional
release, defaulting tofalse
Claiming upserts the current assignment. A new actor silently takes over an existing claim. Repeating an identical claim is idempotent.
release=true clears only the owner. It keeps an attached PR and its state. Only the current actor may release a claim. A request cannot combine release=true with pr_url.
Claims do not expire. Expiration and heartbeats are deferred.
Reports in potential, candidate, in_progress, pending_input, ready, or failed may be claimed. Suppressed and resolved reports remain terminal.
Pull requests
A report has at most one attached implementation PR. One PR may be attached to several reports.
The assignment stores the supplied URL and its normalized (repository, pr_number) identity. Replacing the URL updates the assignment and records the before/after values in the activity log.
When the repository is connected, attaching a PR immediately fetches its state. Open and draft PRs put the report in review. A merged PR resolves the report. A closed, unmerged PR suppresses it, matching the existing inbox behavior.
PRs from unconnected repositories are allowed. Their state is unknown, they are treated as in review, and they require a manual state transition because PostHog cannot fetch their state or receive their webhooks.
GitHub webhook matching is scoped by the teams associated with the installation, then matched by normalized repository and PR number. A matching merge or close transitions every unresolved report attached to that PR.
Internal implementation tasks claim their report when they start. When a PR-bearing task run records a PR, the signals receiver copies it into the assignment without requiring the task to call the public claim API. Existing task-backed PRs remain a compatibility fallback for reads, PR actions, dismissal, and webhook handling when an assignment has no PR; a non-empty assignment PR always wins. See PR lifecycle.
Resolving a report never requires a PR. Manual resolution keeps the existing behavior: fixed_outside_posthog describes a fix without a PR, and pr_merged describes a merged PR that did not resolve the report automatically. A direct resolve or suppression closes an attached open PR only when its assignment actor is task or system, or the PR comes from the task-backed fallback, and PostHog can access it. Explicit PRs owned by users or external agents are not modified. A PR stays open while another unfinished report uses it through either source.
Derived work state
Work state is derived in this order:
done: the report is resolved.in_review: an attached PR is open, draft, or unknown.working: the report has an owner and no in-review PR.unclaimed: the report has no owner and no in-review PR.
Pipeline status and remediation work_state remain separate. Claimed reports still appear in actionable views.
Data model
Add SignalReportAssignment, one row per report:
- team and report
- nullable actor kind, authenticated user ID, internal task ID, and external agent name
- optional PR URL, normalized repository and PR number
- optional PR state and merged flag
claimed_at,created_at, andupdated_at
Ownership fields are nullable so release can preserve PR state. External-agent rows never carry a task ID.
Add actor_kind and actor_agent to SignalReportArtefact. Keep created_by and task. New writes persist explicit actor kinds; legacy null kinds serialize as system.
API and MCP surface
- Add
inbox-reports-claimfor claim, takeover, PR attachment, PR replacement, and release. - Keep
inbox-reports-set-statefor resolve, suppress, and restore. - Extend
inbox-reports-listwithunclaimedandassignee=mefilters. - Return
work_state, assignment actor details,claimed_at, PR URL, and PR state from every report list and retrieve response. - Back
has_implementation_pr,implementation_pr_url, andimplementation_pr_mergedfrom the assignment table first, with existing task-backed PRs as a compatibility fallback. - Update list and retrieve agent guidance to claim before starting work. External agents no longer need or create a task association.
assignee=me means the exact current actor: the authenticated user for direct user requests, or the authenticated user plus derived MCP client name for external agents.
Audit trail
Use the existing ActivityLog mechanism with scope=SignalReport. Record claim, takeover, release, PR attachment, and PR replacement as before/after assignment changes. Do not write an entry for an identical repeat request.
No new assignment-history table or assignment artefact type is required.
Deferred work
- Claim expiration and heartbeats.
- Force-takeover or compare-and-swap ownership.
- More than one PR per report.
- Rich assignee search beyond
assignee=me. - Polling or reconciliation for PRs in unconnected repositories.
Follow-up verification
- Model constraints and actor attribution for user, task, agent, system, and legacy rows.
- MCP client-name forwarding, generic MCP fallback, and direct-user attribution.
- Claim, silent takeover, same-actor idempotency, authorized release, and rejected release by another actor.
- Team scoping for claim, retrieve, filtering, and cross-project report IDs.
- PR attach, replace, release-with-PR, connected-state fetch, and unconnected unknown state.
- Derived work state across report status, ownership, and PR state combinations.
unclaimed,assignee=me, andhas_implementation_prlist filtering.- Activity-log before/after entries and no-op suppression.
- Connected webhook scoping, one PR linked to several reports, merge resolution, and closed-unmerged suppression.
- Manual resolve/suppress PR-closing behavior.
- Verify that new task PRs populate assignments and existing task-run-backed PRs remain visible through the fallback.
- OpenAPI generation, generated MCP schema, tool-name lint, MCP typecheck, and focused backend tests.