Skip to content

Commit 7180c35

Browse files
fix(server): keep typeof getAgentDir guard for protocol-only stub
MENTOR_RUNNER_PROTOCOL_ONLY=1 swaps the Pi SDK for a deterministic stub (buildStubSdk) that does not export getAgentDir. The previous commit dropped the typeof guard, so the smoke test in pi-mentor-runner.spec.mjs crashed with `getAgentDir is not a function`. Restore the guard and update its fallback to /workspace/.pi to match the new container layout. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent a6329c1 commit 7180c35

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

server/application-server/src/main/resources/agent/pi-mentor-runner.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ async function ensureRuntime() {
225225
DefaultResourceLoader,
226226
getAgentDir,
227227
} = await loadSdk();
228-
const agentDir = AGENT_DIR_OVERRIDE ?? getAgentDir();
228+
// `typeof getAgentDir === "function"` guard accommodates MENTOR_RUNNER_PROTOCOL_ONLY=1 mode,
229+
// where the stub SDK (see buildStubSdk) does not export getAgentDir. Tests then fall through
230+
// to the workspace-relative default that matches production's PI_CODING_AGENT_DIR.
231+
const agentDir = AGENT_DIR_OVERRIDE ?? (typeof getAgentDir === "function" ? getAgentDir() : "/workspace/.pi");
229232

230233
// System prompt is optional in v1 — the Java caller may inject it later. If the
231234
// resource exists we load it once and reuse via ResourceLoader override.

0 commit comments

Comments
 (0)