Skip to content

feat(harness-pi): add agentDir option to createPi for reusing CLI config#16492

Open
Albert-Gao wants to merge 4 commits into
vercel:mainfrom
Albert-Gao:feat/harness-pi-agent-dir
Open

feat(harness-pi): add agentDir option to createPi for reusing CLI config#16492
Albert-Gao wants to merge 4 commits into
vercel:mainfrom
Albert-Gao:feat/harness-pi-agent-dir

Conversation

@Albert-Gao

Copy link
Copy Markdown

Summary

Add an optional agentDir field to PiHarnessSettings and CreatePiSessionInput. When provided, the harness constructs AuthStorage, ModelRegistry, and SettingsManager against that directory instead of the per-session temp dir. When omitted, behavior is unchanged — purely additive, non-breaking.

This lets host applications reuse a user's existing Pi CLI login (~/.pi/agent/auth.json), model config (models.json), and settings (settings.json including defaultProvider/defaultModel) without managing credentials themselves.

Manual Verification

Unit tests added in pi-session.test.ts covering both paths:

  • agentDir provided → AuthStorage.create / ModelRegistry.create called with paths under agentDir, SettingsManager.create used
  • agentDir omitted → SettingsManager.inMemory used (existing behavior preserved)

Checklist

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Related Issues

Fixes #16491

… config

## Background

The Pi harness currently hardcodes a per-session temp directory for
`AuthStorage`, `ModelRegistry`, and uses `SettingsManager.inMemory()`.
This means the harness cannot reuse a user's existing CLI login
(`~/.pi/agent/auth.json`), model config (`models.json`), or settings
(`settings.json` including `defaultProvider`/`defaultModel`).

When embedding the Pi harness in a host application that wants to reuse
the user's interactive CLI credentials (zero-setup auth), there is no
way to point the harness at the user's agent directory.

## Summary

Add an optional `agentDir` field to `PiHarnessSettings` and
`CreatePiSessionInput`. When provided, the harness constructs
`AuthStorage`, `ModelRegistry`, and `SettingsManager` against that
directory instead of the temp dir. When omitted, behavior is unchanged
(temp dir + `inMemory` settings) — purely additive, non-breaking.

## Manual Verification

Unit tests added in `pi-session.test.ts` covering both paths:
- `agentDir` provided → `AuthStorage.create` / `ModelRegistry.create`
  called with paths under `agentDir`, `SettingsManager.create` used
- `agentDir` omitted → `SettingsManager.inMemory` used (existing behavior)
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.

harness-pi: allow caller to override agent config directory

1 participant