|
| 1 | +# Plan: Agent Provider Simplification (ACP-only) |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +Replace the “agent provider” abstraction and detection logic with a single explicit rule: **ACP is the only agent provider and is identified by `providerId === 'acp'`.** |
| 6 | + |
| 7 | +## Current Call Flow (relevant parts) |
| 8 | + |
| 9 | +- Main: |
| 10 | + - `ProviderInstanceManager.createProviderInstance()` already special-cases `provider.id === 'acp'`. |
| 11 | + - `ProviderInstanceManager.isAgentProvider()` uses `instanceof BaseAgentProvider` and (if instance not created) a constructor prototype check (`isAgentConstructor`). |
| 12 | + - `LLMProviderPresenter.isAgentProvider()` exposes this to the renderer via `ILlmProviderPresenter`. |
| 13 | +- Renderer: |
| 14 | + - `src/renderer/src/stores/modelStore.ts` calls `llmproviderPresenter.isAgentProvider(providerId)` over IPC to choose between: |
| 15 | + - `agentModelStore.refreshAgentModels(providerId)` (ACP path) |
| 16 | + - `refreshStandardModels + refreshCustomModels` (standard path) |
| 17 | + - Other renderer logic already treats ACP as special via `provider.id === 'acp'`. |
| 18 | + |
| 19 | +## Proposed Changes |
| 20 | + |
| 21 | +### 1) Remove agent-provider classification API |
| 22 | + |
| 23 | +- Remove `isAgentProvider(providerId: string)` from: |
| 24 | + - `src/shared/types/presenters/llmprovider.presenter.d.ts` |
| 25 | + - `src/shared/types/presenters/legacy.presenters.d.ts` |
| 26 | + - `src/main/presenter/llmProviderPresenter/index.ts` |
| 27 | + - `src/main/presenter/llmProviderPresenter/managers/providerInstanceManager.ts` |
| 28 | + |
| 29 | +Rationale: It is only used by the renderer for ACP gating, and ACP can be identified locally by ID. |
| 30 | + |
| 31 | +### 2) Replace renderer gating with an explicit ACP check |
| 32 | + |
| 33 | +- In `src/renderer/src/stores/modelStore.ts`: |
| 34 | + - Remove the async IPC call `llmP.isAgentProvider(providerId)`. |
| 35 | + - Replace with a local predicate: `providerId === 'acp'`. |
| 36 | + - Keep the existing ACP refresh path using `agentModelStore.refreshAgentModels('acp')` (no behavioral change). |
| 37 | + |
| 38 | +### 3) Remove `BaseAgentProvider` (optional but preferred) |
| 39 | + |
| 40 | +Because `BaseAgentProvider` is only used by `AcpProvider`, delete the base class and: |
| 41 | + |
| 42 | +- Make `AcpProvider` extend `BaseLLMProvider` directly. |
| 43 | +- Move `cleanup()` logic into `AcpProvider` (or delegate to `AcpSessionManager` / `AcpProcessManager`). |
| 44 | +- Ensure `cleanup()` is safe to call multiple times and during shutdown. |
| 45 | + |
| 46 | +Notes: |
| 47 | +- `acpCleanupHook` currently awaits `cleanup()` even though `BaseAgentProvider.cleanup()` is `void`. Consider standardizing ACP cleanup to `Promise<void>` to match usage. |
| 48 | + |
| 49 | +## Compatibility / Migration |
| 50 | + |
| 51 | +- No user data migration. |
| 52 | +- Provider ID `acp` remains unchanged and is treated as a stable internal contract. |
| 53 | +- Any internal IPC typing generation must be updated to reflect removal of `isAgentProvider`. |
| 54 | + |
| 55 | +## Test Strategy |
| 56 | + |
| 57 | +Add minimal tests focusing on the only behavioral dependency (renderer model refresh selection): |
| 58 | + |
| 59 | +- Renderer unit test for `modelStore.refreshProviderModels()`: |
| 60 | + - When `providerId === 'acp'`, it uses `agentModelStore.refreshAgentModels`. |
| 61 | + - When `providerId !== 'acp'`, it uses standard refresh path. |
| 62 | + |
| 63 | +Main-process unit tests are optional; the change is mostly removal and ACP-id checks. |
| 64 | + |
| 65 | +## Rollout |
| 66 | + |
| 67 | +Single PR is acceptable if changes stay localized (types + modelStore + ACP provider base class cleanup). |
| 68 | + |
0 commit comments