Skip to content

fix(cli): support mode when importing agents - #4743

Open
keithpk wants to merge 2 commits into
getpaseo:mainfrom
keithpk:fix/import-mode
Open

fix(cli): support mode when importing agents#4743
keithpk wants to merge 2 commits into
getpaseo:mainfrom
keithpk:fix/import-mode

Conversation

@keithpk

@keithpk keithpk commented Sep 11, 2026

Copy link
Copy Markdown

Summary

Fixes #4731.

paseo import now accepts --mode <mode>, matching paseo agent run --mode. The requested mode is carried through the client and optional protocol field into the daemon's import path, where it configures both fresh imports and restores of archived Paseo records before the provider session opens.

Regression coverage

The CLI regression test failed before the fix because the import call omitted modeId:

$ npx vitest run packages/cli/src/commands/agent/import.test.ts --bail=1
FAIL  ... > passes the requested mode to the import request
-     "modeId": "auto",
Test Files  1 failed (1)
Tests       1 failed | 4 passed (5)

After the fix:

$ npx vitest run packages/cli/src/commands/agent/import.test.ts --bail=1
Test Files  1 passed (1)
Tests       5 passed (5)
Duration    1.80s

Focused coverage for each layer:

$ npx vitest run packages/cli/src/cli-surface.test.ts --bail=1
Test Files  1 passed (1) | Tests 10 passed (10)

$ npx vitest run packages/protocol/src/messages.workspaces.test.ts --bail=1
Test Files  1 passed (1) | Tests 41 passed (41)

$ npx vitest run packages/client/src/daemon-client.test.ts --bail=1
Test Files  1 passed (1) | Tests 121 passed (121)

$ npx vitest run packages/server/src/server/agent/import-sessions.test.ts --bail=1
Test Files  1 passed (1) | Tests 16 passed (16)

$ npx vitest run packages/server/src/server/agent/agent-manager.test.ts --bail=1
Test Files  1 passed (1) | Tests 184 passed (184)

End-to-end QA

Built the server/client stack, started an isolated daemon on 127.0.0.1:16731, and imported a real Claude Code session that had previously run in Always Ask mode:

$ node packages/cli/dist/index.js import b1d2305a-f0f1-4c20-a887-0e7e89d458fb --provider claude --cwd /tmp --mode auto --json --home /tmp/paseo-qa-4731-20260911
{
  "agentId": "e2e83a43-abb9-4348-b20f-9b72394a1fe6",
  "status": "created",
  "provider": "claude",
  "cwd": "/tmp",
  "title": "Run pwd exactly once, then stop."
}

$ node packages/cli/dist/index.js inspect e2e83a43 --json --home /tmp/paseo-qa-4731-20260911

Relevant fields from the complete JSON output:

"Status": "idle",
"Mode": "auto",
"PendingPermissions": []

Then exercised the first tool call from the imported session:

$ node packages/cli/dist/index.js send e2e83a43 "Use the Write tool to create /tmp/paseo-import-mode-qa.txt containing exactly hello." --json --home /tmp/paseo-qa-4731-20260911
{
  "agentId": "e2e83a43-abb9-4348-b20f-9b72394a1fe6",
  "status": "completed",
  "message": "Agent completed processing the message"
}

$ node packages/cli/dist/index.js permit ls --json --home /tmp/paseo-qa-4731-20260911
[]

$ sed -n '1p' /tmp/paseo-import-mode-qa.txt
hello

The isolated daemon was stopped and the probe file removed after QA.

Repository checks:

$ npm run typecheck
[all workspaces exit 0]

$ npm run lint
Found 0 warnings and 0 errors.
Finished in 703ms on 4182 files with 177 rules using 14 threads.

Protocol compatibility

modeId is optional on import_agent_request. Older clients continue sending the existing shape, which the new daemon accepts; older daemons accept the new request because their Zod object schema strips the unknown optional field. No response shape changed.

Platforms

Platform Tested Notes
macOS Yes Node 22.23.1; real CLI, isolated daemon, Claude Code import and first Write tool call
Windows No CLI/daemon plumbing is platform-independent
Linux No CLI/daemon plumbing is platform-independent

@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds provider-mode selection to paseo import and carries the optional mode through the CLI, client, protocol, and daemon import paths.

  • Applies the requested mode to both fresh imports and restored archived agents.
  • Keeps the protocol field optional for backward compatibility.
  • Adds focused regression coverage across the CLI, client, protocol, and server layers.
  • The follow-up revision promotes the import and unarchive contracts in agent-manager.ts to named interfaces.

Confidence Score: 5/5

The PR appears safe to merge, with mode propagation covered across both fresh and archived import paths and no outstanding findings.

The optional mode is propagated consistently from the CLI through the protocol into persisted session configuration without narrowing the existing wire contract. The previous named-type thread was manually resolved without explanation.

Important Files Changed

Filename Overview
packages/cli/src/commands/agent/import.ts Adds the --mode option and forwards it as modeId in the import request.
packages/client/src/daemon-client.ts Extends the import client input and wire request with the optional mode.
packages/protocol/src/messages.ts Adds an optional, backward-compatible modeId field to the import request schema.
packages/server/src/server/agent/import-sessions.ts Propagates the requested mode through fresh-import and archived-record restoration paths.
packages/server/src/server/agent/agent-manager.ts Applies the mode to stored provider configuration and introduces named import and unarchive contracts.

Sequence Diagram

sequenceDiagram
    participant CLI as paseo import
    participant Client as DaemonClient
    participant Protocol as import_agent_request
    participant Import as Import session handler
    participant Manager as AgentManager
    participant Provider as Provider session

    CLI->>Client: importAgent(modeId?)
    Client->>Protocol: import_agent_request(modeId?)
    Protocol->>Import: normalized request
    alt Archived Paseo record exists
        Import->>Manager: unarchiveSnapshot(modeId?)
        Manager->>Manager: persist updated config
    else Fresh provider import
        Import->>Manager: importProviderSession(modeId?)
        Manager->>Provider: importSession(storedConfig)
    end
    Manager->>Provider: open configured session
Loading

Reviews (2): Last reviewed commit: "refactor(server): name import parameter ..." | Re-trigger Greptile

Comment thread packages/server/src/server/agent/agent-manager.ts Outdated
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.

bug: paseo import has no --mode, so an imported agent lands on Always Ask and silently stalls on its first tool call

1 participant