fix(worker): surface the real reason a Claude run failed instead of a generic exit-code message

StreamAnalyzer now reads subtype/terminal_reason/errors from the CLI's result
event, and TaskRunner builds a specific ErrorMarkdown from them: max_turns names
the turn budget and points at set_task_config + requeue, api_error passes
through the provider's own message (which carries the reset time), and any
other terminal_reason is appended to the previous generic text instead of
staying invisible. Falls through to the old "exited with code N and no result"
text when there's no terminal_reason at all (a real crash).
This commit is contained in:
mika kuns
2026-08-05 15:55:09 +02:00
parent 83ea429b8a
commit 2ebdadff08
6 changed files with 298 additions and 1 deletions
@@ -105,6 +105,9 @@ public sealed class ClaudeProcess : IClaudeProcess
TokensIn = streamResult.TokensIn,
TokensOut = streamResult.TokensOut,
Blocks = streamResult.Blocks,
ResultSubtype = streamResult.ResultSubtype,
TerminalReason = streamResult.TerminalReason,
Errors = streamResult.Errors,
};
}
@@ -115,12 +118,19 @@ public sealed class ClaudeProcess : IClaudeProcess
return new RunResult
{
ExitCode = exitCode,
// Kept even on failure: a terminal reason like api_error often carries the
// provider's own message (e.g. session-limit + reset time) in this field,
// with nothing useful on stderr.
ResultMarkdown = streamResult.ResultMarkdown,
ErrorMarkdown = error,
SessionId = streamResult.SessionId,
TurnCount = streamResult.TurnCount,
TokensIn = streamResult.TokensIn,
TokensOut = streamResult.TokensOut,
Blocks = streamResult.Blocks,
ResultSubtype = streamResult.ResultSubtype,
TerminalReason = streamResult.TerminalReason,
Errors = streamResult.Errors,
};
}
}