* Compute the `currentValue` for the `model` config option when the * caller (either `newSession` or `loadSession`'s fallback path) does * not have a more specific signal. Prefers the harness's configured * `defaultModel`; otherwise falls back to the first listed catalog * alias so the d
()
| 785 | * `default_model = ...` sees a breadcrumb in the agent log. |
| 786 | */ |
| 787 | private async resolveCurrentModelId(): Promise<string> { |
| 788 | // Minimal-stub harnesses (no `getConfig`) skip the catalog entirely |
| 789 | // and return the empty string silently. The old code path was the |
| 790 | // same — `listAvailableModels` used to live behind a |
| 791 | // `typeof harness.listAvailableModels === 'function'` guard, and we |
| 792 | // preserve that ergonomic so adapter unit tests with bare-bones |
| 793 | // stubs don't fire spurious "no models" warnings. |
| 794 | if (typeof this.harness.getConfig !== 'function') return ''; |
| 795 | try { |
| 796 | const config = await this.harness.getConfig(); |
| 797 | const declared = config.defaultModel; |
| 798 | if (typeof declared === 'string' && declared.length > 0) { |
| 799 | return declared; |
| 800 | } |
| 801 | } catch (err) { |
| 802 | log.warn('acp: harness.getConfig threw during configOptions assembly; falling back', { |
| 803 | error: err instanceof Error ? err.message : String(err), |
| 804 | }); |
| 805 | return ''; |
| 806 | } |
| 807 | try { |
| 808 | const models = await listModelsFromHarness(this.harness); |
| 809 | if (models.length === 0) { |
| 810 | log.warn('acp: harness exposes no models; configOptions will ship an empty model picker'); |
| 811 | return ''; |
| 812 | } |
| 813 | log.warn( |
| 814 | 'acp: harness has no defaultModel; falling back to first catalog entry for configOptions.currentValue', |
| 815 | { fallbackModelId: models[0]!.id }, |
| 816 | ); |
| 817 | return models[0]!.id; |
| 818 | } catch (err) { |
| 819 | log.warn('acp: listModelsFromHarness threw during configOptions assembly', { |
| 820 | error: err instanceof Error ? err.message : String(err), |
| 821 | }); |
| 822 | } |
| 823 | return ''; |
| 824 | } |
| 825 | |
| 826 | /** |
| 827 | * Compute the initial value for the `thinking` toggle when |
no test coverage detected