Skip to content

[5283] fix(agent): Persist Pi transcripts in session workspaces - #5292

Merged
mmabrouk merged 2 commits into
big-agentsfrom
fix/pi-transcript-persistence
Jul 14, 2026
Merged

[5283] fix(agent): Persist Pi transcripts in session workspaces#5292
mmabrouk merged 2 commits into
big-agentsfrom
fix/pi-transcript-persistence

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Jul 13, 2026

Copy link
Copy Markdown
Member

Context

Pi stored native transcripts below its agent directory. Local runs create a temporary agent directory whenever they carry skills or a system prompt, then delete that directory at teardown. The next cold continuation could therefore point at a transcript path that no longer existed.

This is the lower PR in the launch stack. It fixes transcript persistence only. #5295 stacks the stable skill path on top.

Changes

Pi now writes native transcripts to <cwd>/agents/sessions/pi, inside the existing durable conversation workspace. The runner creates that directory before starting Pi on local and Daytona runs.

Pi already honors PI_CODING_AGENT_SESSION_DIR. The pinned pi-acp@0.0.29 did not consult that variable when rebuilding its session index, so this PR carries a narrow package patch that makes its scan use the same directory.

Before:

<temporary PI_CODING_AGENT_DIR>/sessions/...

After:

<durable session cwd>/agents/sessions/pi/...

This PR does not change warm or cold decisions, session/load, replay selection, continuity IDs, token usage, prompt caching, or Claude behavior. Healthy Pi resumes continue to use native history exactly as before.

Live local QA

Verified on the EE deployment at port 8280 against the actual service-targeted subscription sidecar and pi_core with openai-codex/gpt-5.4-mini.

  • Turn 1 created one Pi JSONL under <cwd>/agents/sessions/pi and stored the private marker PI-COLD-MEM-9Q7R.
  • The sidecar container was deleted and recreated. The new container had no prior /tmp workspace.
  • The existing 120-second local-runner ownership lease first rejected the replacement replica as designed. After that lease expired, the same session cold-loaded with hydrated ... turn=0 and session/load ... loaded=true, then recalled the marker.
  • After the normal 60-second warm-pool eviction unmounted the cwd, another turn remounted the same workspace, logged session/load ... loaded=true, and recalled the marker again.

The ownership retry is existing local-runner affinity behavior, not introduced by this PR. A stable AGENTA_RUNNER_REPLICA_ID avoids that delay across normal orchestrated restarts.

Tests

  • pnpm exec vitest run --project unit tests/unit/sandbox-agent-pi-assets.test.ts tests/unit/sandbox-agent-orchestration.test.ts: 60 passed.
  • pnpm run typecheck: passed.
  • The full runner suite was also run on the complete stack: 69 files and 1,066 tests passed.

How to review

  1. Start with pi-assets.ts for the single session-directory contract.
  2. Check sandbox_agent.ts for local and Daytona directory creation before Pi starts.
  3. Review the pi-acp patch. It only adds environment-variable precedence to the existing scan-directory resolver.
  4. Finish with the local and Daytona orchestration guards.

Part of #5283. The upper #5295 completes the issue.

@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jul 14, 2026 12:12am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a11e948c-a9e9-4dbd-a197-9bc9e11e803f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pi-transcript-persistence

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mmabrouk
mmabrouk marked this pull request as ready for review July 13, 2026 23:33
@mmabrouk mmabrouk added the needs-review Agent updated; awaiting Mahmoud's review label Jul 13, 2026
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. Backend labels Jul 13, 2026
@mmabrouk

Copy link
Copy Markdown
Member Author

Local cold-resume QA is complete. The Pi JSONL was present under <cwd>/agents/sessions/pi; a fresh sidecar container with no old /tmp resumed it after the existing owner-affinity lease expired; and a second cold load after the normal 60-second warm eviction recalled the original marker again. No canonical replay or warm/cold behavior changed.

@mmabrouk

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:\n\nFinal verification after rebasing onto the current big-agents base:\n\n- Head: e0593b4\n- The lower PR now contains only transcript-persistence code and its lower-level tests; the stacked skill-workspace imports and assertions were removed from this lane.\n- I exported the exact lower commit tree into an isolated directory and ran the runner typecheck plus the complete runner suite: 69 files, 1,059 tests passed.\n- GitHub CI is fully green, including runner unit, integration, and acceptance tests, plus API, SDK, services, web, contribution checks, and Vercel.\n- The initial unrelated SDK catalog failure was rerun and passed without any SDK changes.\n- This PR does not change replay, warm/cold selection, token use, or prompt-cache behavior. It only keeps Pi transcripts in the session workspace so they survive cold sandbox replacement.

@mmabrouk mmabrouk left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mmabrouk
mmabrouk merged commit bd33ab3 into big-agents Jul 14, 2026
25 of 26 checks passed
@mmabrouk mmabrouk mentioned this pull request Jul 14, 2026
12 tasks
ardaerzin added a commit that referenced this pull request Jul 14, 2026
…a-* markers) from the Files UI

Pi now persists its native transcripts into the durable session cwd at agents/sessions/pi/ (#5292),
and the runner writes dot-markers there (.agenta-skill-set.json, .agenta-usage.json, .agenta-pi).
Our drive listing recurses the whole cwd tree, so these internal files were about to surface in the
Files / context rail / config Files UI as noise. Add isInternalDrivePath and exclude those paths in
driveFiles (flat lists, counts, sizes, recents) and buildDriveTree (tree view). The agent's own
agent-files/ folder is intentional and not matched (no dot, not under agents/).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend needs-review Agent updated; awaiting Mahmoud's review size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant