













@@ -3865,64 +3865,87 @@ describe("matrix live qa scenarios", () => {
3865386538663866it("keeps Matrix-looking tool progress mentions inert in partial previews", async () => {
38673867const previewEventId = "$tool-progress-mention-preview";
3868-mockMatrixQaRoomClient({
3869-driverEventId: "$tool-progress-mention-trigger",
3870-events: [
3871-{
3872-event: matrixQaMessageEvent({
3873-kind: "message",
3874-eventId: previewEventId,
3875-body: "Working...\n- `tool: read`",
3876-}),
3877-since: "driver-sync-preview",
3878-},
3879-{
3880-event: matrixQaMessageEvent({
3881-kind: "message",
3882-eventId: "$tool-progress-mention-edit",
3883-body: "Working...\n- `tool: read`\n- `read from matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt`",
3884-formattedBody:
3885-"Working...<br><ul><li><code>read from matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt</code></li></ul>",
3886-mentions: {},
3887-relatesTo: {
3888-relType: "m.replace",
3868+const gatewayWorkspaceDir = await mkdtemp(path.join(os.tmpdir(), "matrix-qa-workspace-"));
3869+try {
3870+const { sendTextMessage } = mockMatrixQaRoomClient({
3871+driverEventId: "$tool-progress-mention-trigger",
3872+events: [
3873+{
3874+event: matrixQaMessageEvent({
3875+kind: "message",
38893876eventId: previewEventId,
3890-},
3891-}),
3892-since: "driver-sync-progress",
3893-},
3894-{
3895-event: ({ sendTextMessage }) =>
3896-matrixQaMessageEvent({
3877+body: "Working...\n- `tool: read`",
3878+}),
3879+since: "driver-sync-preview",
3880+},
3881+{
3882+event: matrixQaMessageEvent({
38973883kind: "message",
3898-eventId: "$tool-progress-mention-final",
3899-body: readMatrixQaReplyDirective(
3900- mockMessageBody(sendTextMessage, "sendTextMessage"),
3901-"MATRIX_QA_TOOL_PROGRESS_MENTION_SAFE_FIXED",
3902-),
3884+eventId: "$tool-progress-mention-edit",
3885+body: "Working...\n- `tool: read`\n- `read from matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt`",
3886+formattedBody:
3887+"Working...<br><ul><li><code>read from matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt</code></li></ul>",
3888+mentions: {},
39033889relatesTo: {
39043890relType: "m.replace",
39053891eventId: previewEventId,
39063892},
39073893}),
3908-since: "driver-sync-next",
3909-},
3910-],
3911-});
3894+since: "driver-sync-progress",
3895+},
3896+{
3897+event: ({ sendTextMessage }) =>
3898+matrixQaMessageEvent({
3899+kind: "message",
3900+eventId: "$tool-progress-mention-final",
3901+body: readMatrixQaReplyDirective(
3902+mockMessageBody(sendTextMessage, "sendTextMessage"),
3903+"MATRIX_QA_TOOL_PROGRESS_MENTION_SAFE_FIXED",
3904+),
3905+relatesTo: {
3906+relType: "m.replace",
3907+eventId: previewEventId,
3908+},
3909+}),
3910+since: "driver-sync-next",
3911+},
3912+],
3913+});
391239143913-const scenario = requireMatrixQaScenario("matrix-room-tool-progress-mention-safety");
3915+ const scenario = requireMatrixQaScenario("matrix-room-tool-progress-mention-safety");
391439163915-const result = await runMatrixQaScenario(scenario, matrixQaScenarioContext());
3916-const artifacts = result.artifacts as {
3917-driverEventId?: unknown;
3918-previewEventId?: unknown;
3919-previewMentions?: unknown;
3920-reply?: { eventId?: unknown };
3921-};
3922-expect(artifacts.driverEventId).toBe("$tool-progress-mention-trigger");
3923-expect(artifacts.previewEventId).toBe("$tool-progress-mention-preview");
3924-expect(artifacts.previewMentions).toEqual({});
3925-expect(artifacts.reply?.eventId).toBe("$tool-progress-mention-final");
3917+const result = await runMatrixQaScenario(scenario, {
3918+ ...matrixQaScenarioContext(),
3919+ gatewayWorkspaceDir,
3920+});
3921+const artifacts = result.artifacts as {
3922+driverEventId?: unknown;
3923+previewEventId?: unknown;
3924+previewMentions?: unknown;
3925+reply?: { eventId?: unknown };
3926+token?: unknown;
3927+};
3928+expect(artifacts.driverEventId).toBe("$tool-progress-mention-trigger");
3929+expect(artifacts.previewEventId).toBe("$tool-progress-mention-preview");
3930+expect(artifacts.previewMentions).toEqual({});
3931+expect(artifacts.reply?.eventId).toBe("$tool-progress-mention-final");
3932+const prompt = mockMessageBody(sendTextMessage, "sendTextMessage");
3933+expect(prompt).toContain(
3934+"call the read tool exactly once on `matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt`",
3935+);
3936+expect(prompt).toContain("Do not use search for this check.");
3937+await expect(
3938+readFile(
3939+path.join(
3940+gatewayWorkspaceDir,
3941+"matrix-progress-@room-@alice:matrix-qa.test-!room:matrix-qa.test.txt",
3942+),
3943+"utf8",
3944+),
3945+).resolves.toContain(String(artifacts.token));
3946+} finally {
3947+await rm(gatewayWorkspaceDir, { force: true, recursive: true });
3948+}
39263949});
3927395039283951it("preserves separate finalized block events when Matrix block streaming is enabled", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。