Skip to content

Agent turn ends silently after promising to continue (end_turn on a one-shot claude -p) #59

Description

@ngochuy13

A long agent turn stops silently in the middle of a multi-phase task. The assistant writes "now I'm moving on to Phase 1 ... I'll do the remaining phases and report each one", and then nothing happens. No error, no spinner, no "stopped" state — the turn pill just shows the final timing and the chat goes idle. The user has to type something ("???") to make it continue, and it then does Phase 1 fine.

Not a one-off: it is reproducible with any long prompt whose instructions say "report after each phase".

Repro

  1. Chat tab, agent Claude Code, model DeepSeek-V4-Flash-0731 (grid relay).
  2. Send a long one-shot prompt with numbered phases containing the instruction "do the phases in order, report each phase as you finish it, don't dump everything at the end".
  3. Agent runs Phase 0 (92 tool calls, 8m54s), prints the Phase 0 report ending with "now I'm moving on to Phase 1 ... I'll do the remaining phases and report each one".
  4. Turn ends there. Phase 1 never starts.
  5. Send any message ("???") → it starts Phase 1 immediately and keeps going.

Evidence

~/.grid/logs/app-20260824.log — the turn exits clean, no failure path:

[14:49:21] INFO agent  DeepSeek-V4-Flash-0731: replaying this chat into a new session…
[14:58:16] INFO cli    claude -p DeepSeek-V4-Flash-0731 (agent) → ok (8m54s)

Claude Code transcript ~/.claude/projects/-Users-macbook-WorkPlace-Hackathon-me-phim/cdac1d90-….jsonl, last assistant record of that turn (07:58:15.754Z):

stop_reason:    end_turn
input_tokens:   120718      (limit is 256000 — not a context wall)
output_tokens:  833
model:          DeepSeek-V4-Flash-0731

Every earlier assistant record in the turn is stop_reason: tool_use (92 of them). Only the last one is end_turn: the model returned plain text with no tool_use block.

Turn stats from the stored chat: 145 requests, 8,835,492 tokens in, 60,101 out, first token 4.9s, 534,313 ms total.

Why it happens

claude -p is one-shot: an assistant message with no tool_use block ends the process. So end_turn == the app's turn is over, whatever the text says.

The model treated "report after each phase" as "report and hand control back". It finished Phase 0, marked its task item complete, wrote the recon doc, printed the report, and ended the turn — while the sentence it ended on is a promise to continue, not a completion. Weaker/faster models (DeepSeek-V4-Flash here) do this far more than the frontier ones.

Nothing on our side cut it short: there is no --max-turns on the Claude Code path (only Hermes pins agent.max_turns), no timeout fired, no stop was requested, context was at 47% of the window.

Why it reads as a bug to the user

The turn looks successful and finished. There is no signal that the work stopped at Phase 0 of 5. The only difference between "done" and "abandoned mid-plan" is the wording of the last paragraph, which nobody reads as a state.

Suggested fixes (in order of how much we'd like them)

  1. Auto-continue an unfinished plan. The agent still had open items in its own task list (TaskUpdate had just marked feat(grid overview): codex usage, and split self-host vs subscription #1 of N complete) when it returned end_turn. If a turn ends with open tasks, send an automatic continue nudge instead of idling — capped (e.g. 3 auto-continues) and visible in the UI so it can't loop forever.
  2. Relay / system-prompt side: for CLI-seat models served through the grid, append a turn-discipline line ("never end a turn with a statement of intent — if you say you will do X next, do X in the same turn"). Cheapest fix, helps every agent on that model, but it is a nudge, not a guarantee.
  3. At minimum, make the state honest. If a turn ends with open task items, don't render it as a plain finished turn — show "stopped with N steps left" plus a Continue button (§5: every state must be actionable). Today the user has to guess that "???" is the fix.

Option 3 is the floor; 1 is the real fix.

Environment

  • Grid app on main @ 2adef4d, macOS 15 (Darwin 25.5.0), Apple Silicon
  • grid CLI 0.3.19
  • Agent: Claude Code, model DeepSeek-V4-Flash-0731 via grid relay
  • 2026-08-24 14:49–14:58 (+07)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions