Skip to content

Commit 68b3b78

Browse files
test(acp): cover untagged load metadata in the existing replay-activity case
Drop the wall-clock mock-agent fixture; the classifier assertion fails on main without racing the idle gap. AI-assisted; verified with the tests and tools listed above.
1 parent 488d6c2 commit 68b3b78

3 files changed

Lines changed: 10 additions & 99 deletions

File tree

‎apps/server/scripts/acp-mock-agent.ts‎

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ const failLoadSession = process.env.T3_ACP_FAIL_LOAD_SESSION === "1";
6363
const failLoadSessionAfterConfigReplay =
6464
process.env.T3_ACP_FAIL_LOAD_SESSION_AFTER_CONFIG_REPLAY === "1";
6565
const emitLoadReplay = process.env.T3_ACP_EMIT_LOAD_REPLAY === "1";
66-
// GitHub Copilot CLI sends session metadata first, goes quiet while it loads, then replays
67-
// untagged history before answering session/load.
68-
const emitSlowUntaggedLoadReplay = process.env.T3_ACP_EMIT_SLOW_UNTAGGED_LOAD_REPLAY === "1";
6966
const failPrompt = process.env.T3_ACP_FAIL_PROMPT === "1";
7067
// JSON for the `data` of an "Internal error" response to `session/new`, as
7168
// Antigravity sends when its runtime cannot reach its local harness.
@@ -490,8 +487,6 @@ const program = Effect.gen(function* () {
490487
const agent = yield* EffectAcpAgent.AcpAgent;
491488
const nativeCancelRequested = yield* Deferred.make<void>();
492489
const nativeCancelRelease = yield* Deferred.make<void>();
493-
const promptRequested = yield* Deferred.make<void>();
494-
const loadSessionFinished = yield* Deferred.make<void>();
495490
const publishAntigravityCommands = (targetSessionId: string) =>
496491
agent.client.sessionUpdate({
497492
sessionId: targetSessionId,
@@ -693,35 +688,6 @@ const program = Effect.gen(function* () {
693688
if (emitLoadReplay) {
694689
emitLoadReplayNotifications(requestedSessionId);
695690
}
696-
if (emitSlowUntaggedLoadReplay) {
697-
yield* agent.client.sessionUpdate({
698-
sessionId: requestedSessionId,
699-
update: {
700-
sessionUpdate: "available_commands_update",
701-
availableCommands: [{ name: "compact", description: "Compact history" }],
702-
},
703-
});
704-
yield* Deferred.await(promptRequested).pipe(Effect.timeoutOption("1 second"));
705-
yield* agent.client.sessionUpdate({
706-
sessionId: requestedSessionId,
707-
update: {
708-
sessionUpdate: "tool_call_update",
709-
toolCallId: "history-subagent-1",
710-
title: "History subagent",
711-
kind: "other",
712-
status: "in_progress",
713-
},
714-
});
715-
yield* agent.client.sessionUpdate({
716-
sessionId: requestedSessionId,
717-
update: {
718-
sessionUpdate: "agent_message_chunk",
719-
messageId: "history-agent-message",
720-
content: { type: "text", text: "history from an earlier turn" },
721-
},
722-
});
723-
yield* Deferred.succeed(loadSessionFinished, undefined);
724-
}
725691
yield* agent.client.sessionUpdate({
726692
sessionId: requestedSessionId,
727693
update: {
@@ -863,10 +829,6 @@ const program = Effect.gen(function* () {
863829
yield* agent.handlePrompt((request) =>
864830
Effect.gen(function* () {
865831
const requestedSessionId = String(request.sessionId ?? sessionId);
866-
if (emitSlowUntaggedLoadReplay) {
867-
yield* Deferred.succeed(promptRequested, undefined);
868-
yield* Deferred.await(loadSessionFinished);
869-
}
870832
beginAcpMockPrompt(cancelledSessions, requestedSessionId);
871833
promptCount += 1;
872834
if (idleError === "grok-background" && promptCount === 1) {

‎apps/server/src/provider/acp/AcpJsonRpcConnection.test.ts‎

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,52 +1153,6 @@ describe("AcpSessionRuntime", () => {
11531153
),
11541154
);
11551155

1156-
// Live clock: the agent's quiet load phase is subprocess wall time racing the idle gap.
1157-
it.live("keeps untagged history replayed after a quiet session/load out of the next prompt", () =>
1158-
Effect.gen(function* () {
1159-
const runtime = yield* AcpSessionRuntime.AcpSessionRuntime;
1160-
yield* runtime.start();
1161-
1162-
yield* runtime.prompt({
1163-
prompt: [{ type: "text", text: "hi" }],
1164-
});
1165-
const notes = Array.from(
1166-
yield* Stream.runCollect(
1167-
runtime
1168-
.getEvents()
1169-
.pipe(
1170-
Stream.takeUntil(
1171-
(note) => note._tag === "ContentDelta" && note.text === "hello from mock",
1172-
),
1173-
),
1174-
),
1175-
);
1176-
expect(notes.flatMap((note) => (note._tag === "ContentDelta" ? [note.text] : []))).toEqual([
1177-
"hello from mock",
1178-
]);
1179-
expect(notes.map((note) => note._tag)).not.toContain("ToolCallUpdated");
1180-
}).pipe(
1181-
Effect.provide(
1182-
AcpSessionRuntime.layer({
1183-
authMethodId: "test",
1184-
spawn: {
1185-
command: mockAgentCommand,
1186-
args: mockAgentArgs,
1187-
env: {
1188-
T3_ACP_EMIT_SLOW_UNTAGGED_LOAD_REPLAY: "1",
1189-
},
1190-
},
1191-
cwd: process.cwd(),
1192-
resumeSessionId: "mock-session-1",
1193-
sessionLoadReplayIdleGap: "200 millis",
1194-
clientInfo: { name: "t3-test", version: "0.0.0" },
1195-
}),
1196-
),
1197-
Effect.scoped,
1198-
Effect.provide(NodeServices.layer),
1199-
),
1200-
);
1201-
12021156
it.effect("rejects invalid config option values before sending session/set_config_option", () => {
12031157
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "acp-runtime-"));
12041158
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");

‎packages/provider-acp/src/server/runtimeModel.test.ts‎

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe("AcpRuntimeModel", () => {
6666
).toBe(false);
6767
});
6868

69-
it("ignores Grok keepalive chunks when tracking session/load replay activity", () => {
69+
it("ignores keepalive chunks and untagged metadata when tracking session/load replay activity", () => {
7070
expect(
7171
sessionUpdateCountsAsLoadReplayActivity({
7272
sessionId: "session-1",
@@ -76,6 +76,15 @@ describe("AcpRuntimeModel", () => {
7676
},
7777
} satisfies EffectAcpSchema.SessionNotification),
7878
).toBe(false);
79+
expect(
80+
sessionUpdateCountsAsLoadReplayActivity({
81+
sessionId: "session-1",
82+
update: {
83+
sessionUpdate: "available_commands_update",
84+
availableCommands: [{ name: "compact", description: "Compact history" }],
85+
},
86+
} satisfies EffectAcpSchema.SessionNotification),
87+
).toBe(false);
7988
expect(
8089
sessionUpdateCountsAsLoadReplayActivity({
8190
_meta: { isReplay: true },
@@ -91,20 +100,6 @@ describe("AcpRuntimeModel", () => {
91100
).toBe(true);
92101
});
93102

94-
it("does not count untagged session metadata as load replay activity", () => {
95-
const metadata = {
96-
sessionId: "session-1",
97-
update: {
98-
sessionUpdate: "available_commands_update",
99-
availableCommands: [{ name: "compact", description: "Compact history" }],
100-
},
101-
} satisfies EffectAcpSchema.SessionNotification;
102-
expect(sessionUpdateCountsAsLoadReplayActivity(metadata)).toBe(false);
103-
expect(
104-
sessionUpdateCountsAsLoadReplayActivity({ ...metadata, _meta: { isReplay: true } }),
105-
).toBe(true);
106-
});
107-
108103
it("ignores load-replay activity from other sessions while a load gate is active", () => {
109104
expect(
110105
sessionUpdateCountsAsLoadReplayActivity(

0 commit comments

Comments
 (0)