Skip to content

[codex] Isolate local Claude config per agent - #798

Draft
bradbrok wants to merge 3 commits into
mainfrom
feat/per-agent-claude-config
Draft

[codex] Isolate local Claude config per agent#798
bradbrok wants to merge 3 commits into
mainfrom
feat/per-agent-claude-config

Conversation

@bradbrok

@bradbrok bradbrok commented Jun 18, 2026

Copy link
Copy Markdown
Owner

What

Refs #797 / task #221.

This adds a flag-gated per-agent CLAUDE_CONFIG_DIR for local Claude agents so one corrupt Claude config can wedge one agent instead of the whole local fleet.

  • Added shared pinky_daemon.claude_config helpers for resolve_agent_claude_config_dir(agent), Claude project slugs, trust/settings seeds, and one-time transcript migration.
  • Wired the same resolver through tmux env injection, tmux _project_dir() / _has_prior_transcript(), SDK streaming options.env, tmux dream seeding/env, and SessionStart transcript-path validation.
  • Added copy-if-missing migration from ~/.claude/projects/<slug> to <agent>/.claude-config/projects/<slug> before tmux decides whether --continue is safe.
  • Made migration crash-safe by copying into a temp dir and renaming into place, so interrupted copies do not leave a partial destination that suppresses retries.
  • Seeded local .claude.json with hasCompletedOnboarding plus trust/bypass flags, and seeded settings.json with skipDangerousModePermissionPrompt for fresh per-agent dirs.

Guardrails

  • Default off behind PINKY_PER_AGENT_CLAUDE_CONFIG.
  • Applies only to isolation_mode in ("", "local"); container and unix_user modes keep their provisioned config dirs.
  • Requires CLAUDE_CODE_OAUTH_TOKEN at resolve time. If the static token is absent, the resolver skips the per-agent dir instead of silently booting into a login wall.
  • The daemon process env is not mutated; only child Claude env gets CLAUDE_CONFIG_DIR.

Evidence

Smoke screenshot showing the per-agent dir appears under data/agents/smoke, transcript history migrates, onboarding/settings are seeded, and non-local modes are skipped:

PR 798 per-agent Claude config smoke screenshot

Terminal smoke text:

before_config_dir_exists=False
CLAUDE_CONFIG_DIR=/.../data/agents/smoke/.claude-config
project_dir=/.../data/agents/smoke/.claude-config/projects/-...-data-agents-smoke
migrated_prior_jsonl=True
hasCompletedOnboarding=True
settings_json_exists=True
container_resolver_skip=True
unix_user_resolver_skip=True
fleet_health_smoke=local agent isolated; nonlocal modes untouched

Validation

  • ruff check .
  • pytest tests/test_claude_config.py tests/test_tmux_trust_seed.py tests/test_tmux_container_isolation.py tests/test_streaming_claude_config.py tests/test_tmux_dream_runner.py tests/test_api.py -q — 454 passed
  • pytest tests/test_tmux_session.py tests/test_tmux_container_isolation.py tests/test_tmux_trust_seed.py tests/test_claude_config.py tests/test_streaming_claude_config.py tests/test_tmux_dream_runner.py -q — 384 passed
  • pytest tests/test_claude_config.py tests/test_tmux_trust_seed.py tests/test_tmux_container_isolation.py tests/test_streaming_claude_config.py tests/test_tmux_dream_runner.py -q — 102 passed
  • pytest tests/test_api.py::TestAPI::test_transcript_path_allows_flagged_per_agent_config_root tests/test_api.py::TestAPI::test_manual_dream_uses_full_persisted_conversation_history -q — 2 passed
  • After crash-safe migration hardening: ruff check src/pinky_daemon/claude_config.py tests/test_claude_config.py and pytest tests/test_claude_config.py tests/test_tmux_container_isolation.py::TestProjectDir::test_local_agent_uses_per_agent_config_when_flagged -q — 8 passed

Note: local API runs still emit existing FastAPI deprecation warnings and shared-MCP port-binding thread warnings on this workstation; the tests pass.

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.

2 participants