Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

TaskOutput Cannot Retrieve claude-researcher and gemini-researcher Agent Results

Open brycemagera opened this issue 10 months ago • 2 comments

TaskOutput Cannot Retrieve claude-researcher and gemini-researcher Agent Results

Summary

When using the Research skill (/conduct-research) with parallel agents, the perplexity-researcher agent returns results successfully, but claude-researcher and gemini-researcher agents complete their work but cannot be retrieved via TaskOutput tool. The agents finish successfully and write complete transcripts to .jsonl files, but their task IDs become invalid before results can be collected.

Environment

  • Claude Code Version: 2.1.15
  • OS: macOS 26.2 (Build 25C56)
  • Node: v22.15.1
  • Bun: 1.2.21
  • PAI: Custom installation with Research skill

Steps to Reproduce

  1. Launch 3 parallel research agents using the Task tool (invoked via user prompt "do some quick research on ___"):

    Task({
      subagent_type: "perplexity-researcher",
      description: "Research query 1",
      prompt: "Research topic A..."
    })
    
    Task({
      subagent_type: "claude-researcher",
      description: "Research query 2",
      prompt: "Research topic B..."
    })
    
    Task({
      subagent_type: "gemini-researcher",
      description: "Research query 3",
      prompt: "Research topic C..."
    })
    
  2. Agents launch and return agent IDs (e.g., a4f0876, a675f06)

  3. Attempt to retrieve results using TaskOutput:

    TaskOutput({
      task_id: "a4f0876",
      block: true,
      timeout: 120000
    })
    

Expected Behavior

All three agents should:

  1. Complete their research
  2. Return results that can be retrieved via TaskOutput
  3. Provide consistent behavior across all agent types

Actual Behavior

perplexity-researcher: ✅ Works perfectly

  • Returns full results in initial Task output
  • Results available immediately
  • No retrieval issues

claude-researcher: ❌ Retrieval fails

  • Agent launches successfully (returns agent ID)
  • Agent completes work (verified in transcript files)
  • TaskOutput returns: No task found with ID: a4f0876
  • Full transcript exists at: .claude/projects/[project-id]/subagents/agent-a4f0876.jsonl

gemini-researcher: ❌ Same issue as claude-researcher

  • Agent launches successfully (returns agent ID)
  • Agent completes work (verified in transcript files)
  • TaskOutput returns: No task found with ID: a675f06
  • Full transcript exists at: .claude/projects/[project-id]/subagents/agent-a675f06.jsonl

Evidence

Successful Agent Completion

Both claude and gemini agents complete successfully with comprehensive research results:

$ wc -l ~/.claude/projects/[project-id]/subagents/agent-a4f0876.jsonl
      23 agent-a4f0876.jsonl

$ wc -l ~/.claude/projects/[project-id]/subagents/agent-a675f06.jsonl
      26 agent-a675f06.jsonl

Agent Output Verification

Reading the .jsonl transcript shows:

  • Agents load context
  • Execute WebSearch queries
  • Generate formatted research reports
  • Attempt voice notification
  • Complete with SubagentStop event

Sample from claude-researcher transcript (line 17):

{
  "message": {
    "content": [{
      "type": "text",
      "text": "📅 2026-01-21\n\n**📋 SUMMARY:** Conducted focused research...\n\n**✅ RESULTS:**\n\n## Simon Sinek's Complete Bibliography\n..."
    }]
  }
}

TaskOutput Error

TaskOutput(task_id: "a4f0876", block: true, timeout: 120000)
→ Error: No task found with ID: a4f0876

Root Cause Hypothesis

The agents complete so quickly (15-30 seconds) that by the time TaskOutput attempts retrieval, the tasks have been archived/cleaned up from the active task system. The transcript files persist, but the task IDs become invalid.

Possible issues:

  1. Task cleanup happens immediately after SubagentStop event
  2. TaskOutput looks in wrong location for completed subagent tasks
  3. Subagent task IDs use different namespace than expected
  4. Race condition between task completion and task registry cleanup

Impact

Current workaround: Use only perplexity-researcher agents, which return results synchronously in the initial Task output.

Impact on functionality:

  • Research skill works but cannot leverage multi-source validation from all 3 agent types
  • Must launch multiple perplexity agents instead of diverse agent types
  • Loss of unique capabilities from claude-researcher (WebSearch with decomposition) and gemini-researcher (multi-perspective synthesis)

Workaround

Option 1: Use perplexity-researcher only

Launch multiple perplexity agents with different query angles:

Task({ subagent_type: "perplexity-researcher", prompt: "angle 1" })
Task({ subagent_type: "perplexity-researcher", prompt: "angle 2" })
Task({ subagent_type: "perplexity-researcher", prompt: "angle 3" })

Option 2: Parse .jsonl files directly (hacky)

Could modify Research skill to read subagent transcript files directly:

jq -r 'select(.message.role == "assistant") | .message.content[]? | select(.type == "text") | .text' \
  ~/.claude/projects/[project-id]/subagents/agent-[ID].jsonl

Questions

  1. Is this a known issue with subagent task lifecycle management?
  2. Are other users experiencing similar problems with claude-researcher and gemini-researcher?
  3. Should TaskOutput be able to retrieve completed subagent results?
  4. Is there a different tool/approach for collecting subagent outputs?
  5. Should agents write to a shared output file that persists beyond task cleanup?

Additional Context

This issue was discovered while implementing the Research skill for parallel multi-source research. The pattern of "launch N agents, collect results" works perfectly for perplexity-researcher but fails for the other two agent types, despite all agents completing their work successfully.

The inconsistency suggests this may be an implementation difference between how perplexity-researcher returns results (synchronous in Task output) versus how claude-researcher and gemini-researcher are expected to return results (asynchronous via TaskOutput).


Test Case Files:

  • Research subject: Alison Shapira (first test)
  • Research subject: Simon Sinek (second test - reproduced same behavior)
  • Agent transcript locations: ~/.claude/projects/-path/c2db0183-a081-40d5-bf62-36c6c694d01a/subagents/

brycemagera avatar Jan 21 '26 22:01 brycemagera

Thanks for reporting this! We've been doing a major restructuring of PAI's core systems, including a complete redesign of the hook architecture (consolidated from 22 to ~19 hooks), a rewritten Algorithm (now v0.5.1 with PRD-based verification), removal of the observability system, and numerous path/configuration fixes.

This specific issue is addressed by those changes. We're targeting a v3.0 release soon that will include all of this. We appreciate your patience and your help in identifying these issues — it directly informed our redesign work. Stay tuned!

danielmiessler avatar Feb 10 '26 21:02 danielmiessler

Thanks for this detailed report with reproduction steps!

This is a Claude Code platform issue — TaskOutput retrieval behavior is controlled by Claude Code's internal agent management, not by PAI. PAI's Research skill spawns the agents, but the task ID lifecycle and output retrieval are Claude Code internals.

We'd recommend reporting this to https://github.com/anthropics/claude-code/issues if not already done. The Claude Code team can investigate why certain subagent types have different output retrieval behavior.

Closing as outside PAI's scope, but great investigation work!

kaimagnus avatar Feb 15 '26 18:02 kaimagnus