From fc31e71e21a5f144c52c0c33552b82f40dec9db5 Mon Sep 17 00:00:00 2001 From: oldschoola Date: Mon, 25 May 2026 14:41:04 -0700 Subject: [PATCH] test(coding-agent): pass autoApprove context to direct eval tool calls The approval gate added in 0efa60b7d requires either a UI runner or an autoApprove context flag. The python-cleanup tests call EvalTool.execute directly, bypassing the agent loop that normally supplies context. Pass { autoApprove: true } as AgentToolContext at three direct call sites. This matches the in-loop behaviour for tests that opt into approval-free execution and unblocks CI for #1378. --- .../test/agent-session-python-cleanup.test.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/coding-agent/test/agent-session-python-cleanup.test.ts b/packages/coding-agent/test/agent-session-python-cleanup.test.ts index d47e2382d..939e12a98 100644 --- a/packages/coding-agent/test/agent-session-python-cleanup.test.ts +++ b/packages/coding-agent/test/agent-session-python-cleanup.test.ts @@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "bun:test"; import * as fs from "node:fs"; import * as os from "node:os"; import * as path from "node:path"; +import type { AgentToolContext } from "@oh-my-pi/pi-agent-core"; import { getBundledModel } from "@oh-my-pi/pi-ai"; import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings"; import * as pythonExecutor from "@oh-my-pi/pi-coding-agent/eval/py/executor"; @@ -401,7 +402,9 @@ describe("AgentSession python cleanup", () => { expect(EvalTool).toBeDefined(); let toolExecutionSettled = false; const toolExecution = EvalTool! - .execute("call-id", { cells: [{ language: "py", code: "print('tool')" }] }, undefined, undefined, undefined) + .execute("call-id", { cells: [{ language: "py", code: "print('tool')" }] }, undefined, undefined, { + autoApprove: true, + } as AgentToolContext) .finally(() => { toolExecutionSettled = true; }); @@ -627,13 +630,9 @@ describe("AgentSession python cleanup", () => { expect(EvalTool).toBeDefined(); const disposeSession = session.dispose(); await expect( - EvalTool!.execute( - "call-id", - { cells: [{ language: "py", code: "print('late')" }] }, - undefined, - undefined, - undefined, - ), + EvalTool!.execute("call-id", { cells: [{ language: "py", code: "print('late')" }] }, undefined, undefined, { + autoApprove: true, + } as AgentToolContext), ).rejects.toThrow("Python execution is unavailable while session disposal is in progress"); await disposeSession; expect(executeSpy).not.toHaveBeenCalled(); @@ -671,7 +670,7 @@ describe("AgentSession python cleanup", () => { { cells: [{ language: "py", code: "print('late after artifact')" }] }, undefined, undefined, - undefined, + { autoApprove: true } as AgentToolContext, ); await artifactStarted.promise; const disposeSession = session.dispose();