fix(gateway+acp): thread stopReason through final event to ACP bridge (#24867)

Complete the stop reason propagation chain so ACP clients can
distinguish end_turn from max_tokens:

- server-chat.ts: emitChatFinal accepts optional stopReason param,
  includes it in the final payload, reads it from lifecycle event data
- translator.ts: read stopReason from the final payload instead of
  hardcoding end_turn

Chain: LLM API → run.ts (meta.stopReason) → agent.ts (lifecycle event)
→ server-chat.ts (final payload) → ACP translator (PromptResponse)
This commit is contained in:
Viz
2026-03-03 00:40:54 -05:00
committed by GitHub
parent b34530a05d
commit 0b3bbfec06
2 changed files with 9 additions and 1 deletions

View File

@@ -423,7 +423,9 @@ export class AcpGatewayAgent implements Agent {
}
if (state === "final") {
this.finishPrompt(pending.sessionId, pending, "end_turn");
const rawStopReason = payload.stopReason as string | undefined;
const stopReason: StopReason = rawStopReason === "max_tokens" ? "max_tokens" : "end_turn";
this.finishPrompt(pending.sessionId, pending, stopReason);
return;
}
if (state === "aborted") {