Skip to content

Prevent agent log loss during pier exec#4

Merged
jbragg merged 1 commit into
mainfrom
prevent-log-loss
Apr 10, 2026
Merged

Prevent agent log loss during pier exec#4
jbragg merged 1 commit into
mainfrom
prevent-log-loss

Conversation

@jbragg

@jbragg jbragg commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Agent session logs were lost when containers stopped because pier exec
didn'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.

  • Session recording: agent commands are auto-detected via Harbor's
    agent registry and wrapped with script(1) to record output while
    preserving TTY for interactive use
  • Config-dir env vars: CLAUDE_CONFIG_DIR and CODEX_HOME set on
    every container exec so structured session logs land in the mounted
    volume (user -e overrides win)
  • Per-session isolation: each pier exec gets a timestamped directory
    under /logs/agent/ so multiple sessions don't overwrite each other
  • Post-run artifacts: gemini trajectory copy and hermes session export
    run after the agent exits
  • --session flag: pier verify --session <ts> and
    pier capture --session <ts> select a specific session when multiple
    exist
  • DEVELOPER.md: architecture docs for log capture, session layout,
    Harbor integration, and tech debt

Builds on #3 — that PR ensures verify/capture work when logs exist;
this PR ensures logs exist.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 exec and record interactive output to per-exec timestamped directories under /logs/agent/ (host: .pier/_harbor/agent/).
  • Always set CLAUDE_CONFIG_DIR and CODEX_HOME for container execs (with user -e overrides winning) and run agent-specific post-run artifact collection (gemini/hermes).
  • Add --session to pier verify / pier capture to 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.

Comment thread DEVELOPER.md Outdated
Comment thread DEVELOPER.md Outdated
Comment thread pier/tests/test_harbor_bridge.py Outdated
Comment thread pier/cli.py Outdated
Comment thread pier/harbor_bridge.py
Comment thread pier/harbor_bridge.py Outdated
@jbragg jbragg force-pushed the prevent-log-loss branch 3 times, most recently from e12de22 to 1121320 Compare April 10, 2026 17:00
@jbragg jbragg requested a review from Copilot April 10, 2026 17:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread pier/cli.py Outdated
Comment thread pier/cli.py
Comment thread pier/cli.py
Comment thread pier/harbor_bridge.py
Comment thread pier/harbor_bridge.py
Comment thread DEVELOPER.md Outdated
@jbragg jbragg force-pushed the prevent-log-loss branch from 1121320 to feff3c4 Compare April 10, 2026 17:37
@jbragg jbragg requested a review from mikerjacobi April 10, 2026 18:19
Comment thread pier/cli.py Outdated
@jbragg jbragg force-pushed the prevent-log-loss branch from feff3c4 to 36f8a0e Compare April 10, 2026 23:29
@jbragg jbragg enabled auto-merge April 10, 2026 23:30
@jbragg jbragg merged commit 88abf70 into main Apr 10, 2026
9 checks passed
@jbragg jbragg deleted the prevent-log-loss branch April 10, 2026 23:45
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.

3 participants