How the investment-team Skill Runs 4 Parallel AI Agents: A Technical Deep Dive

The investment-team skill orchestrates four specialized AI agents by invoking the Task tool four times in a single message with run_in_background: true, enabling concurrent execution of business analysis, financial analysis, industry research, and risk assessment.

The investment-team skill in the xbtlin/ai-berkshire repository implements a sophisticated multi-agent architecture for investment research. This open-source framework demonstrates how to run 4 parallel AI agents to analyze a target company simultaneously, significantly reducing research time while maintaining rigorous analytical standards.

The Four-Role Parallel Architecture

This skill implements a "four-role parallel analysis framework" that divides research responsibilities among specialized sub-agents. According to the source code in skills/investment-team.md, the workflow creates distinct roles:

  • business-analyst: Examines the target company's business model, competitive moat, and user value
  • financial-analyst: Validates quantitative data and financial metrics using commands from tools/financial_rigor.py
  • industry-researcher: Analyzes sector landscape and competitive positioning
  • risk-assessor: Evaluates investment risks and potential downside scenarios

Each agent operates independently but contributes to a unified team structure coordinated by the team-lead.

Step-by-Step Implementation

The parallel execution follows a precise orchestration protocol defined in skills/investment-team.md and exposed through codex-prompts/investment-team.md.

Creating the Research Team

First, the skill initializes a team context using the TeamCreate tool. The team name derives from the target company (e.g., meituan-research), with the current user assigned as team-lead.

TeamCreate:
  team_name: "meituan-research"
  agent_type: "team-lead"

Defining the Four Tasks

Next, the skill registers four distinct tasks via TaskCreate. Each task specifies a subject, detailed description, and an activeForm that maps to one of the four analyst roles.

TaskCreate:
  subject: "分析Meituan商业模式、护城河与用户价值"
  description: |
    1. 商业模式本质…
    2. 护城河分析…
  activeForm: "business-analyst"

This process repeats for financial-analyst, industry-researcher, and risk-assessor, establishing the work scope for each parallel agent.

Launching Agents in Parallel

The critical parallelism occurs when the skill issues a single message containing four Task invocations. As specified in the source code at lines 11-12 of skills/investment-team.md: "4个Agent必须并行启动——在同一条消息中调用4次Task工具" (The 4 agents must start in parallel — call the Task tool 4 times in the same message).

Task:
  - subagent_type: "general-purpose"
    run_in_background: true
    team_name: "meituan-research"
    name: "business-analyst"
    prompt: |
      你是Meituan投研团队中的"业务分析师"…
      完成任务 #1:分析Meituan商业模式…

  - subagent_type: "general-purpose"
    run_in_background: true
    team_name: "meituan-research"
    name: "financial-analyst"
    prompt: |
      你是Meituan投研团队中的"财务分析师"…
      完成任务 #2:分析Meituan财务数据…

  - subagent_type: "general-purpose"
    run_in_background: true
    team_name: "meituan-research"
    name: "industry-researcher"
    prompt: |
      你是Meituan投研团队中的"行业研究员"…
      完成任务 #3:分析行业格局…

  - subagent_type: "general-purpose"
    run_in_background: true
    team_name: "meituan-research"
    name: "risk-assessor"
    prompt: |
      你是Meituan投研团队中的"风险评估师"…
      完成任务 #4:评估投资风险…

The run_in_background: true parameter is essential—without it, agents would execute sequentially rather than concurrently.

Aggregation and Shutdown

Once all four agents complete their analysis, they transmit reports via SendMessage directed to the team-lead. After receiving all four inputs, the team-lead aggregates the findings into a structured final report following standards from skills/financial-data.md, executes validation through tools/report_audit.py, and issues shutdown_request messages to terminate the background agents.

SendMessage:
  type: "message"
  recipient: "team-lead"
  content: "<markdown report from the sub‑agent>"

Key Technical Requirements for Parallelism

The investment-team skill relies on specific implementation details to ensure true parallel execution:

  • Single-message dispatch: All four Task tool calls must occur within the same message payload to avoid sequential processing
  • Background execution flags: Each subagent must specify run_in_background: true to prevent blocking operations
  • Shared team context: The team_name parameter ensures all four agents belong to the same coordination group, enabling message passing between the team-lead and sub-agents

Safety Guards and Pre-Checks

Before spawning parallel agents, the skill performs a critical validation check. According to lines 34-47 of skills/investment-team.md, it verifies WebSearch permission availability to ensure agents can retrieve up-to-date market data. This prevents scenarios where background agents launch but cannot access required data sources, which would waste computational resources and produce incomplete analyses.

Summary

  • The investment-team skill divides research into four specialized roles: business analyst, financial analyst, industry researcher, and risk assessor
  • Parallelism requires invoking the Task tool four times in one message with run_in_background: true for each subagent
  • All agents share a team context created via TeamCreate, enabling coordinated communication through SendMessage
  • Pre-execution checks validate WebSearch permissions before consuming resources on parallel execution
  • Final aggregation combines four independent reports into a single investment research document validated by tools/report_audit.py

Frequently Asked Questions

What happens if one of the four parallel agents fails?

If a subagent encounters an error or fails to complete its analysis, the team-lead detects the missing report through timeout mechanisms or failed SendMessage callbacks. The skill handles partial failures by noting the missing analysis in the final aggregated report or prompting for manual intervention, though the exact retry logic depends on the underlying agent orchestration platform.

Can I modify the investment-team skill to run more than four parallel agents?

Yes, you can extend the framework by adding additional TaskCreate definitions and corresponding Task invocations in skills/investment-team.md. However, you must maintain the single-message dispatch pattern and set run_in_background: true for each new agent. Be aware that adding agents increases API call concurrency and may hit rate limits imposed by the underlying AI provider.

Why must all four Task tool calls occur in a single message?

The single-message requirement ensures the underlying execution engine recognizes these as concurrent operations rather than sequential commands. According to the source code in skills/investment-team.md, calling the Task tool four times in separate messages would force the team-lead to wait for each agent to complete before starting the next, eliminating the parallelism benefits and significantly extending research time.

How does the team-lead know when all four agents have finished?

The team-lead monitors incoming SendMessage traffic from the four subagents. Each agent sends its completed report to the team-lead recipient using the SendMessage tool. Once the team-lead receives four distinct reports matching the expected agent names (business-analyst, financial-analyst, industry-researcher, risk-assessor), it triggers the aggregation phase and issues shutdown commands to terminate the background processes.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →