Skip to content

fix: sub-agent fatal failure silently ends the main turn without surfacing failure reason #579

Description

@jexShain

使用场景

在 AI 模式下通过 agent 工具派发 general-purpose 子 Agent 时,如果子 Agent 的会话在中途因 LLM 请求失败(401/超时/连接错误等不可恢复错误)进入 Fatal 状态,主会话的当前回合会被 short-circuit 立即结束——用户只看到「思考中」动画消失、提示符直接返回,没有任何子 Agent 失败原因、失败阶段或已完成工作摘要的显示。

实测复现(确定性 5/5):mock 子 Agent 第 2 次模型请求返回 401 → 子循环 Fatal → 主循环 turn 立即结束,中间没有面向用户的失败说明输出(失败摘要写进了 tool result 给模型看,但没有展示给用户)。

期望行为

  • 子 Agent 进入 Fatal 时,在终端明确显示:失败原因(error_category / 错误消息)、失败前已完成的工具步骤摘要(fatal_tool_result 已生成该摘要,仅差展示)。
  • short-circuit 结束主回合的行为保留(避免父循环继续盲目重试),但必须先输出失败信息。
  • 思考中 动画在显示失败信息之后再停止。

验收标准

  1. 子 Agent Fatal 时,终端显示失败原因(含 error_category,如 budget_exhausted / api_error)。
  2. 终端显示失败前已完成的工具调用摘要(工具名 + 结果摘要)。
  3. 主回合仍被 short-circuit 结束(不改变既有控制流),显示顺序:失败信息 → 证据保存提示 → 提示符返回。
  4. 自动化测试覆盖:mock 子 Agent 请求 401 → 断言终端输出包含失败原因与已完成步骤摘要。

边界

补充:相关联的独立修复

测试过程中同时确认 TokenUsage 解析层丢弃了 provider 返回的缓存 token 字段(OpenAI prompt_tokens_details.cached_tokens、Anthropic cache_read_input_tokens/cache_creation_input_tokens),导致 /token 统计把缓存命中计入消耗、数字虚高。该修复独立且小,可作为本 issue 的姊妹 PR 提交。

Activity

  1. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    Thanks for opening this issue. A maintainer will review it when available.

    Before that, please make sure the report includes clear reproduction steps, expected behavior, actual behavior, and environment details.

    Contribution guide: https://github.com/AI-Shell-Team/aish/blob/main/CONTRIBUTING.md

  2. added
    cliCLI and shell UX issue
    configConfiguration-related issue
    toolsTool integration issue
    on Sep 30, 2026
  3. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    This issue looks incomplete. Please update it with the missing information below so maintainers can triage it effectively.

    Missing items:

    • Summary
    • Bug type
    • Steps to reproduce
    • Actual behavior
    • AISH version
    • Operating system
    • Install method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliCLI and shell UX issueconfigConfiguration-related issuetoolsTool integration issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions