Skip to content

fix(cli): restore imported custom sessions from matching config - #689

Draft
Dante-dan wants to merge 1 commit into
LodyAI:mainfrom
Dante-dan:fix/188-imported-custom-session-launch
Draft

Dante-dan wants to merge 1 commit into
LodyAI:mainfrom
Dante-dan:fix/188-imported-custom-session-launch

Conversation

@Dante-dan

Copy link
Copy Markdown

Related issue

Closes #188

Problem / pressure

An imported custom ACP session records its provider identity but legitimately has no agentConfigId. The resume path therefore returned without consulting the target machine's current agent configurations and failed with session_restore_failed, even when exactly one machine-owned configuration could safely supply the custom launch command.

Summary

  • Read the target machine's agentConfig family only for externally imported custom sessions without an explicit config id.
  • Match the session's machineId, cliType, and agentType, accepting exactly one current configuration and failing closed for zero or multiple matches.
  • Preserve explicit-id lookup, legacy launch fields, builtin/registry providers, and machine-owned command/environment/runtime authority.
  • Document the decision in paired English and Chinese Agent Notes.

Visual explanation

flowchart TD
    A[Resume imported session] --> B{Explicit agentConfigId?}
    B -- Yes --> C[Existing exact-id resolution]
    B -- No --> D{external-acp + custom?}
    D -- No --> E[Existing legacy or provider resolution]
    D -- Yes --> F[Read target-machine agentConfig family]
    F --> G{Matches machineId + cliType + agentType}
    G -- Exactly one --> H[Use current machine-owned launch fields]
    G -- Zero or multiple --> I[Remain unresolved; restore reports failure]
Loading

Before / after

Before After
Imported custom sessions without agentConfigId never consulted current machine configuration. An imported session uses the current target-machine config only when its provider identity has exactly one match.
A matching custom command could not be recovered, so restore failed immediately. The unique match supplies customAcp, environment, and runtime overrides; missing or ambiguous matches still fail closed.

Test plan

  • pnpm --filter lody exec vitest run src/session/session-launch-config-resolver.test.ts — 7/7 passed.
  • pnpm format — passed for the submitted files.
  • git diff --check — passed.

Context handoff

This handoff is public. An invalid external PR receives a seven-day correction period before closure.

Instructions for reviewing agents

  • Review focus: Check session-launch-config-resolver.ts for target-machine authority, unique-match semantics, and preservation of explicit-id and legacy paths.
  • Decisions to challenge: Confirm that matching machineId, cliType, and agentType is sufficient and that ambiguity should fail closed instead of selecting by ordering.
  • Plausible failures / evidence gaps: A live third-party custom ACP process was not launched; broader integration behavior depends on remote CI and the existing restore error path.

Authoring context

  • User goal / directives: Restore startup from the configuration uniquely matching the target machine and report an explicit error when no safe match exists.
  • Constraints / non-goals: Do not trust imported metadata or control-plane input with executable fields, do not alter non-imported or builtin/registry resolution, and do not decide read-only provider prompt semantics here.
  • Risk-bearing decisions: The resolver follows the current machine configuration rather than snapshotting the import-time command, and refuses both missing and ambiguous matches.
  • Destructive or irreversible behavior: The change performs no migration, overwrite, cleanup, or destructive action; an unresolved match leaves the existing restore failure behavior intact.
  • Deliberately not done or tested: No UI/E2E flow or live third-party ACP process was run because this is a focused resolver change; remote CI supplies broader repository coverage.
  • Unknowns / confidence: The pure resolver boundary is covered with high confidence; the separate product behavior for read-only history providers remains unresolved and out of scope.

Original user prompt

Show original prompt
#188:恢复启动时,应该用目标机器唯一匹配配置恢复,匹配不上应该明确报错。

Model: gpt-5.6-sol
Signed-off-by: Dante <duanjl.china@gmail.com>
@Dante-dan
Dante-dan force-pushed the fix/188-imported-custom-session-launch branch from 50c547b to d618845 Compare September 14, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Imported sessions from a custom ACP agent fail to open (session_restore_failed)

1 participant