Skip to content

Commit cf48ea8

Browse files
Yuruzuuclaude
andauthored
perf(acp): ACP agents skip decoding output twice for unused diagnostics (pingdotgg#29100)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent ba962f2 commit cf48ea8

2 files changed

Lines changed: 90 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ function makeMockRuntime(input: {
381381
? runtimeInput.protocolLogging
382382
: {
383383
...runtimeInput.protocolLogging,
384+
logIncoming: true,
385+
logOutgoing: true,
384386
logger: (event: EffectAcpProtocol.AcpProtocolLogEvent) =>
385387
Queue.offer(protocolEvents, event).pipe(
386388
Effect.andThen(runtimeInput.protocolLogging.logger?.(event) ?? Effect.void),
@@ -3077,6 +3079,92 @@ describe("AcpAdapterV2", () => {
30773079
}).pipe(Effect.provide(layerTest), Effect.scoped),
30783080
);
30793081

3082+
it.effect("keeps protocol diagnostics off unless a protocol logger is supplied", () =>
3083+
Effect.gen(function* () {
3084+
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3085+
const path = yield* Path.Path;
3086+
const selfInvocation = yield* resolveSelfInvocation();
3087+
const mockAgentPath = yield* path.fromFileUrl(
3088+
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
3089+
);
3090+
const runTurn = Effect.fn("AcpAdapterV2.testProtocolLoggingTurn")(function* (
3091+
name: string,
3092+
nativeLogging?: NonNullable<Parameters<typeof makeAcpAdapterV2>[0]["nativeLogging"]>,
3093+
) {
3094+
const events: Array<EffectAcpProtocol.AcpProtocolLogEvent> = [];
3095+
const instanceId = ProviderInstanceId.make(`acp-test-${name}`);
3096+
const threadId = ThreadId.make(`thread-acp-${name}`);
3097+
const makeRuntime = makeMockRuntime({ childProcessSpawner, mockAgentPath });
3098+
const adapter = yield* makeAcpAdapterV2({
3099+
instanceId,
3100+
flavor: {
3101+
driver: ACP_TEST_DRIVER,
3102+
capabilities: AcpProviderCapabilitiesV2,
3103+
makeRuntime: (runtimeInput) =>
3104+
makeRuntime({
3105+
...runtimeInput,
3106+
protocolLogging: {
3107+
...runtimeInput.protocolLogging,
3108+
logger: (event) =>
3109+
Effect.sync(() => void events.push(event)).pipe(
3110+
Effect.andThen(runtimeInput.protocolLogging.logger?.(event) ?? Effect.void),
3111+
),
3112+
},
3113+
}),
3114+
},
3115+
selfInvocation,
3116+
...(nativeLogging === undefined ? {} : { nativeLogging }),
3117+
});
3118+
const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
3119+
runtimeMode: "full-access",
3120+
interactionMode: "default",
3121+
cwd: process.cwd(),
3122+
});
3123+
const modelSelection = { instanceId, model: "default" } as const;
3124+
const runtime = yield* adapter.openSession({
3125+
threadId,
3126+
providerSessionId: ProviderSessionId.make(`provider-session-acp-${name}`),
3127+
modelSelection,
3128+
runtimePolicy,
3129+
});
3130+
const providerThread = yield* runtime.ensureThread({
3131+
threadId,
3132+
modelSelection,
3133+
runtimePolicy,
3134+
});
3135+
yield* runtime.startTurn(
3136+
makeTurnInput({
3137+
threadId,
3138+
providerThread,
3139+
instanceId,
3140+
runtimePolicy,
3141+
now: yield* DateTime.now,
3142+
ordinal: 1,
3143+
}),
3144+
);
3145+
const terminal = yield* runtime.events.pipe(
3146+
Stream.filter((event) => event.type === "turn.terminal"),
3147+
Stream.runHead,
3148+
);
3149+
assert.equal(Option.getOrThrow(terminal).status, "completed");
3150+
return events;
3151+
});
3152+
3153+
assert.deepEqual(yield* runTurn("protocol-logging-default"), []);
3154+
3155+
const explicit: Array<EffectAcpProtocol.AcpProtocolLogEvent> = [];
3156+
yield* runTurn("protocol-logging-explicit", () => ({
3157+
protocolLogging: {
3158+
logIncoming: true,
3159+
logOutgoing: true,
3160+
logger: (event) => Effect.sync(() => void explicit.push(event)),
3161+
},
3162+
}));
3163+
assert.isTrue(explicit.some((e) => e.direction === "incoming" && e.stage === "raw"));
3164+
assert.isTrue(explicit.some((e) => e.direction === "outgoing"));
3165+
}).pipe(Effect.provide(layerTest), Effect.scoped),
3166+
);
3167+
30803168
it.effect("advertises ACP session notices and shows them as system notices", () =>
30813169
Effect.gen(function* () {
30823170
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;

‎packages/provider-acp/src/server/adapter.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,8 +2367,8 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
23672367
? {}
23682368
: { requestLogger: nativeLogging.requestLogger }),
23692369
protocolLogging: nativeLogging?.protocolLogging ?? {
2370-
logIncoming: true,
2371-
logOutgoing: true,
2370+
logIncoming: false,
2371+
logOutgoing: false,
23722372
logger: () => Effect.void,
23732373
},
23742374
};

0 commit comments

Comments
 (0)