Skip to content

feat: implement fork agent with parent context inheritance - #1471

Draft
zhanba wants to merge 1 commit into
mainfrom
feat-fork-agent
Draft

feat: implement fork agent with parent context inheritance#1471
zhanba wants to merge 1 commit into
mainfrom
feat-fork-agent

Conversation

@zhanba

@zhanba zhanba commented Apr 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds a new built-in fork agent type that inherits the parent conversation's full message history, enabling context-aware parallel sub-tasks
  • Introduces buildForkMessages / buildForkDirective utilities that clone the parent messages (with fresh IDs) and append a structured fork directive as a final user turn
  • Refactors getBuiltinSubAgentInfo into a shared helper in @getpochi/common, removing duplicated agent-type switch logic from use-live-sub-task and tool-call-approval-button
  • Filters <fork-directive> messages out of the UI formatter (same as <system-reminder>) so they are never rendered to the user
  • Passes parent messages through FlexibleChatTransportcreateNewTaskMiddleware so fork tasks are seeded with full context at creation time

Test plan

  • Run unit tests: bun run test in packages/common
  • Verify buildForkDirective wraps directive text correctly
  • Verify buildForkMessages clones parent history and appends directive as new user message with fresh IDs
  • Verify formatters.ui strips fork-directive messages from rendered output
  • Spawn a fork agent from the UI and confirm it receives the parent conversation context

🤖 Generated with Pochi | Task

@codecov-commenter

codecov-commenter commented Apr 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.90476% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.45%. Comparing base (c413217) to head (61898c5).
⚠️ Report is 385 commits behind head on main.

Files with missing lines Patch % Lines
.../common/src/vscode-webui-bridge/types/sub-agent.ts 6.66% 14 Missing ⚠️
packages/common/src/base/agents/fork-messages.ts 75.00% 9 Missing ⚠️
...bui/src/features/tools/hooks/use-live-sub-task.tsx 0.00% 5 Missing ⚠️
.../approval/components/tool-call-approval-button.tsx 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1471      +/-   ##
==========================================
+ Coverage   19.41%   19.45%   +0.04%     
==========================================
  Files         703      705       +2     
  Lines       66504    66565      +61     
  Branches     1632     1588      -44     
==========================================
+ Hits        12909    12950      +41     
- Misses      53316    53336      +20     
  Partials      279      279              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zhanba zhanba changed the title feat: add fork agent for context-aware parallel sub-tasks feat: implement fork agent with parent context inheritance Apr 21, 2026
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.

2 participants