Prevent agent log loss during pier exec#4
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Improves pier exec reliability in container mode by ensuring agent session logs and interactive output are persisted to the host-mounted Harbor agent log volume, enabling pier verify/pier capture to consistently extract trajectories.
Changes:
- Auto-detect Harbor agents on
pier execand record interactive output to per-exec timestamped directories under/logs/agent/(host:.pier/_harbor/agent/). - Always set
CLAUDE_CONFIG_DIRandCODEX_HOMEfor container execs (with user-eoverrides winning) and run agent-specific post-run artifact collection (gemini/hermes). - Add
--sessiontopier verify/pier captureto select a specific per-exec session directory when multiple exist; add docs and test coverage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates pier exec docs and points dev setup/testing guidance to DEVELOPER.md. |
| DEVELOPER.md | New developer guide including architecture notes for log capture/session layout. |
| pier/harbor_bridge.py | Adds log-capture env helpers, agent binary registry mapping, per-session selection helpers, and script(1) wrapping support in exec_in_container(). |
| pier/cli.py | Implements agent auto-detection + per-exec session dirs + --session support for verify/capture and post-run artifact collection. |
| pier/tests/test_pier_cli.py | Adds CLI unit tests for log-capture env behavior, auto-detect/recording behavior, and --session flag behavior. |
| pier/tests/test_harbor_bridge.py | Adds unit tests for new harbor_bridge helpers and an end-to-end extraction/assembly pipeline test. |
| pier/tests/test_docker_integration.py | Adds Docker integration tests verifying log-capture env vars are present and bind-mounted/writable. |
| pier/tests/test_agent_integration.py | Extends agent integration tests to assert per-session tee output and log env vars. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e12de22 to
1121320
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1121320 to
feff3c4
Compare
mikerjacobi
reviewed
Apr 10, 2026
mikerjacobi
approved these changes
Apr 10, 2026
feff3c4 to
36f8a0e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Agent session logs were lost when containers stopped because
pier execdidn't capture output or set the env vars agents need to write to the
mounted volume. This PR fixes log capture for all Harbor agents.
agent registry and wrapped with
script(1)to record output whilepreserving TTY for interactive use
CLAUDE_CONFIG_DIRandCODEX_HOMEset onevery container exec so structured session logs land in the mounted
volume (user
-eoverrides win)pier execgets a timestamped directoryunder
/logs/agent/so multiple sessions don't overwrite each otherrun after the agent exits
--sessionflag:pier verify --session <ts>andpier capture --session <ts>select a specific session when multipleexist
Harbor integration, and tech debt
Builds on #3 — that PR ensures verify/capture work when logs exist;
this PR ensures logs exist.