> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # BatchPartsProcessor `BatchPartsProcessor` は、ストリーミング中に複数の stream part をまとめて送出頻度を減らす **output processor** です。小さなテキストチャンクを統合してネットワーク負荷を減らし、ユーザー体験を改善するとともに、part をクライアントへ送出するタイミングを制御してストリーミング性能を最適化できます。 ## 使用例 ```typescript import { BatchPartsProcessor } from '@mastra/core/processors' const processor = new BatchPartsProcessor({ batchSize: 5, maxWaitTime: 100, emitOnNonText: true, }) ``` ## コンストラクターパラメーター **options** (`Options`): stream part をまとめるための設定オプション **options.batchSize** (`number`): 送出前にまとめる part の数 **options.maxWaitTime** (`number`): バッチを送出するまでの最大待機時間(ミリ秒)。設定すると、batchSize に達していなくても現在のバッチを送出します **options.emitOnNonText** (`boolean`): テキスト以外の part を検出したときに即座に送出するかどうか ## 戻り値 **id** (`string`): 'batch-parts' に設定された processor の識別子 **name** (`string`): 任意の processor 表示名 **processOutputStream** (`(args: { part: ChunkType; streamParts: ChunkType[]; state: Record; abort: (reason?: string) => never }) => Promise`): ストリーミング出力の part を処理してまとめます **flush** (`(state?: BatchPartsState) => ChunkType | null`): ストリーム終了時に残っているバッチ済み part を強制的に flush します ## 詳細な使用例 ```typescript import { Agent } from '@mastra/core/agent' import { BatchPartsProcessor } from '@mastra/core/processors' export const agent = new Agent({ id: 'batched-agent', name: 'batched-agent', instructions: 'You are a helpful assistant', model: 'openai/gpt-5.6-sol', outputProcessors: [ new BatchPartsProcessor({ batchSize: 5, maxWaitTime: 100, emitOnNonText: true, }), ], }) ``` ## 関連情報 - [Guardrails](https://mastra.zisheng.pro/ja/docs/agents/guardrails)