feat(tasks): route slack follow-ups through the queue with per-message actors
Problem
Follow-ups are queued now (#70806), but everything that needs "who sent this one" — credential resolution, reply @-tagging, the permission broker — still reads shared mutable state the next message overwrites. Two people messaging back-to-back get replies tagged to whoever spoke last.
Changes
- Each queued message carries its sender: the follow-up signal gains
actor_user_id+ acontextdict (extension point, holds the sender's Slack id). Additive with defaults, so old histories replay unchanged. - Delivery pins credentials and the token mint to that sender, and records
message_id → sender(redis, 2h TTL). - The relay resolves the @-tag from
message_idfirst (echoed by the agent, see below), falling back to the live actor for pre-rollout runs.mapping.latest_actor_slack_user_idstays as the pre-rollout fallback, marked for removal. - One
slack_actor_state_updatesbuilder inrun_actor.pyfor every writer of the load-bearing keys.
U2 sends a message
▼ signal [message, artifact_ids, message_id, actor_user_id, context{slack_user_id}]
task queue ─▶ send_followup_to_sandbox pins creds/token, records message_id → U2
▼
agent-server runs the turn ─▶ POST relay_message {text, message_id} ◀─ echo from code#3434
▼
relay_slack_message tag = actor(message_id) → live actor → mapping
▼ "@U2 …"
Paired with PostHog/code#3434
The agent-server echoes the initiating message_id on relay_message (that PR). Neither side hard-depends on the other: without the echo the relay uses its fallbacks (correct except rapid multi-user bursts), and an older backend ignores the unknown field. Exact per-message tagging switches on once both ship, with the agent release (npm + sandbox image) as the gating leg. Verified end-to-end locally with the two PRs together.
How did you test this code?
Locally, two-user thread: each reply tags its sender and PostHog attribution follows the speaker. Automated coverage for the pinning, the turn-start actor stamp, and the forwarding/API call shapes.
Automatic notifications
- [ ] Publish to changelog?
- [ ] Alert Sales and Marketing teams?
Docs update
Internal behavior only.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Claude Code (Claude Fable 5).
[!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
- #70454

- #70762
👈 (View in Graphite) - #70806

- #71562

master
This stack of pull requests is managed by Graphite. Learn more about stacking.
🤖 CI report
✅ Bundle size — no change
Uncompressed size of every built .js bundle, compared against the base branch.
Total: 64.81 MiB · no change
No file changed by more than 1000 B.
Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report
✅ Eager graph — within budget
How much code each root ships on the eager path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy import() / React.lazy chunks are not counted.
| Root | Eager (shipped) | Δ vs base | Budget |
|---|---|---|---|
entry (logged-out pages, app bootstrap)src/index.tsx |
1.23 MiB · 22 files | no change | ███░░░░░░░ 28.6% of 4.29 MiB |
authenticated shell (every logged-in page)src/scenes/AuthenticatedShell.tsx |
8.15 MiB · 2,987 files | no change | █████████░ 88.1% of 9.25 MiB |
🟢 node_modules/monaco-editor/ stays out of src/index.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 node_modules/monaco-editor/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx
Largest files eagerly shipped from src/index.tsx
| Size | File |
|---|---|
| 126.8 KiB | ../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.production.min.js |
| 24.6 KiB | ../node_modules/.pnpm/[email protected]/node_modules/buffer/index.js |
| 6.3 KiB | ../node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.production.min.js |
| 4.5 KiB | ../node_modules/.pnpm/@[email protected]/node_modules/@jspm/core/nodelibs/browser/process.js |
| 3.9 KiB | ../node_modules/.pnpm/[email protected]/node_modules/scheduler/cjs/scheduler.production.min.js |
| 1.4 KiB | ../node_modules/.pnpm/[email protected]/node_modules/base64-js/index.js |
| 1.3 KiB | src/RootErrorBoundary.tsx |
| 912 B | ../node_modules/.pnpm/[email protected]/node_modules/ieee754/index.js |
| 789 B | src/scenes/ChunkLoadErrorBoundary.tsx |
| 762 B | src/index.tsx |
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
| Size | File |
|---|---|
| 281.3 KiB | ../node_modules/.pnpm/[email protected]/node_modules/posthog-js/dist/rrweb.js |
| 267.7 KiB | ../node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@posthog/icons/dist/posthog-icons.es.js |
| 235.5 KiB | src/taxonomy/core-filter-definitions-by-group.json |
| 223.2 KiB | ../node_modules/.pnpm/[email protected]/node_modules/posthog-js/dist/module.js |
| 164.0 KiB | src/queries/validators.js |
| 154.3 KiB | ../node_modules/.pnpm/[email protected]/node_modules/re2js/build/index.esm.js |
| 126.8 KiB | ../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.production.min.js |
| 105.8 KiB | src/lib/api.ts |
| 93.3 KiB | ../node_modules/.pnpm/[email protected]/node_modules/prosemirror-view/dist/index.js |
| 93.3 KiB | ../packages/quill/packages/quill/dist/index.js |
Posted automatically by check-eager-graph · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479
✅ Dist folder size — 🔺 +522 B (+0.0%)
Total size of the built frontend/dist folder (all assets), compared against the base branch.
Total: 1333.82 MiB · 🔺 +522 B (+0.0%)
✅ Backend coverage — no measured backend lines changed
🧪 Backend test coverage
No measured backend lines changed in this PR (patch coverage n/a).
Report-only. Patch coverage = changed backend lines covered vs origin/master. Sorted lowest first.
Known gaps: lines covered only by Temporal tests show as uncovered; core line numbers may drift if master changed the same file.
🦔 Hogbox preview · ❌ build failed
The preview didn't come up for commit d9caad1. See the build log for the failing step. It'll retry on the next push.
👀 Auto-assigned reviewers
These soft owners were skipped because they only have minor changes here. Nothing blocks merge, so self-assign if you'd like a look:
@PostHog/team-self-driving(products/slack_app/product.yaml)
Soft owners come from each directory's owners.yaml and each product's product.yaml (resolved nearest-file-wins). The locator after each owner is the file that decided it. Generated files and lockfiles are ignored when deciding ownership.
The run-wide MCP refresh gate can keep one user's OAuth token and MCP servers active for another user's turn. A failed durable actor stamp can also leave permission consumers reading the previous actor.Security Review
Reviews (1): Last reviewed commit: "refactor(tasks): resolve reply mentions ..." | Re-trigger Greptile
PR overview
This PR routes Slack task follow-up messages through the task processing queue and associates each queued message with the Slack actor who sent it. The touched backend activity updates how follow-ups are delivered into the sandbox agent flow.
There is one open security issue affecting actor isolation for queued Slack follow-ups. When the active Slack actor changes, the sandbox credential refresh logic can keep the previous actor’s OAuth token and MCP configuration, which may let a later participant interact with resources available to the earlier actor. No issues have been fixed yet, so the PR still carries a clear cross-user authorization risk until actor changes force credential rebinding.
Open issues (1)
- High: Actor changes do not force credential refresh — products/tasks/backend/temporal/process_task/activities/send_followup_to_sandbox.py:164
Fixed/addressed: 0 · PR risk: 8/10
Did a wrong restack and unintentionally requested review from @PostHog/team-security / @PostHog/hogql / @PostHog/clickhouse . You guys don't need to review, sorry for the noise
Reviews (2): Last reviewed commit: "refactor(tasks): resolve reply mentions ..." | Re-trigger Greptile
Thanks for confirming. Since the current diff still leaves the initial actor’s GitHub credentials in the sandbox for a later participant’s turn, I’ll keep this finding open here until the follow-up fix is available. Please link the GitHub-rebinding PR (or update this branch) when it lands and I can verify and resolve it.