fix(api): preserve dynamic defaults after rebase

This commit is contained in:
imccyu
2026-08-07 19:44:47 +08:00
parent 8bbbb6fe59
commit 55ccfb5a48
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -20,8 +20,8 @@ export type ApiRemoteAgentResult =
/** Resume configuration supplied by the owning Host composition. */ /** Resume configuration supplied by the owning Host composition. */
export interface ApiRemoteAgentOptions { export interface ApiRemoteAgentOptions {
/** Per-Agent defaults used when a cold identity must resume. */ /** Read the per-Agent defaults when a cold identity must resume. */
readonly agentOptions?: AgentOptions readonly agentOptions?: () => AgentOptions
/** Host-specific Agent-scope composition completed before publication. */ /** Host-specific Agent-scope composition completed before publication. */
readonly setup?: AgentSetup readonly setup?: AgentSetup
} }
@@ -144,7 +144,7 @@ export function createApiRemoteAgentResolver(
} }
const handle = await ctx.agents.resume({ const handle = await ctx.agents.resume({
resumeSessionId: sessionId, resumeSessionId: sessionId,
...options.agentOptions === undefined ? {} : { agentOptions: options.agentOptions }, ...options.agentOptions === undefined ? {} : { agentOptions: options.agentOptions() },
...options.setup === undefined ? {} : { setup: options.setup }, ...options.setup === undefined ? {} : { setup: options.setup },
}) })
return handle.agent return handle.agent
@@ -206,7 +206,7 @@ describe('Remote Agent and Session lookup policy', () => {
}) })
const defaultAgentLookup = ctx.typert.lookups.get('agent') const defaultAgentLookup = ctx.typert.lookups.get('agent')
const defaultSessionLookup = ctx.typert.lookups.get('session') const defaultSessionLookup = ctx.typert.lookups.get('session')
createApiProxy(ctx, { provider: 'p', model: 'm', cwd: '/tmp', workspaceRoot: '/tmp' }) createApiProxy(ctx, { defaultTarget: () => ({ provider: 'p', model: 'm' }), cwd: '/tmp', workspaceRoot: '/tmp' })
await vi.waitFor(() => { await vi.waitFor(() => {
expect(ctx.typert.lookups.get('agent')).not.toBe(defaultAgentLookup) expect(ctx.typert.lookups.get('agent')).not.toBe(defaultAgentLookup)
expect(ctx.typert.lookups.get('session')).not.toBe(defaultSessionLookup) expect(ctx.typert.lookups.get('session')).not.toBe(defaultSessionLookup)
@@ -250,7 +250,7 @@ describe('Remote Agent and Session lookup policy', () => {
const resume = vi.spyOn(ctx.agents, 'resume') const resume = vi.spyOn(ctx.agents, 'resume')
const defaultAgentLookup = ctx.typert.lookups.get('agent') const defaultAgentLookup = ctx.typert.lookups.get('agent')
const defaultSessionLookup = ctx.typert.lookups.get('session') const defaultSessionLookup = ctx.typert.lookups.get('session')
createApiProxy(ctx, { provider: 'p', model: 'm', cwd: '/tmp', workspaceRoot: '/tmp' }) createApiProxy(ctx, { defaultTarget: () => ({ provider: 'p', model: 'm' }), cwd: '/tmp', workspaceRoot: '/tmp' })
await vi.waitFor(() => { await vi.waitFor(() => {
expect(ctx.typert.lookups.get('agent')).not.toBe(defaultAgentLookup) expect(ctx.typert.lookups.get('agent')).not.toBe(defaultAgentLookup)
expect(ctx.typert.lookups.get('session')).not.toBe(defaultSessionLookup) expect(ctx.typert.lookups.get('session')).not.toBe(defaultSessionLookup)