docs(subagent): note the settlement-fold optimization condition

This commit is contained in:
Hypatia May
2026-08-10 17:06:07 +08:00
parent ccbaedc8a8
commit 0a4bdd8ee8
@@ -65,6 +65,10 @@ export class AssistantOutputFold {
* @returns the selected output, or `undefined` when the child produced none.
*/
export function finalAssistantOutput(events: readonly SessionEvent[]): ContentBlock[] | undefined {
// TODO: this folds the complete suffix once per run/epoch settlement. If a
// long continuable epoch ever profiles hot here, scan backward with early
// exit for the last non-empty message and fold text deltas only on the
// no-message fallback.
const fold = new AssistantOutputFold()
for (const event of events) fold.push(event)
return fold.collect()