feat(ph-ai): subagent tool
Problem
This PR adds a new "subagent" tool that allows the chat agent to delegate independent tasks to autonomous subagents that run in parallel.
Changes
- Added a new
SubagentToolthat can be used to delegate tasks to autonomous subagents - Created a new Temporal workflow
SubagentWorkflowfor processing subagent activities - Implemented Redis stream handling for subagent communication
- Added feature flag control via
has_subagent_tool_feature_flag - Updated the frontend to support and display subagent tool calls
How did you test this code?
Locally + tests coming soon
Changelog: (features only) Is this feature complete?
Could be in the changelog
- #42052
: 2 dependent PRs (#42060
, #42704
) 👈 (View in Graphite) - #42888

master
This stack of pull requests is managed by Graphite. Learn more about stacking.
Wiz Scan Summary
| Scanner | Findings |
|---|---|
| - | |
| 1 |
|
| - | |
| - | |
| - | |
| Total | 1 |
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.
Size Change: +27 B (0%)
Total Size: 3.7 MB
ℹ️ View Unchanged
| Filename | Size | Change |
|---|---|---|
frontend/dist/toolbar.js |
3.7 MB | +27 B (0%) |
I made these updates:
- We now pass a
SubagentTypeto the subagent workflow, right now it's fixed toGENERAL_PURPOSEbut for example I'll have a read-only subagent for research - Added a SubagentUpdateEvent which streams a subagent tool call
- If it's a subagent, the checkpointer is set to False, and we don't track
chat with ai - No new conversation for subagents, it's the same from the parent, this simplifies the
read_data:artifactsPR I did on top of this one - Subagents have a new prompt 😉 😉
Main fixes:
- New subagent tool prompt
- new workflow for all chat agents
- workflow can determine an agent type, which registers certain modes and mode registries
- you can pass
use_checkpointerto the workflow to turn on/off the checkpointer
Query snapshots: Backend query snapshots updated
Changes: 1 snapshots (1 modified, 0 added, 0 deleted)
What this means:
- Query snapshots have been automatically updated to match current output
- These changes reflect modifications to database queries or schema
Next steps:
- Review the query changes to ensure they're intentional
- If unexpected, investigate what caused the query to change
Visual regression: Storybook UI snapshots updated
Changes: 6 snapshots (6 modified, 0 added, 0 deleted)
What this means:
- Snapshots have been automatically updated to match current rendering
- Next CI run will switch to CHECK mode to verify stability
- If snapshots change again, CHECK mode will fail (indicates flapping)
Next steps:
- Review the changes to ensure they're intentional
- Approve if changes match your expectations
- If unexpected, investigate component rendering
Edits:
- Subagent tool is now called
task, the prompt has been improved accordingly - Task tool accepts agent modes as parameters
- Fixed a problem with running parallel subagent, they would go in a deadlock due to the memory nodes being sync, fixed in this PR: https://github.com/PostHog/posthog/pull/42888
- You can now set a
parent_span_idon a chat agent workflow, that will then track traces as a span rather than as a new trace, through a modifiedCallbackHandler, needed for the subagent flow - Cancelling a workflow now cancels all subagent workflows
- Artifacts from subagents are not added to the stream, but rather summarized in the tool call result
🔍 Migration Risk Analysis
We've analyzed your migrations for potential risks.
Summary: 1 Safe | 0 Needs Review | 0 Blocked
✅ Safe
Brief or no lock, backwards compatible
ee.0036_add_is_internal_to_conversation
└─ #1 ✅ AddField
Adding nullable field requires brief lock
model: conversation, field: is_internal
📚 How to Deploy These Changes Safely
AddField:
This operation acquires a brief lock but doesn't rewrite the table.
Deployment uses lock timeouts with automatic retries, so lock contention will cause retries rather than connection pile-up.
Last updated: 2025-12-12 17:04 UTC (eed44ee)