File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @moonshot-ai/kimi-code " : patch
3+ ---
4+
5+ Fallback ACP turn-end stop reason mapping to ` end_turn ` for unknown runtime values.
Original file line number Diff line number Diff line change @@ -56,6 +56,8 @@ export function assistantDeltaToSessionUpdate(
5656 * belong on the JSON-RPC error channel). Returning `end_turn` keeps the
5757 * client unblocked; the caller is expected to log the `error` payload
5858 * separately so the failure is observable in the agent logs.
59+ * Unknown runtime values also fall back to `end_turn` so a newer SDK
60+ * reason cannot leak `undefined` onto the ACP wire.
5961 */
6062export function turnEndReasonToStopReason ( reason : TurnEndReason ) : AcpStopReason {
6163 switch ( reason ) {
@@ -65,6 +67,8 @@ export function turnEndReasonToStopReason(reason: TurnEndReason): AcpStopReason
6567 return 'cancelled' ;
6668 case 'failed' :
6769 return 'end_turn' ;
70+ default :
71+ return 'end_turn' ;
6872 }
6973}
7074
Original file line number Diff line number Diff line change 1+ import { describe , expect , it } from 'vitest' ;
2+
3+ import type { TurnEndReason } from '@moonshot-ai/kimi-code-sdk' ;
4+
5+ import { turnEndReasonToStopReason } from '../src/events-map' ;
6+
7+ describe ( 'turnEndReasonToStopReason' , ( ) => {
8+ it ( 'maps known SDK turn-end reasons to ACP stop reasons' , ( ) => {
9+ expect ( turnEndReasonToStopReason ( 'completed' ) ) . toBe ( 'end_turn' ) ;
10+ expect ( turnEndReasonToStopReason ( 'cancelled' ) ) . toBe ( 'cancelled' ) ;
11+ expect ( turnEndReasonToStopReason ( 'failed' ) ) . toBe ( 'end_turn' ) ;
12+ } ) ;
13+
14+ it ( 'falls back to end_turn for unknown runtime reasons' , ( ) => {
15+ expect ( turnEndReasonToStopReason ( 'interrupted' as TurnEndReason ) ) . toBe ( 'end_turn' ) ;
16+ } ) ;
17+ } ) ;
You can’t perform that action at this time.
0 commit comments