Skip to content

The agent that grows with you

fix(desktop): canonical create keeps a manual model pick's provider

Teknium78bc44f58525
diff --git a/apps/desktop/src/api/canonical-create-options.test.ts b/apps/desktop/src/api/canonical-create-options.test.ts
index f9bd00ecc66..f3290098b40 100644
--- a/apps/desktop/src/api/canonical-create-options.test.ts
+++ b/apps/desktop/src/api/canonical-create-options.test.ts
@@ -23,7 +23,9 @@ const CASES: Array<[string, Record<string, unknown>, Record<string, unknown> | R
['onboarding minimal effort', { ...BASE, reasoning_effort: 'minimal', fast: false, title: 'Welcome' }, { reasoning: 'minimal', title: 'Welcome', service_tier: 'normal' }],
['Bot Chat', { ...BASE, title: 'Bot Chat', hidden: true, follow_profile_config: true }, { follow_profile_config: true, hidden: true }],
['Fast speed', { ...BASE, cwd: '/w', cwd_explicit: false, fast: true }, { cwd: '/w', service_tier: 'priority' }],
- ['Ultrafast speed', { ...BASE, fast: true, service_tier: 'ultrafast' }, { service_tier: 'ultrafast' }]
+ ['Ultrafast speed', { ...BASE, fast: true, service_tier: 'ultrafast' }, { service_tier: 'ultrafast' }],
+ // KoNit-K P1: a manual model pick ships its provider; the owner's create contract admits both.
+ ['manual model + provider', { ...BASE, model: 'gpt-5', provider: 'openrouter', fast: false }, { model: 'gpt-5', provider: 'openrouter', service_tier: 'normal' }]
]
test.each(CASES)('%s: the Desktop create frame is admitted by the owner contract or refused by name', async (_label, params, expected) => {
diff --git a/apps/desktop/src/api/canonical-protocol.test.ts b/apps/desktop/src/api/canonical-protocol.test.ts
index 69ae00b742b..f20e760f327 100644
--- a/apps/desktop/src/api/canonical-protocol.test.ts
+++ b/apps/desktop/src/api/canonical-protocol.test.ts
@@ -85,7 +85,7 @@ test('metadata writes retain the original CAS revision and request identity unti
expect(protocol.prepare('session.archive', { session_id: 's', archived: true })).toMatchObject({ expected_revision: 8, operation: 'archive', payload: { archived: true } })
})
-test('canonical create retries retain identity and reject unsupported explicit intent', () => {
+test('canonical create retries retain identity', () => {
const protocol = new CanonicalDesktopProtocol()
const params = { source: 'desktop', profile: 'default', cols: 96, fast: false, cwd: '/tmp' }
const first = protocol.prepare('session.create', params)
@@ -93,7 +93,9 @@ test('canonical create retries retain identity and reject unsupported explicit i
expect(protocol.prepare('session.create', { ...params })).toEqual(first)
expect(first).not.toHaveProperty('profile')
expect(protocol.prepare('session.create', { ...params, fast: true })).toMatchObject({ service_tier: 'priority' })
- expect(() => protocol.prepare('session.create', { ...params, provider: 'custom' })).toThrow('provider')
+ const manual = protocol.prepare('session.create', { ...params, model: 'gpt-5', provider: 'custom' })
+ expect(manual).toMatchObject({ model: 'gpt-5', provider: 'custom' })
+ expect(protocol.prepare('session.create', { ...params, model: 'gpt-5', provider: 'custom' })).toEqual(manual)
protocol.result('session.create', first, { session_id: 'canonical', stored_session_id: 'canonical' })
expect(protocol.prepare('session.create', params).request_id).not.toBe(first.request_id)
})
diff --git a/apps/desktop/src/api/canonical-protocol.ts b/apps/desktop/src/api/canonical-protocol.ts
index 4c8ab3a54b2..4ae8aa23453 100644
--- a/apps/desktop/src/api/canonical-protocol.ts
+++ b/apps/desktop/src/api/canonical-protocol.ts
@@ -384,7 +384,7 @@ export class CanonicalDesktopProtocol {
}
// The composer's per-session create options in the owner's create contract: the effort is the
- // frozen launch `reasoning`; the speed pick is `service_tier` (main: an explicit tier wins, Fast
+ // frozen launch `reasoning`; a manual model pick keeps its `provider`; the speed pick is `service_tier` (main: an explicit tier wins, Fast
// pins priority, Normal pins normal over a profile tier, omitted inherits); `cwd_explicit` is the
// provenance that lets a named profile's own workspace beat an inherited cwd.
private prepareCreate(input: Record<string, unknown>): Record<string, unknown> {
@@ -397,13 +397,13 @@ export class CanonicalDesktopProtocol {
if (typeof params.cwd_explicit !== 'boolean') { delete params.cwd_explicit }
- const allowed = new Set(['request_id', 'source', 'cwd', 'model', 'toolsets', 'reasoning', 'profile', 'cols', 'title', 'hidden', 'follow_profile_config', 'service_tier', 'cwd_explicit'])
+ const allowed = new Set(['request_id', 'source', 'cwd', 'model', 'provider', 'toolsets', 'reasoning', 'profile', 'cols', 'title', 'hidden', 'follow_profile_config', 'service_tier', 'cwd_explicit'])
const unsupported = Object.keys(params).filter(key => !allowed.has(key))
if (unsupported.length) { throw new Error(`Canonical gateway does not support explicit session options: ${unsupported.join(', ')}`) }
const result = Object.fromEntries(Object.entries(params).filter(([key, value]) =>
- ['request_id', 'cwd', 'model', 'toolsets', 'reasoning', 'title', 'hidden', 'follow_profile_config', 'service_tier', 'cwd_explicit'].includes(key) || (key === 'profile' && siblingRoute(value))))
+ ['request_id', 'cwd', 'model', 'provider', 'toolsets', 'reasoning', 'title', 'hidden', 'follow_profile_config', 'service_tier', 'cwd_explicit'].includes(key) || (key === 'profile' && siblingRoute(value))))
const key = JSON.stringify(result)
const requestId = params.request_id ?? this.creates.get(key) ?? crypto.randomUUID()