Skip to content

feat(tool): enhance check_task with subagent visibility #400

@randomm

Description

@randomm

Motivation

The check_task tool currently returns only status + last 200 chars of output for running tasks. A parent agent checking on a subagent sees "running" but has no idea if it is making progress or stalled. This makes it impossible for an autonomous system to detect and act on stuck subagents.

Proposed Solution

Extend TaskResult with three new fields for running tasks:

interface TaskResult {
  // ... existing fields ...
  stallDetected?: boolean       // true if stall timeout exceeded
  lastToolCalls?: {             // last 3 tool calls
    name: string                // tool name (e.g., "read", "edit")
    status: string              // "running" | "completed" | "error"
    time: string                // ISO timestamp when tool was invoked
  }[]
  lastActivity?: string         // ISO timestamp of last meaningful stream event
}

Data sources (all already exist in the codebase):

  • SessionStatus.get(sessionId) — busy/idle state
  • Session.messages({sessionID}) — message history with ToolPart entries that have state.time.start, state.time.end, state.status
  • The stall detector from EPIC: Subagent LLM stall detection and visibility #398 sets session status to "failed" on stall

Implementation approach:

  • In checkSessionTask() (lines 87-91), when status is "busy", query the last 3-5 messages for ToolPart entries
  • Extract the 3 most recent tool calls with name, status, and timestamp
  • Read lastActivity from the stall detector metadata (or fall back to last message timestamp)
  • Return all new fields in the TaskResult

Quality Gates (Non-Negotiable)

  • TDD: Write tests before implementation
  • Coverage: 80%+ test coverage for new code
  • Linting: All code passes project linting rules
  • Local Verification: All tests pass locally before completion

Acceptance Criteria

  • TaskResult interface extended with stallDetected, lastToolCalls, lastActivity
  • Running tasks return the 3 most recent tool calls with name, status, and timestamp
  • stallDetected is true when the stall detector has fired for this session
  • lastActivity reflects the timestamp of the last token or tool call
  • Existing check_task behavior unchanged for completed/failed tasks
  • Test coverage for new fields

Definition of Done

  • Tests written and passing
  • Typecheck passes
  • Linting passes

Dependencies

Fork Manifest Requirement

This issue modifies the subagent monitoring system introduced by the async-tasks fork feature. Upon completion, update .fork-features/manifest.json entry async-tasks:

  • criticalCode: Add stallDetected, lastToolCalls, lastActivity
  • absorptionSignals: Add stallDetected, lastToolCalls, lastActivity

This ensures sync-time agents understand the visibility enhancement and can verify it survives upstream merges.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions