mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:51:37 +00:00
ACP: rename stream char limits to output/sessionUpdate
This commit is contained in:
@@ -450,7 +450,7 @@ describe("createAcpReplyProjector", () => {
|
||||
enabled: true,
|
||||
stream: {
|
||||
deliveryMode: "live",
|
||||
maxToolSummaryChars: 48,
|
||||
maxSessionUpdateChars: 48,
|
||||
tagVisibility: {
|
||||
tool_call: true,
|
||||
tool_call_update: true,
|
||||
@@ -649,7 +649,7 @@ describe("createAcpReplyProjector", () => {
|
||||
coalesceIdleMs: 0,
|
||||
maxChunkChars: 256,
|
||||
deliveryMode: "live",
|
||||
maxTurnChars: 5,
|
||||
maxOutputChars: 5,
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -194,7 +194,7 @@ export function createAcpReplyProjector(params: {
|
||||
const chunker = new EmbeddedBlockChunker(streaming.chunking);
|
||||
const liveIdleFlushMs = Math.max(streaming.coalescing.idleMs, ACP_LIVE_IDLE_FLUSH_FLOOR_MS);
|
||||
|
||||
let emittedTurnChars = 0;
|
||||
let emittedOutputChars = 0;
|
||||
let truncationNoticeEmitted = false;
|
||||
let lastStatusHash: string | undefined;
|
||||
let lastToolHash: string | undefined;
|
||||
@@ -262,7 +262,7 @@ export function createAcpReplyProjector(params: {
|
||||
clearLiveIdleTimer();
|
||||
blockReplyPipeline.stop();
|
||||
blockReplyPipeline = createTurnBlockReplyPipeline();
|
||||
emittedTurnChars = 0;
|
||||
emittedOutputChars = 0;
|
||||
truncationNoticeEmitted = false;
|
||||
lastStatusHash = undefined;
|
||||
lastToolHash = undefined;
|
||||
@@ -301,7 +301,7 @@ export function createAcpReplyProjector(params: {
|
||||
if (!params.shouldSendToolSummaries) {
|
||||
return;
|
||||
}
|
||||
const bounded = truncateText(text.trim(), settings.maxStatusChars);
|
||||
const bounded = truncateText(text.trim(), settings.maxSessionUpdateChars);
|
||||
if (!bounded) {
|
||||
return;
|
||||
}
|
||||
@@ -332,7 +332,7 @@ export function createAcpReplyProjector(params: {
|
||||
}
|
||||
|
||||
const renderedToolSummary = renderToolSummaryText(event);
|
||||
const toolSummary = truncateText(renderedToolSummary, settings.maxToolSummaryChars);
|
||||
const toolSummary = truncateText(renderedToolSummary, settings.maxSessionUpdateChars);
|
||||
const hash = hashText(renderedToolSummary);
|
||||
const toolCallId = event.toolCallId?.trim() || undefined;
|
||||
const status = normalizeToolStatus(event.status);
|
||||
@@ -424,14 +424,14 @@ export function createAcpReplyProjector(params: {
|
||||
text = `${resolveHiddenBoundarySeparatorText(settings.hiddenBoundarySeparator)}${text}`;
|
||||
}
|
||||
pendingHiddenBoundary = false;
|
||||
if (emittedTurnChars >= settings.maxTurnChars) {
|
||||
if (emittedOutputChars >= settings.maxOutputChars) {
|
||||
await emitTruncationNotice();
|
||||
return;
|
||||
}
|
||||
const remaining = settings.maxTurnChars - emittedTurnChars;
|
||||
const remaining = settings.maxOutputChars - emittedOutputChars;
|
||||
const accepted = remaining < text.length ? text.slice(0, remaining) : text;
|
||||
if (accepted.length > 0) {
|
||||
emittedTurnChars += accepted.length;
|
||||
emittedOutputChars += accepted.length;
|
||||
lastVisibleOutputTail = accepted.slice(-1);
|
||||
if (settings.deliveryMode === "live") {
|
||||
liveBufferText += accepted;
|
||||
|
||||
@@ -12,7 +12,8 @@ describe("acp stream settings", () => {
|
||||
expect(settings.deliveryMode).toBe("final_only");
|
||||
expect(settings.hiddenBoundarySeparator).toBe("paragraph");
|
||||
expect(settings.repeatSuppression).toBe(true);
|
||||
expect(settings.maxTurnChars).toBe(24_000);
|
||||
expect(settings.maxOutputChars).toBe(24_000);
|
||||
expect(settings.maxSessionUpdateChars).toBe(320);
|
||||
});
|
||||
|
||||
it("applies explicit stream overrides", () => {
|
||||
@@ -24,7 +25,8 @@ describe("acp stream settings", () => {
|
||||
deliveryMode: "final_only",
|
||||
hiddenBoundarySeparator: "space",
|
||||
repeatSuppression: false,
|
||||
maxTurnChars: 500,
|
||||
maxOutputChars: 500,
|
||||
maxSessionUpdateChars: 123,
|
||||
tagVisibility: {
|
||||
usage_update: true,
|
||||
},
|
||||
@@ -35,7 +37,8 @@ describe("acp stream settings", () => {
|
||||
expect(settings.deliveryMode).toBe("final_only");
|
||||
expect(settings.hiddenBoundarySeparator).toBe("space");
|
||||
expect(settings.repeatSuppression).toBe(false);
|
||||
expect(settings.maxTurnChars).toBe(500);
|
||||
expect(settings.maxOutputChars).toBe(500);
|
||||
expect(settings.maxSessionUpdateChars).toBe(123);
|
||||
expect(settings.tagVisibility.usage_update).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -8,9 +8,8 @@ const DEFAULT_ACP_REPEAT_SUPPRESSION = true;
|
||||
const DEFAULT_ACP_DELIVERY_MODE = "final_only";
|
||||
const DEFAULT_ACP_HIDDEN_BOUNDARY_SEPARATOR = "paragraph";
|
||||
const DEFAULT_ACP_HIDDEN_BOUNDARY_SEPARATOR_LIVE = "space";
|
||||
const DEFAULT_ACP_MAX_TURN_CHARS = 24_000;
|
||||
const DEFAULT_ACP_MAX_TOOL_SUMMARY_CHARS = 320;
|
||||
const DEFAULT_ACP_MAX_STATUS_CHARS = 320;
|
||||
const DEFAULT_ACP_MAX_OUTPUT_CHARS = 24_000;
|
||||
const DEFAULT_ACP_MAX_SESSION_UPDATE_CHARS = 320;
|
||||
|
||||
export const ACP_TAG_VISIBILITY_DEFAULTS: Record<AcpSessionUpdateTag, boolean> = {
|
||||
agent_message_chunk: true,
|
||||
@@ -32,9 +31,8 @@ export type AcpProjectionSettings = {
|
||||
deliveryMode: AcpDeliveryMode;
|
||||
hiddenBoundarySeparator: AcpHiddenBoundarySeparator;
|
||||
repeatSuppression: boolean;
|
||||
maxTurnChars: number;
|
||||
maxToolSummaryChars: number;
|
||||
maxStatusChars: number;
|
||||
maxOutputChars: number;
|
||||
maxSessionUpdateChars: number;
|
||||
tagVisibility: Partial<Record<AcpSessionUpdateTag, boolean>>;
|
||||
};
|
||||
|
||||
@@ -109,22 +107,18 @@ export function resolveAcpProjectionSettings(cfg: OpenClawConfig): AcpProjection
|
||||
hiddenBoundaryFallback,
|
||||
),
|
||||
repeatSuppression: clampBoolean(stream?.repeatSuppression, DEFAULT_ACP_REPEAT_SUPPRESSION),
|
||||
maxTurnChars: clampPositiveInteger(stream?.maxTurnChars, DEFAULT_ACP_MAX_TURN_CHARS, {
|
||||
maxOutputChars: clampPositiveInteger(stream?.maxOutputChars, DEFAULT_ACP_MAX_OUTPUT_CHARS, {
|
||||
min: 1,
|
||||
max: 500_000,
|
||||
}),
|
||||
maxToolSummaryChars: clampPositiveInteger(
|
||||
stream?.maxToolSummaryChars,
|
||||
DEFAULT_ACP_MAX_TOOL_SUMMARY_CHARS,
|
||||
maxSessionUpdateChars: clampPositiveInteger(
|
||||
stream?.maxSessionUpdateChars,
|
||||
DEFAULT_ACP_MAX_SESSION_UPDATE_CHARS,
|
||||
{
|
||||
min: 64,
|
||||
max: 8_000,
|
||||
},
|
||||
),
|
||||
maxStatusChars: clampPositiveInteger(stream?.maxStatusChars, DEFAULT_ACP_MAX_STATUS_CHARS, {
|
||||
min: 64,
|
||||
max: 8_000,
|
||||
}),
|
||||
tagVisibility: stream?.tagVisibility ?? {},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user