Fix /copy after aborts

This commit is contained in:
Armin Ronacher 2025-12-29 11:54:45 +01:00
parent c193ef74d2
commit e30c4e30cb

View file

@ -1525,7 +1525,13 @@ export class AgentSession {
const lastAssistant = this.messages
.slice()
.reverse()
.find((m) => m.role === "assistant");
.find((m) => {
if (m.role !== "assistant") return false;
const msg = m as AssistantMessage;
// Skip aborted messages with no content
if (msg.stopReason === "aborted" && msg.content.length === 0) return false;
return true;
});
if (!lastAssistant) return null;