Repository navigation
Description
Summary
A Subagent that ends a run with no final text on a StopNoProgress (or empty StopEndTurn) terminal returns the bare placeholder (subagent produced no summary) to the parent — with no explanation of why and no attempt to recover the work the child actually did across its turns. The parent loses everything the child found.
This violates the intended invariant (and the directive that a child should always return something recoverable, even on failure).
Where it happens
The salvage path that recovers a partial summary from an empty terminal only triggers on the limit/budget stops:
engine/agent/subagent.go — salvageEmptyLimitStop (issue #48):
func salvageEmptyLimitStop(...) (string, session.Usage) {
if stop != session.StopMaxTurns && stop != session.StopMaxToolCalls && stop != session.StopBudget {
return finalText, usage // StopNoProgress / empty StopEndTurn fall straight through
}
...When StopNoProgress (or StopEndTurn with empty finalText) reaches renderSubagentResult, it lands in the success family and produces the placeholder:
if strings.TrimSpace(body) == "" {
body = "(subagent produced no summary)"
}The note switch in renderSubagentResult also has no StopNoProgress case, so even the placeholder carries no "why".
Why it surfaced now
Observed live with a model-router config routing the large subagent category to z-ai/glm-5.2. Slow reasoning models are exactly the ones that emit reasoning-only / empty turns → get nudged (finishTurnNoTools) → exhaust MaxNoProgressNudges → terminate StopNoProgress with empty finalText. The faster deepseek-v4-pro ("medium") children finished cleanly; the glm-5.2 ("large") children returned empty. In a multi-wave fan-out this means whole branches of delegated work came back as (subagent produced no summary).
Proposed fix
- Extend the salvage trigger to also fire on
StopNoProgressand emptyStopEndTurn(renamesalvageEmptyLimitStop→salvageEmptyStop); drive the same bounded one-turn wrap-up to extract a summary of what the child found. - Add a
StopNoProgressnote inrenderSubagentResult(e.g.[subagent stopped: ended without a final summary]) so the parent learns the reason. - Last-resort fallback: if salvage still yields nothing, digest the child's last assistant/tool activity instead of the bare placeholder, so the work is never silently lost. (The team path already digests
LastText/completed-task for non-recording members — precedent exists.) - As part of the work, confirm there is no path where the Subagent result is truly empty (a raw Go error bubbling past the renderer rather than a rendered tool error).
All changes are confined to the failure path; the happy and limit paths are unchanged.
Acceptance
- A subagent ending on
StopNoProgress/ emptyStopEndTurnreturns a non-empty, model-addressable result with theagentId:trailer, the stop reason, and salvaged-or-digested content. - Tests cover
StopNoProgressand emptyStopEndTurnsalvage paths.
Related: #153 (Bash discards partial output on runner error) — failure paths discarding recoverable information is the shared anti-pattern. Builds on #48.
Activity
fix(agent): recover subagent work instead of an empty result on no-pr…