Open History to see the last commit
1import { assert, describe, it } from "@effect/vitest";
2
3import {
4 T3_CODE_ORCHESTRATION_INSTRUCTIONS,
5 t3AcpPromptWithInstructions,
6 t3OrchestrationPromptForFirstRun,
7 t3OrchestrationSystemPrompt,
8} from "./T3OrchestrationInstructions.ts";
9
10describe("T3 orchestration provider instructions", () => {
11 it("distinguishes delegated subagents from ordinary top-level threads", () => {
12 assert.include(T3_CODE_ORCHESTRATION_INSTRUCTIONS, "Use `delegate_task`");
13 assert.include(T3_CODE_ORCHESTRATION_INSTRUCTIONS, "ordinary top-level T3 conversations");
14 assert.include(T3_CODE_ORCHESTRATION_INSTRUCTIONS, "Never use them merely");
15 assert.include(T3_CODE_ORCHESTRATION_INSTRUCTIONS, "cross-provider");
16 });
17
18 it("documents structured schedules instead of JSON strings", () => {
19 assert.include(T3_CODE_ORCHESTRATION_INSTRUCTIONS, "structured object, never as JSON text");
20 assert.include(T3_CODE_ORCHESTRATION_INSTRUCTIONS, '"everyMs":3600000');
21 assert.include(T3_CODE_ORCHESTRATION_INSTRUCTIONS, "bindToCurrentThread=false");
22 });
23
24 it("injects prompt fallback only for an MCP-enabled first run", () => {
25 const prompt = "Inspect the repository.";
26 const injected = t3OrchestrationPromptForFirstRun({
27 prompt,
28 runOrdinal: 1,
29 hasT3Mcp: true,
30 });
31
32 assert.include(injected, "<t3_code_orchestration_instructions>");
33 assert.include(injected, `<user_request>\n${prompt}\n</user_request>`);
34 assert.equal(
35 t3OrchestrationPromptForFirstRun({ prompt, runOrdinal: 2, hasT3Mcp: true }),
36 prompt,
37 );
38 assert.equal(
39 t3OrchestrationPromptForFirstRun({ prompt, runOrdinal: 1, hasT3Mcp: false }),
40 prompt,
41 );
42 });
43
44 it("only exposes the system prompt when the T3 MCP server is attached", () => {
45 assert.equal(t3OrchestrationSystemPrompt(false), undefined);
46 assert.equal(t3OrchestrationSystemPrompt(true), T3_CODE_ORCHESTRATION_INSTRUCTIONS);
47 });
48
49 it("gives ACP sessions provider-neutral mode, browser, and orchestration guidance", () => {
50 const injected = t3AcpPromptWithInstructions({
51 prompt: "Inspect the repository.",
52 state: { interactionMode: "default", hasT3Mcp: true },
53 });
54
55 assert.include(injected, "T3 Code interaction mode: Default");
56 assert.include(injected, "T3 Code collaborative browser");
57 assert.include(injected, "T3 Code orchestration");
58 assert.include(injected, "<user_request>\nInspect the repository.\n</user_request>");
59 });
60
61 it("reinjects ACP guidance only when mode or tool availability changes", () => {
62 const prompt = "Continue.";
63 const defaultState = { interactionMode: "default", hasT3Mcp: true } as const;
64
65 assert.equal(
66 t3AcpPromptWithInstructions({ prompt, state: defaultState, previousState: defaultState }),
67 prompt,
68 );
69 assert.include(
70 t3AcpPromptWithInstructions({
71 prompt,
72 state: { ...defaultState, interactionMode: "plan" },
73 previousState: defaultState,
74 }),
75 "T3 Code interaction mode: Plan",
76 );
77 const withoutMcp = t3AcpPromptWithInstructions({
78 prompt,
79 state: { interactionMode: "default", hasT3Mcp: false },
80 });
81 assert.include(withoutMcp, "T3 Code interaction mode: Default");
82 assert.notInclude(withoutMcp, "T3 Code collaborative browser");
83 assert.notInclude(withoutMcp, "T3 Code orchestration");
84 });
85});