perf(server): ACP tool updates no longer persist a snapshot per streamed chunk #16682
Mergeddarjss(GitHub profile, opens in a new tab)merged 7 commits into
main fromrefs/pull/16682/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -1462 +1469,21 @@146214691470+/**1471+ * Some agents stream a tool's arguments (a file write's diff, `rawInput`) and1472+ * resend the whole call each time. Persist those with #7279's V1 rule. Output1473+ * the user watches live (command stdout, monitor ticks) and the agent's own1474+ * completed/failed always persist, even when a flavor normalizes the status.1475+ */1476+function shouldPersistToolUpdate(1477+ context: ActiveAcpTurn,1478+ key: string,1479+ previous: AcpToolCallState | undefined,1480+ next: AcpToolCallState,1481+ reportedStatus: AcpToolCallState["status"],1482+): boolean {1483+ const emission = context.toolEmissions.get(key);1484+ const progressLength = toolCallProgressLength(next);1485+ const decision =1486+ reportedStatus === "completed" ||1487+ reportedStatus === "failed" ||1488+ emission === undefined ||1489+ progressLength !== emission.lastEmittedDetailLength
coderabbitai[bot](GitHub profile, opens in a new tab) requested changes
apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts lines 1489 to 1491OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1462,0 +1471,21 @@1471+ * Some agents stream a tool's arguments (a file write's diff, `rawInput`) and1472+ * resend the whole call each time. Persist those with #7279's V1 rule. Output1473+ * the user watches live (command stdout, monitor ticks) and the agent's own1474+ * completed/failed always persist, even when a flavor normalizes the status.1475+ */1476+function shouldPersistToolUpdate(1477+ context: ActiveAcpTurn,1478+ key: string,1479+ previous: AcpToolCallState | undefined,1480+ next: AcpToolCallState,1481+ reportedStatus: AcpToolCallState["status"],1482+): boolean {1483+ const emission = context.toolEmissions.get(key);1484+ const progressLength = toolCallProgressLength(next);1485+ const decision =1486+ reportedStatus === "completed" ||1487+ reportedStatus === "failed" ||1488+ emission === undefined ||1489+ progressLength !== emission.lastEmittedDetailLength1490+ ? { emit: true, skippedSinceEmit: 0 }1491+ : decideToolCallUpdateEmission({apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts lines 1491 to 1496OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1462,0 +1476,21 @@1476+function shouldPersistToolUpdate(1477+ context: ActiveAcpTurn,1478+ key: string,1479+ previous: AcpToolCallState | undefined,1480+ next: AcpToolCallState,1481+ reportedStatus: AcpToolCallState["status"],1482+): boolean {1483+ const emission = context.toolEmissions.get(key);1484+ const progressLength = toolCallProgressLength(next);1485+ const decision =1486+ reportedStatus === "completed" ||1487+ reportedStatus === "failed" ||1488+ emission === undefined ||1489+ progressLength !== emission.lastEmittedDetailLength1490+ ? { emit: true, skippedSinceEmit: 0 }1491+ : decideToolCallUpdateEmission({1492+ previous,1493+ next,1494+ lastEmittedDetailLength: emission.lastEmittedDetailLength,1495+ skippedSinceEmit: emission.skippedSinceEmit,1496+ });coderabbitai[bot](GitHub profile, opens in a new tab) requested changes
apps/server/src/provider/acp/AcpRuntimeModel.ts lines 1017 to 1019OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1000,3 +1000,20 @@10001000 return Math.max(state.detail?.length ?? 0, contentChars, rawOutputChars);10011001 }100210021003+function toolCallVisibleOutput(state: AcpToolCallState): ReadonlyArray<string | undefined> {1004+ const texts: Array<string | undefined> = [state.detail];1005+ const content = state.data.content;1006+ if (Array.isArray(content)) {1007+ for (const entry of content) {1008+ texts.push(1009+ isRecord(entry) ? toolCallContentText(entry as EffectAcpSchema.ToolCallContent) : undefined,1010+ );1011+ }1012+ }1013+ const rawOutput = state.data.rawOutput;1014+ if (typeof rawOutput === "string") {1015+ texts.push(rawOutput);1016+ } else if (isRecord(rawOutput)) {1017+ for (const field of RAW_OUTPUT_TEXT_FIELDS) {1018+ const value = rawOutput[field];1019+ texts.push(typeof value === "string" ? value : undefined);coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed