MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / streamWithFinish

Function streamWithFinish

packages/kosong/test/step.test.ts:456–479  ·  view source on GitHub ↗
(
      parts: StreamedMessagePart[],
      finishReason:
        | 'completed'
        | 'truncated'
        | 'tool_calls'
        | 'filtered'
        | 'paused'
        | 'other'
        | null,
      rawFinishReason: string | null,
    )

Source from the content-addressed store, hash-verified

454
455 describe('finishReason propagation', () => {
456 function streamWithFinish(
457 parts: StreamedMessagePart[],
458 finishReason:
459 | 'completed'
460 | 'truncated'
461 | 'tool_calls'
462 | 'filtered'
463 | 'paused'
464 | 'other'
465 | null,
466 rawFinishReason: string | null,
467 ): StreamedMessage {
468 return {
469 id: 'mock',
470 usage: null,
471 finishReason,
472 rawFinishReason,
473 async *[Symbol.asyncIterator](): AsyncIterator<StreamedMessagePart> {
474 for (const part of parts) {
475 yield part;
476 }
477 },
478 };
479 }
480
481 it('copies stream.finishReason onto the StepResult', async () => {
482 const stream = streamWithFinish([{ type: 'text', text: 'hi' }], 'truncated', 'length');

Callers 1

step.test.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected