Skip to content

bug: 'API Error: terminated' when agent generates large write operations #488

@hqhq1025

Description

@hqhq1025

Problem

When the agent attempts a large write operation (e.g., replacing ~250 lines in a single Write/Edit tool call), the API response gets terminated mid-generation, resulting in:

API Error: terminated

The session shows a "继续" (Continue) button, suggesting the response was cut off.

Context from screenshot

  • Agent was working on rewriting Phase 2-7 of a SKILL.md file (lines 680-926, ~246 lines)
  • Multiple subagents had completed and returned
  • The agent attempted to replace the entire section in one shot
  • The API call was terminated before the write completed

Likely Cause

The API response exceeded the maximum output token limit or hit a timeout while generating the large content block for the Write/Edit tool call. This is a known limitation when the model tries to output very large code blocks in a single response.

Expected Behavior

  • The agent should either chunk large writes into smaller operations
  • Or the system should handle the termination more gracefully with a retry mechanism
  • The error message could be more descriptive (e.g., "Response too long, try breaking into smaller operations")

Environment

  • Web UI session with Codex/Claude
  • YOLO permission mode
  • Large file editing scenario

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions