Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(agent): enable Pi task supplement negotiation (MUL-9178) (#10531)
Multica Eve2cd2045a8349
diff --git a/e2e/comment-steering.spec.ts b/e2e/comment-steering.spec.tsindex 8188aa1685..89c1353c6d 100644--- a/e2e/comment-steering.spec.ts+++ b/e2e/comment-steering.spec.ts@@ -7,92 +7,94 @@ import { createTestApi } from "./helpers";// Steering matrices live in the Go handler and composer tests. This browser// regression covers the real path: a reply in a running agent's thread goes// into that turn by default, and its receipt follows delivery.-test("a reply steers the thread agent's running turn and shows its receipt", async ({ page }, testInfo) => {- test.setTimeout(120_000);- const api = await createTestApi();- const db = new pg.Client(process.env.DATABASE_URL);- await db.connect();- let runtimeId: string | undefined;- let agentId: string | undefined;- try {- const workspace = (await api.getWorkspaces())[0]!;- const user = await db.query<{ id: string }>(`SELECT id FROM "user" WHERE email = $1`, [api.getEmail()]);- const userId = user.rows[0]!.id;- const runtime = await db.query<{ id: string }>(- `INSERT INTO agent_runtime (workspace_id, name, runtime_mode, provider, status, device_info, metadata, owner_id, last_seen_at)- VALUES ($1, 'Steering verification', 'cloud', 'codex', 'online', 'E2E fixture', '{}'::jsonb, $2, now()) RETURNING id`,- [workspace.id, userId],- );- runtimeId = runtime.rows[0]!.id;- const agent = await db.query<{ id: string }>(- `INSERT INTO agent (workspace_id, name, description, instructions, runtime_mode, runtime_config, runtime_id, visibility, permission_mode, max_concurrent_tasks, owner_id)- VALUES ($1, 'Lambda', '', '', 'cloud', '{}'::jsonb, $2, 'private', 'private', 1, $3) RETURNING id`,- [workspace.id, runtimeId, userId],- );- agentId = agent.rows[0]!.id;- const issue = await api.createIssue("Fix the Safari 17 login page");- const root = await db.query<{ id: string }>(- `INSERT INTO comment (workspace_id, issue_id, author_type, author_id, content)- VALUES ($1, $2, 'member', $3, $4) RETURNING id`,- [workspace.id, issue.id, userId, `[@Lambda](mention://agent/${agentId}) The login page is blank in Safari 17. Find the cause and fix it.`],- );- const rootId = root.rows[0]!.id;- const turn = await db.query<{ id: string }>(- `INSERT INTO agent_task_queue (agent_id, runtime_id, issue_id, trigger_comment_id, delivered_comment_ids, status, dispatched_at, started_at)- VALUES ($1, $2, $3, $4, ARRAY[$4]::uuid[], 'running', now() - interval '2 minutes', now() - interval '2 minutes') RETURNING id`,- [agentId, runtimeId, issue.id, rootId],- );- const turnId = turn.rows[0]!.id;- await db.query(- `INSERT INTO task_supplement_capability (task_id, workspace_id, issue_id, capability) VALUES ($1, $2, $3, 'task-supplement-v1')`,- [turnId, workspace.id, issue.id],- );+for (const provider of ["codex", "pi"]) {+ test(`a reply steers the ${provider} thread agent's running turn and shows its receipt`, async ({ page }, testInfo) => {+ test.setTimeout(120_000);+ const api = await createTestApi();+ const db = new pg.Client(process.env.DATABASE_URL);+ await db.connect();+ let runtimeId: string | undefined;+ let agentId: string | undefined;+ try {+ const workspace = (await api.getWorkspaces())[0]!;+ const user = await db.query<{ id: string }>(`SELECT id FROM "user" WHERE email = $1`, [api.getEmail()]);+ const userId = user.rows[0]!.id;+ const runtime = await db.query<{ id: string }>(+ `INSERT INTO agent_runtime (workspace_id, name, runtime_mode, provider, status, device_info, metadata, owner_id, last_seen_at)+ VALUES ($1, 'Steering verification', 'cloud', $3, 'online', 'E2E fixture', '{}'::jsonb, $2, now()) RETURNING id`,+ [workspace.id, userId, provider],+ );+ runtimeId = runtime.rows[0]!.id;+ const agent = await db.query<{ id: string }>(+ `INSERT INTO agent (workspace_id, name, description, instructions, runtime_mode, runtime_config, runtime_id, visibility, permission_mode, max_concurrent_tasks, owner_id)+ VALUES ($1, 'Lambda', '', '', 'cloud', '{}'::jsonb, $2, 'private', 'private', 1, $3) RETURNING id`,+ [workspace.id, runtimeId, userId],+ );+ agentId = agent.rows[0]!.id;+ const issue = await api.createIssue(`Fix the Safari 17 login page (${provider})`);+ const root = await db.query<{ id: string }>(+ `INSERT INTO comment (workspace_id, issue_id, author_type, author_id, content)+ VALUES ($1, $2, 'member', $3, $4) RETURNING id`,+ [workspace.id, issue.id, userId, `[@Lambda](mention://agent/${agentId}) The login page is blank in Safari 17. Find the cause and fix it.`],+ );+ const rootId = root.rows[0]!.id;+ const turn = await db.query<{ id: string }>(+ `INSERT INTO agent_task_queue (agent_id, runtime_id, issue_id, trigger_comment_id, delivered_comment_ids, status, dispatched_at, started_at)+ VALUES ($1, $2, $3, $4, ARRAY[$4]::uuid[], 'running', now() - interval '2 minutes', now() - interval '2 minutes') RETURNING id`,+ [agentId, runtimeId, issue.id, rootId],+ );+ const turnId = turn.rows[0]!.id;+ await db.query(+ `INSERT INTO task_supplement_capability (task_id, workspace_id, issue_id, capability) VALUES ($1, $2, $3, 'task-supplement-v1')`,+ [turnId, workspace.id, issue.id],+ );- await page.addInitScript((token) => {- localStorage.setItem("multica_token", token!);- localStorage.setItem("multica:chat:isOpen", "false");- }, api.getToken());- await page.setViewportSize({ width: 1440, height: 1000 });- await page.goto(`/${workspace.slug}/issues/${issue.id}`, { waitUntil: "domcontentloaded" });- await expect(page.locator(`[data-run-id="${turnId}"]`)).toBeVisible({ timeout: 45_000 });+ await page.addInitScript((token) => {+ localStorage.setItem("multica_token", token!);+ localStorage.setItem("multica:chat:isOpen", "false");+ }, api.getToken());+ await page.setViewportSize({ width: 1440, height: 1000 });+ await page.goto(`/${workspace.slug}/issues/${issue.id}`, { waitUntil: "domcontentloaded" });+ await expect(page.locator(`[data-run-id="${turnId}"]`)).toBeVisible({ timeout: 45_000 });- const shell = page.getByTestId("reply-composer-shell").first();- // The empty box makes no claim about who a reply goes to; the chip says- // so once there is text and the recipient is known.- await expect(shell).toHaveText("Leave a reply...");- await shell.click();- const placeholder = "Leave a reply...";- const editor = page.locator(`.ProseMirror[data-placeholder="${placeholder}"], .ProseMirror:has([data-placeholder="${placeholder}"])`).first();- await editor.fill("This PR only fixes web; leave the desktop login page alone.");- const chip = page.getByRole("button", { name: "Lambda trigger: Add to current run" });- await expect(chip).toBeVisible({ timeout: 15_000 });- await page.screenshot({ path: testInfo.outputPath("steer-composer.png") });- await chip.click();- await expect(page.getByRole("menuitemradio", { name: /Stop and start over/ })).toBeVisible();- await page.screenshot({ path: testInfo.outputPath("steer-menu.png") });- await page.keyboard.press("Escape");+ const shell = page.getByTestId("reply-composer-shell").first();+ // The empty box makes no claim about who a reply goes to; the chip says+ // so once there is text and the recipient is known.+ await expect(shell).toHaveText("Leave a reply...");+ await shell.click();+ const placeholder = "Leave a reply...";+ const editor = page.locator(`.ProseMirror[data-placeholder="${placeholder}"], .ProseMirror:has([data-placeholder="${placeholder}"])`).first();+ await editor.fill("This PR only fixes web; leave the desktop login page alone.");+ const chip = page.getByRole("button", { name: "Lambda trigger: Add to current run" });+ await expect(chip).toBeVisible({ timeout: 15_000 });+ await page.screenshot({ path: testInfo.outputPath("steer-composer.png") });+ await chip.click();+ await expect(page.getByRole("menuitemradio", { name: /Stop and start over/ })).toBeVisible();+ await page.screenshot({ path: testInfo.outputPath("steer-menu.png") });+ await page.keyboard.press("Escape");- const posted = page.waitForResponse((response) => response.request().method() === "POST" && response.url().endsWith(`/api/issues/${issue.id}/comments`));- await page.getByRole("button", { name: "Send", exact: true }).first().click();- const response = await posted;- expect(response.status()).toBe(201);- const reply = await response.json();- expect(reply.supplements).toEqual([expect.objectContaining({ task_id: turnId, agent_id: agentId, status: "pending" })]);- const runs = await db.query(`SELECT id FROM agent_task_queue WHERE issue_id = $1`, [issue.id]);- expect(runs.rows).toHaveLength(1);- await expect(page.getByText("Waiting for Lambda to read it")).toBeVisible();- await expect(page.getByText("Added to Lambda's run")).toBeVisible();- await page.screenshot({ path: testInfo.outputPath("steer-sent.png") });+ const posted = page.waitForResponse((response) => response.request().method() === "POST" && response.url().endsWith(`/api/issues/${issue.id}/comments`));+ await page.getByRole("button", { name: "Send", exact: true }).first().click();+ const response = await posted;+ expect(response.status()).toBe(201);+ const reply = await response.json();+ expect(reply.supplements).toEqual([expect.objectContaining({ task_id: turnId, agent_id: agentId, status: "pending" })]);+ const runs = await db.query(`SELECT id FROM agent_task_queue WHERE issue_id = $1`, [issue.id]);+ expect(runs.rows).toHaveLength(1);+ await expect(page.getByText("Waiting for Lambda to read it")).toBeVisible();+ await expect(page.getByText("Added to Lambda's run")).toBeVisible();+ await page.screenshot({ path: testInfo.outputPath("steer-sent.png") });- await db.query(`UPDATE task_supplement SET status = 'delivered', delivered_at = now() WHERE comment_id = $1`, [reply.id]);- await page.reload({ waitUntil: "domcontentloaded" });- await expect(page.getByText("Read by Lambda")).toBeVisible({ timeout: 30_000 });- await page.screenshot({ path: testInfo.outputPath("steer-delivered.png") });- } finally {- await api.cleanup();- if (agentId) await db.query(`DELETE FROM agent_task_queue WHERE agent_id = $1`, [agentId]);- if (agentId) await db.query(`DELETE FROM agent WHERE id = $1`, [agentId]);- if (runtimeId) await db.query(`DELETE FROM agent_runtime WHERE id = $1`, [runtimeId]);- await db.end();- }-});+ await db.query(`UPDATE task_supplement SET status = 'delivered', delivered_at = now() WHERE comment_id = $1`, [reply.id]);+ await page.reload({ waitUntil: "domcontentloaded" });+ await expect(page.getByText("Read by Lambda")).toBeVisible({ timeout: 30_000 });+ await page.screenshot({ path: testInfo.outputPath("steer-delivered.png") });+ } finally {+ await api.cleanup();+ if (agentId) await db.query(`DELETE FROM agent_task_queue WHERE agent_id = $1`, [agentId]);+ if (agentId) await db.query(`DELETE FROM agent WHERE id = $1`, [agentId]);+ if (runtimeId) await db.query(`DELETE FROM agent_runtime WHERE id = $1`, [runtimeId]);+ await db.end();+ }+ });+}diff --git a/server/internal/handler/comment_agent_steer_test.go b/server/internal/handler/comment_agent_steer_test.goindex d18353b021..0639ea824b 100644--- a/server/internal/handler/comment_agent_steer_test.go+++ b/server/internal/handler/comment_agent_steer_test.go@@ -3,8 +3,8 @@ package handlerimport ("context""fmt"- "strings""net/http"+ "strings""sync""testing"@@ -61,6 +61,7 @@ func steeredAgent(created CommentResponse, agentID string) bool {func TestAgentCommentSteersAnAgentItMayInvoke(t *testing.T) {for _, tc := range []struct {name string+ provider stringbody func(f agentSteerFixture) map[string]anynoOriginator boolself bool@@ -78,12 +79,21 @@ func TestAgentCommentSteersAnAgentItMayInvoke(t *testing.T) {{name: "chain that may not invoke the target", noOriginator: true, body: func(f agentSteerFixture) map[string]any {return map[string]any{"content": agentMention("Target", f.agentID) + " only fix web", "steer": true}}},+ {name: "pi named turn", provider: "pi", wantSteered: true, body: func(f agentSteerFixture) map[string]any {+ return map[string]any{"content": agentMention("Target", f.agentID) + " only fix web", "steer_task_ids": []string{f.taskID}}+ }},+ {name: "pi chain that may not invoke the target", provider: "pi", noOriginator: true, body: func(f agentSteerFixture) map[string]any {+ return map[string]any{"content": agentMention("Target", f.agentID) + " only fix web", "steer": true}+ }},{name: "own running turn", self: true, body: func(f agentSteerFixture) map[string]any {return map[string]any{"content": agentMention("Me", f.callerAgent) + " note to self", "steer_task_ids": []string{f.callerTask}}}},} {t.Run(tc.name, func(t *testing.T) {f := newAgentSteerFixture(t)+ if tc.provider != "" {+ dbfx.Exec(t, `UPDATE agent_runtime SET provider = $2 WHERE id = $1`, f.runtimeID, tc.provider)+ }if tc.noOriginator {dbfx.Exec(t, `UPDATE agent_task_queue SET originator_user_id = NULL, accountable_user_id = NULL, originator_source = NULL WHERE id = $1`, f.callerTask)}diff --git a/server/internal/handler/comment_steer_test.go b/server/internal/handler/comment_steer_test.goindex 1597de2048..def8777c94 100644--- a/server/internal/handler/comment_steer_test.go+++ b/server/internal/handler/comment_steer_test.go@@ -58,7 +58,7 @@ func outcomeFor(outcomes []CommentTriggerOutcome, agentID string) (CommentTrigge}func TestCreateCommentSteersTheThreadAgentsRunningTurn(t *testing.T) {- for _, provider := range []string{"codex", "grok", "cursor", "kiro"} {+ for _, provider := range []string{"codex", "grok", "cursor", "kiro", "pi"} {t.Run(provider, func(t *testing.T) {f := newSupplementFixture(t, provider, "running", true)dbfx.Exec(t, `UPDATE comment SET content = $2 WHERE id = $1`, f.triggerID,diff --git a/server/internal/handler/task_supplement_test.go b/server/internal/handler/task_supplement_test.goindex 8c9400086c..b70a772dcf 100644--- a/server/internal/handler/task_supplement_test.go+++ b/server/internal/handler/task_supplement_test.go@@ -183,9 +183,12 @@ func TestTaskSupplementNegotiationFailsClosed(t *testing.T) {{name: "grok negotiated", provider: "grok", daemonAdvertises: true, wantCapabilityRow: true},{name: "cursor negotiated", provider: "cursor", daemonAdvertises: true, wantCapabilityRow: true},{name: "kiro negotiated", provider: "kiro", daemonAdvertises: true, wantCapabilityRow: true},+ {name: "pi negotiated", provider: "pi", daemonAdvertises: true, wantCapabilityRow: true},+ {name: "pi old daemon", provider: "pi", daemonAdvertises: false, wantCapabilityRow: false},{name: "claude old daemon", provider: "claude", daemonAdvertises: false, wantCapabilityRow: false},{name: "old daemon", provider: "codex", daemonAdvertises: false, wantCapabilityRow: false},{name: "unsupported runtime", provider: "kimi", daemonAdvertises: true, wantCapabilityRow: false},+ {name: "omp is not pi", provider: "omp", daemonAdvertises: true, wantCapabilityRow: false},} {t.Run(tc.name, func(t *testing.T) {fixture := newSupplementFixture(t, tc.provider, "dispatched", false)@@ -215,7 +218,7 @@ func TestTaskSupplementCapabilityDoesNotBreakNonIssueStarts(t *testing.T) {if testHandler == nil {t.Skip("database not available")}- for _, provider := range []string{"codex", "claude", "grok", "cursor", "kiro"} {+ for _, provider := range []string{"codex", "claude", "grok", "cursor", "kiro", "pi"} {t.Run(provider, func(t *testing.T) {runtimeID := dbfx.Runtime(t, "supplement-no-issue", testutil.Cols{"provider": provider})agentID := dbfx.Agent(t, "Supplement no issue", runtimeID)@@ -231,8 +234,70 @@ func TestTaskSupplementCapabilityDoesNotBreakNonIssueStarts(t *testing.T) {}}+func TestPiTaskSupplementLifecycle(t *testing.T) {+ f := newSupplementFixture(t, "pi", "dispatched", false)+ generation := time.Now().UTC().Truncate(time.Microsecond)+ dbfx.Exec(t, `UPDATE agent_task_queue SET dispatched_at = $2 WHERE id = $1`, f.taskID, generation)+ dbfx.Exec(t, `UPDATE comment SET content = $2 WHERE id = $1`, f.triggerID,+ agentMention("Pi", f.agentID)+" original objective")+ dbfx.Exec(t, `UPDATE agent_task_queue SET delivered_comment_ids = ARRAY[trigger_comment_id] WHERE id = $1`, f.taskID)+ dbfx.Cleanup(t, `DELETE FROM agent_task_queue WHERE issue_id = $1`, f.issueID)++ for range 2 {+ var started AgentTaskResponse+ req := withURLParam(newOwnerDaemonRequest(http.MethodPost, "/start", map[string]any{+ "runtime_id": f.runtimeID, "dispatched_at": generation.Format(time.RFC3339Nano),+ "capabilities": []string{protocol.DaemonCapabilityTaskSupplementV1},+ }), "taskId", f.taskID)+ testutil.Call(t, testHandler.StartTask, req).Want(http.StatusOK).JSON(&started)+ if started.ID != f.taskID || started.SupplementCapability != protocol.DaemonCapabilityTaskSupplementV1 {+ t.Fatalf("start/replay did not negotiate Pi: %+v", started)+ }+ }++ var runs []AgentTaskResponse+ testutil.Call(t, testHandler.ListTasksByIssue, withURLParam(+ newRequest(http.MethodGet, "/tasks", nil), "id", f.issueID)).Want(http.StatusOK).JSON(&runs)+ if len(runs) != 1 || runs[0].ID != f.taskID || !runs[0].CanSupplement {+ t.Fatalf("composer cannot offer the Pi run: %+v", runs)+ }++ var bound, submitted CommentResponse+ postSteeredComment(t, f.issueID, f.triggerID, "Steer this Pi run.", f.taskID).+ Want(http.StatusCreated).JSON(&bound)+ supplementRequest(t, f, "0199a4e8-22ce-7b01-bba5-888888888888", "Also keep the original objective.").+ Want(http.StatusCreated).JSON(&submitted)+ for _, comment := range []CommentResponse{bound, submitted} {+ if comment.SupplementTaskID != f.taskID || comment.SupplementStatus != "pending" {+ t.Fatalf("message did not bind to the original run: %+v", comment)+ }+ var claimed struct {+ CommentID string `json:"comment_id"`+ Content string `json:"content"`+ }+ testutil.Call(t, testHandler.ClaimTaskSupplement, withURLParam(+ newOwnerDaemonRequest(http.MethodPost, "/claim", nil), "taskId", f.taskID)).Want(http.StatusOK).JSON(&claimed)+ if claimed.CommentID != comment.ID || claimed.Content != comment.Content {+ t.Fatalf("claim = %+v, want comment %s: %s", claimed, comment.ID, comment.Content)+ }+ testutil.Call(t, testHandler.AckTaskSupplement, withURLParams(+ newOwnerDaemonRequest(http.MethodPost, "/ack", map[string]any{"delivered": true}),+ "taskId", f.taskID, "commentId", comment.ID)).Want(http.StatusOK)+ receipt, err := testHandler.Queries.GetTaskSupplementForRun(t.Context(), db.GetTaskSupplementForRunParams{+ TaskID: parseUUID(f.taskID), CommentID: parseUUID(comment.ID), WorkspaceID: parseUUID(testWorkspaceID),+ })+ if err != nil || receipt.Status != "delivered" || !receipt.DeliveredAt.Valid {+ t.Fatalf("acknowledged receipt = %+v, err %v", receipt, err)+ }+ }+ completeTaskViaDaemon(t, f.taskID)+ if n := dbfx.Count(t, `SELECT count(*) FROM agent_task_queue WHERE issue_id = $1`, f.issueID); n != 1 {+ t.Fatalf("messages restarted the run: got %d runs", n)+ }+}+func TestTaskSupplementCompletionDoesNotReplayBoundComments(t *testing.T) {- for _, provider := range []string{"codex", "claude", "grok", "cursor", "kiro"} {+ for _, provider := range []string{"codex", "claude", "grok", "cursor", "kiro", "pi"} {for _, status := range []string{"pending", "delivering", "delivered", "failed"} {for _, ordinary := range []string{"none", "unhandled", "queued"} {t.Run(provider+"/"+status+"/"+ordinary, func(t *testing.T) {@@ -593,7 +658,16 @@ func TestTaskSupplementTerminalWriteRollsBackWhenSettlementFails(t *testing.T) {}func TestTaskSupplementPermissionAndTenantIsolation(t *testing.T) {- fixture := newSupplementFixture(t, "codex", "running", true)+ for _, provider := range []string{"codex", "pi"} {+ t.Run(provider, func(t *testing.T) {+ assertTaskSupplementPermissionAndTenantIsolation(t, provider)+ })+ }+}++func assertTaskSupplementPermissionAndTenantIsolation(t *testing.T, provider string) {+ t.Helper()+ fixture := newSupplementFixture(t, provider, "running", true)otherUser := dbfx.Insert(t, "user", testutil.Cols{"name": "No Invoke", "email": "[email protected]"})dbfx.Member(t, testWorkspaceID, otherUser, "member")req := newRequestAs(otherUser, http.MethodPost, "/supplements", map[string]any{@@ -601,6 +675,14 @@ func TestTaskSupplementPermissionAndTenantIsolation(t *testing.T) {})testutil.Call(t, testHandler.CreateTaskSupplement,withURLParams(req, "id", fixture.issueID, "taskId", fixture.taskID)).Want(http.StatusForbidden)+ var runs []AgentTaskResponse+ listReq := withURLParam(newRequestAs(otherUser, http.MethodGet, "/tasks", nil), "id", fixture.issueID)+ testutil.Call(t, testHandler.ListTasksByIssue, listReq).Want(http.StatusOK).JSON(&runs)+ for _, run := range runs {+ if run.ID == fixture.taskID && run.CanSupplement {+ t.Fatal("caller without invocation permission can supplement the run")+ }+ }foreignIssueID, foreignTaskID := setupForeignWorkspaceFixture(t)crossTenant := newRequest(http.MethodPost, "/api/issues/"+foreignIssueID+"/tasks/"+foreignTaskID+"/supplements", map[string]any{diff --git a/server/pkg/agent/pi_supplement_integration_test.go b/server/pkg/agent/pi_supplement_integration_test.gonew file mode 100644index 0000000000..c3ac8760be--- /dev/null+++ b/server/pkg/agent/pi_supplement_integration_test.go@@ -0,0 +1,82 @@+//go:build agentintegration++package agent++import (+ "context"+ "crypto/rand"+ "os"+ "os/exec"+ "path/filepath"+ "strings"+ "testing"+ "time"+)++func TestPiRealSupplementReachesTheSameSession(t *testing.T) {+ requireRealAgentSmoke(t)+ if testing.Short() {+ t.Skip("skipping real-binary smoke test in -short mode")+ }+ path, err := exec.LookPath("pi")+ if err != nil {+ t.Skip("pi not on PATH; real same-session consumption is unverified")+ }+ ctx, cancel := context.WithTimeout(t.Context(), 180*time.Second)+ defer cancel()+ version, err := DetectVersion(ctx, NewCommand(path, nil))+ if err != nil {+ t.Fatal(err)+ }+ if !SupportsTaskSupplement("pi", version) {+ t.Skipf("Pi %q does not support steering; need >=1.4.0", version)+ }+ backend, err := New("pi", Config{ExecutablePath: path})+ if err != nil {+ t.Fatal(err)+ }+ cwd := t.TempDir()+ session, err := backend.Execute(ctx,+ "Run `sleep 5` in the shell, then create objective.txt containing exactly objective-complete. Finally summarize what you did.",+ ExecOptions{Cwd: cwd, Timeout: 170 * time.Second, EnableTaskSupplement: true})+ if err != nil {+ t.Fatal(err)+ }+ drained := make(chan struct{})+ go func() {+ defer close(drained)+ for range session.Messages {+ }+ }()+ defer func() {+ cancel()+ <-drained+ }()+ for !session.SupplementReady() {+ select {+ case <-ctx.Done():+ t.Fatal("Pi never became ready for steering")+ case <-drained:+ t.Fatalf("Pi ended before steering: %+v", <-session.Result)+ case <-time.After(25 * time.Millisecond):+ }+ }+ // Only this additional message carries the canary; the initial prompt+ // cannot satisfy the assertion. A queued RPC response alone cannot pass.+ canary := "PI_STEER_" + rand.Text()+ if err := session.Supplement(ctx, "Preserve the original objective. Also create steered.txt containing exactly "+canary+" and include it in your final reply."); err != nil {+ t.Fatalf("same-session supplement was not consumed: %v", err)+ }+ <-drained+ result := <-session.Result+ if result.Status != "completed" || result.SessionID == "" || !strings.Contains(result.Output, canary) {+ t.Fatalf("same-session result did not include guidance: %+v", result)+ }+ for name, want := range map[string]string{"objective.txt": "objective-complete", "steered.txt": canary} {+ data, err := os.ReadFile(filepath.Join(cwd, name))+ if err != nil || strings.TrimSpace(string(data)) != want {+ t.Fatalf("%s = %q, err %v; want %q", name, data, err, want)+ }+ }+ t.Logf("Pi %s consumed additional input in session %s and completed both objectives", version, result.SessionID)+}diff --git a/server/pkg/agent/version_test.go b/server/pkg/agent/version_test.goindex 0cbe30c178..2ffd397e3b 100644--- a/server/pkg/agent/version_test.go+++ b/server/pkg/agent/version_test.go@@ -10,7 +10,7 @@ func TestTaskSupplementVersionGate(t *testing.T) {provider, version stringwant bool}{- {"pi", "1.4.0", true}, {"pi", "1.3.9", false}, {"pi", "", false}, {"omp", "1.4.0", false},+ {"pi", "1.4.0", true}, {"pi", "1.5.2", true}, {"pi", "1.3.9", false}, {"pi", "", false}, {"pi", "dev", false}, {"omp", "1.4.0", false},{"codex", "codex-cli 0.100.0", true}, {"codex", "0.99.0", false},{"claude", "2.1.110 (Claude Code)", true}, {"claude", "2.1.109", false},{"grok", "1.0.14", true}, {"grok", "1.0.13", false}, {"grok", "0.2.120", false},diff --git a/server/pkg/db/generated/supplement.sql.go b/server/pkg/db/generated/supplement.sql.goindex c40631faef..807a845695 100644--- a/server/pkg/db/generated/supplement.sql.go+++ b/server/pkg/db/generated/supplement.sql.go@@ -104,7 +104,7 @@ WITH locked_task AS MATERIALIZED (AND r.workspace_id = $4AND t.status = 'running'AND cap.capability = 'task-supplement-v1'- AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro')+ AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi')AND ($5::text <> 'agent' OR ((SELECT count(*) FROM task_supplement sJOIN comment c ON c.id = s.comment_id@@ -293,7 +293,7 @@ WITH locked_task AS MATERIALIZED (AND r.workspace_id = $3AND t.status = 'running'AND cap.capability = 'task-supplement-v1'- AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro')+ AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi')FOR UPDATE OF t), touched_issue AS (UPDATE issue i SET@@ -854,7 +854,7 @@ WITH candidate AS MATERIALIZED (SELECT id, workspace_id, issue_id, 'task-supplement-v1'FROM candidateWHERE $3::boolean- AND provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro')+ AND provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi')AND issue_id IS NOT NULLON CONFLICT DO NOTHINGRETURNING task_iddiff --git a/server/pkg/db/queries/supplement.sql b/server/pkg/db/queries/supplement.sqlindex a1028b05d3..e0ba571411 100644--- a/server/pkg/db/queries/supplement.sql+++ b/server/pkg/db/queries/supplement.sql@@ -14,7 +14,7 @@ WITH candidate AS MATERIALIZED (SELECT id, workspace_id, issue_id, 'task-supplement-v1'FROM candidateWHERE @enable_task_supplement::boolean- AND provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro')+ AND provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi')AND issue_id IS NOT NULLON CONFLICT DO NOTHINGRETURNING task_id@@ -50,7 +50,7 @@ WITH locked_task AS MATERIALIZED (AND r.workspace_id = @workspace_idAND t.status = 'running'AND cap.capability = 'task-supplement-v1'- AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro')+ AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi')FOR UPDATE OF t), touched_issue AS (UPDATE issue i SET@@ -125,7 +125,7 @@ WITH locked_task AS MATERIALIZED (AND r.workspace_id = @workspace_idAND t.status = 'running'AND cap.capability = 'task-supplement-v1'- AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro')+ AND r.provider IN ('codex', 'claude', 'grok', 'cursor', 'kiro', 'pi')AND (@author_type::text <> 'agent' OR ((SELECT count(*) FROM task_supplement sJOIN comment c ON c.id = s.comment_id