ai icon indicating copy to clipboard operation
ai copied to clipboard

harness-pi skips .pi/SYSTEM.md with sandbox-just-bash

Open zhaoyouqi opened this issue 3 months ago • 8 comments

Bug

With HarnessAgent + createPi + createJustBashSandbox, /workspace/.pi/SYSTEM.md exists but is ignored, so Pi uses its default coding-assistant system prompt.

Cause

harness-pi scans the workspace with find -L, but just-bash returns:

find: unknown predicate '-L'

Because the command is piped, the overall exit code is still 0; the mirror silently receives no .pi files.

Expected

Project .pi/SYSTEM.md is mirrored and used, or session creation fails with the unsupported-command error.

Versions

zhaoyouqi avatar Aug 12 '26 06:08 zhaoyouqi

Identify issue type

Identified as Bug
Confidence: High

Rationale

This is a concrete interoperability failure in existing AI SDK packages that produces incorrect behavior instead of using the project system prompt or surfacing the command error.

Evidence

  • Using HarnessAgent + createPi + createJustBashSandbox ignores an existing /workspace/.pi/SYSTEM.md.
  • harness-pi invokes find -L, which just-bash rejects with find: unknown predicate '-L'.
  • The piped command still exits successfully, silently preventing .pi files from being mirrored and causing the default system prompt to be used.

ai-sdk-factory[bot] avatar Aug 12 '26 06:08 ai-sdk-factory[bot]

Bug Reproduction - AI SDK 7

Bug was reproduced.

Branch: main PR: successful reproduction pull request

Details

  • Pi is expected to replace its default prompt with project .pi/SYSTEM.md; ignoring it causes the agent to operate without the project's required instructions.
  • The target branch matches the reported versions: @ai-sdk/[email protected], @ai-sdk/[email protected], @ai-sdk/[email protected], and [email protected].
  • packages/harness-pi/src/pi-workspace-mirror.ts runs the scoped workspace scan using find -L inside a pipeline, allowing the unsupported-command failure to be masked by the pipeline's successful exit code.
  • examples/ai-functions/src/reproduction/issue-18767-harness-pi-system-prompt.ts verifies the sandbox file exists, captures Pi's active prompt, and observes the default prompt instead of the expected custom marker.

Relevant Documentation

  • https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/usage.md
  • https://github.com/vercel-labs/just-bash

ai-sdk-factory[bot] avatar Aug 12 '26 06:08 ai-sdk-factory[bot]

Bugfix - AI SDK 7

Created bugfix and opened PR: #18769

Root Cause

The workspace mirror used unsupported find -L commands inside a pipeline. just-bash reported find: unknown predicate '-L', but the pipeline exited successfully with no mirrored .pi entries, as confirmed by the replay's exact failure signal.

Summary

Replaced find -L enumeration with scoped recursive shell traversal that remains symlink-aware, added a patch changeset, and removed reproduction-only artifacts.

Testing

Added regression coverage simulating a sandbox that rejects find -L and verifying .pi/SYSTEM.md is still mirrored.

ai-sdk-factory[bot] avatar Aug 12 '26 06:08 ai-sdk-factory[bot]

Bugfix updated - AI SDK 7

Updated PR: #18769

Root Cause

just-bash shell function variables were global, so recursive calls overwrote the caller's next_depth and made depth accumulate across siblings. The old walker exited 1 on a shallow tree with 101 siblings, while the corrected integration test passes.

Update

Scoped recursive walker variables with local declarations and added an actual sandbox-just-bash integration test covering 101 sibling directories, including the required test dependency and TypeScript reference.

ai-sdk-factory[bot] avatar Aug 12 '26 07:08 ai-sdk-factory[bot]

Bugfix updated - AI SDK 7

Updated PR: #18769

Root Cause

The walker assumed globbing through a symlinked directory remained reliable, but just-bash could enumerate the symlink's immediate child while failing on deeper alias paths. A focused real-sandbox test reproduced the missing nested SKILL.md.

Update

The walker now resolves symlinks with readlink while retaining separate logical mirror and physical sandbox paths, reads files from the resolved source, bounds symlink cycles, and prioritizes command stderr on failure.

ai-sdk-factory[bot] avatar Aug 13 '26 18:08 ai-sdk-factory[bot]

Bugfix updated - AI SDK 7

Updated PR: #18769

Root Cause

The shell walker tied cycle protection to recursive call depth, so an actual just-bash sandbox exhausted the recursion limit on a deeply nested but acyclic tree.

Update

Replaced recursive traversal and its fixed depth cap with an iterative work queue, while retaining explicit symlink resolution and ancestry-based cycle detection. No additional changeset was needed because the existing patch changeset covers the behavior.

ai-sdk-factory[bot] avatar Aug 13 '26 19:08 ai-sdk-factory[bot]

Bugfix updated - AI SDK 7

Updated PR: #18769

Root Cause

The symlink resolver represented the filesystem root as an empty resolved path, then ${resolved:-/} converted it into a traversal source. A real just-bash regression failed with a cycle beneath .pi/sandbox/work/.pi, confirming root enumeration.

Update

Root-resolving configuration symlinks are now skipped before directory enumeration. Added real just-bash regression coverage; the existing changeset already covers the behavior.

ai-sdk-factory[bot] avatar Aug 13 '26 20:08 ai-sdk-factory[bot]

:rocket: Published in:

Package Version
@ai-sdk/amazon-bedrock 5.0.57 github npm
@ai-sdk/azure 4.0.43 github npm
@ai-sdk/harness-pi 1.0.74 github npm
@ai-sdk/openai 4.0.42 github npm
@ai-sdk/workflow 1.0.67 github npm
@ai-sdk/xai 4.0.39 github npm

github-actions[bot] avatar Aug 14 '26 19:08 github-actions[bot]