mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 20:03:05 +00:00
fix: show retry attempt count when aborting during retry
When aborting a retry attempt, surface the retry-aware abort message in the assistant output and tool results instead of a generic "Aborted". - Set errorMessage for aborted streaming messages - Render abort message without forcing a leading newline when no content
This commit is contained in:
parent
a65da1c14b
commit
01f15fcbd2
3 changed files with 38 additions and 13 deletions
|
|
@ -1559,13 +1559,21 @@ export class InteractiveMode {
|
|||
if (event.message.role === "user") break;
|
||||
if (this.streamingComponent && event.message.role === "assistant") {
|
||||
this.streamingMessage = event.message;
|
||||
let errorMessage: string | undefined;
|
||||
if (this.streamingMessage.stopReason === "aborted") {
|
||||
const retryAttempt = this.session.retryAttempt;
|
||||
errorMessage =
|
||||
retryAttempt > 0
|
||||
? `Aborted after ${retryAttempt} retry attempt${retryAttempt > 1 ? "s" : ""}`
|
||||
: "Operation aborted";
|
||||
this.streamingMessage.errorMessage = errorMessage;
|
||||
}
|
||||
this.streamingComponent.updateContent(this.streamingMessage);
|
||||
|
||||
if (this.streamingMessage.stopReason === "aborted" || this.streamingMessage.stopReason === "error") {
|
||||
const errorMessage =
|
||||
this.streamingMessage.stopReason === "aborted"
|
||||
? "Operation aborted"
|
||||
: this.streamingMessage.errorMessage || "Error";
|
||||
if (!errorMessage) {
|
||||
errorMessage = this.streamingMessage.errorMessage || "Error";
|
||||
}
|
||||
for (const [, component] of this.pendingTools.entries()) {
|
||||
component.updateResult({
|
||||
content: [{ type: "text", text: errorMessage }],
|
||||
|
|
@ -1872,8 +1880,16 @@ export class InteractiveMode {
|
|||
this.chatContainer.addChild(component);
|
||||
|
||||
if (message.stopReason === "aborted" || message.stopReason === "error") {
|
||||
const errorMessage =
|
||||
message.stopReason === "aborted" ? "Operation aborted" : message.errorMessage || "Error";
|
||||
let errorMessage: string;
|
||||
if (message.stopReason === "aborted") {
|
||||
const retryAttempt = this.session.retryAttempt;
|
||||
errorMessage =
|
||||
retryAttempt > 0
|
||||
? `Aborted after ${retryAttempt} retry attempt${retryAttempt > 1 ? "s" : ""}`
|
||||
: "Operation aborted";
|
||||
} else {
|
||||
errorMessage = message.errorMessage || "Error";
|
||||
}
|
||||
component.updateResult({ content: [{ type: "text", text: errorMessage }], isError: true });
|
||||
} else {
|
||||
this.pendingTools.set(content.id, component);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue