Skip to content

substrate: complete PiSubstrate protocol (execute/read_trajectory/preflight) + configurable pi model - #204

Open
ouryuk wants to merge 4 commits into
google-research:mainfrom
ouryuk:pi-substrate-v2
Open

ouryuk wants to merge 4 commits into
google-research:mainfrom
ouryuk:pi-substrate-v2

Conversation

@ouryuk

@ouryuk ouryuk commented Nov 13, 2026

Copy link
Copy Markdown

What

Completes the PiSubstrate implementation so it satisfies the full Substrate protocol, and makes the pi model route configurable for the end-to-end check.

harness2/substrate/pi.py

  • execute() — forwards to the benchmark-supplied launcher via the shared RunRequest/Install contract (previously missing, so PiSubstrate did not satisfy Substrate).
  • read_trajectory() — renders pi's --mode json event stream into the shared trajectory grammar, merging tool_execution_start/tool_execution_end into one ACTION/OBSERVATION pair and surfacing message_end assistant text.
  • preflight() — verifies the pi CLI exists and pi --version succeeds, raising RuntimeError with the remediation path before any model call is spent.
  • Tool result envelopes ({"content": ...}) are unwrapped when rendering observations.

harness2/config.py

  • PI_SUBSTRATE_MODEL (default zai/glm-5.3, the reference route) so the substrate/e2e can use any pi provider/model without changing benchmark configuration.

Tests

  • tests/test_pi_substrate_unit.py — deterministic checks for the protocol surface, preflight failure mode, and trajectory rendering/truncation (no model calls).
  • tests/test_pi_substrate.py — uses config.PI_SUBSTRATE_MODEL instead of a hard-coded model.

Docs

  • docs/SETUP.md — documents the model override and the two test entry points.

Verification

python -m unittest tests.test_workflow tests.test_pi_substrate_unit   # 10 tests OK
PI_SUBSTRATE_MODEL=<route> python tests/test_pi_substrate.py          # real-agent e2e PASS

Notes

This branch is based on current origin/main (6868817) and cherry-picks the earlier PiSubstrate commits on top.

- PI_SURFACE: c1-c8 mapped to pi's native resource system
- pi_project install mode: .pi/APPEND_SYSTEM.md, .pi/skills, .pi/extensions,
  .pi/prompts, scripts/ — pi loads the staged overlay natively
- reference run_argv (pi --print --mode json -a)
- e2e test: staged harness governs a real pi run (tests/test_pi_substrate.py)
@google-cla

google-cla Bot commented Nov 13, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant