Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions services/cloud-agent-next/src/session-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3339,22 +3339,21 @@ describe('SessionService.buildWrapperSessionReadyAndPromptRequests', () => {
});
});

it.each([
['cloud-agent-web', true],
[undefined, false],
['app-builder', false],
['code-review', false],
['slack', false],
])('sets Kilo snapshots for %s-origin sessions to %s', async (createdOnPlatform, snapshot) => {
const result = await buildPromptWrapperRequests(createMetadata({ createdOnPlatform }));
const kiloConfig = JSON.parse(result.readyRequest.materialized.env.KILO_CONFIG_CONTENT) as {
snapshot?: boolean;
};
const opencodeConfig = JSON.parse(result.readyRequest.materialized.env.OPENCODE_CONFIG_CONTENT);
it.each(['cloud-agent-web', undefined, 'app-builder', 'code-review', 'slack'])(
'disables Kilo snapshots for %s-origin sessions',
async createdOnPlatform => {
const result = await buildPromptWrapperRequests(createMetadata({ createdOnPlatform }));
const kiloConfig = JSON.parse(result.readyRequest.materialized.env.KILO_CONFIG_CONTENT) as {
snapshot?: boolean;
};
const opencodeConfig = JSON.parse(
result.readyRequest.materialized.env.OPENCODE_CONFIG_CONTENT
);

expect(kiloConfig.snapshot).toBe(snapshot);
expect(opencodeConfig).toEqual(kiloConfig);
});
expect(kiloConfig.snapshot).toBe(false);
expect(opencodeConfig).toEqual(kiloConfig);
}
);

it.each(['fake-deterministic', 'kilo/fake-deterministic'])(
'pins small_model and title model when the session model is %s',
Expand Down
2 changes: 1 addition & 1 deletion services/cloud-agent-next/src/session-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ export class SessionService {
},
},
autoupdate: false,
snapshot: createdOnPlatform === 'cloud-agent-web',
snapshot: false,
Comment thread
kilo-code-bot[bot] marked this conversation as resolved.
};
if (!bitbucketInputPath && mcpServers && Object.keys(mcpServers).length > 0) {
const materialized = materializeMcpServers(mcpServers, env.AGENT_ENV_VARS_PRIVATE_KEY);
Expand Down
52 changes: 1 addition & 51 deletions services/cloud-agent-next/test/unit/wrapper/kilo-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ describe('createWrapperKiloClient prompt handoff', () => {
variant: 'high',
system: 'Review only',
tools: { bash: false },
snapshotInitialization: 'wait',
};

const result = await client.sendPrompt(opts);
Expand All @@ -102,7 +101,6 @@ describe('createWrapperKiloClient prompt handoff', () => {
variant: 'high',
system: 'Review only',
tools: { bash: false },
snapshotInitialization: 'wait',
});
}
});
Expand Down Expand Up @@ -404,25 +402,6 @@ describe('createWrapperKiloClient prompt handoff', () => {
).rejects.toThrow('Async prompt for session kilo_sess_rejected failed: HTTP 409');
});

it('passes snapshot wait policy through async prompt requests', async () => {
const fetchMock = vi.fn().mockResolvedValue(new Response(null, { status: 204 }));
vi.stubGlobal('fetch', fetchMock);
const client = createWrapperKiloClient(createSdkClient(), 'http://127.0.0.1:0', workspacePath);

await client.sendPromptAsync({
sessionId: 'kilo_sess_wait',
messageId: 'msg_wait',
prompt: 'queue this prompt',
snapshotInitialization: 'wait',
});

const request = fetchMock.mock.calls[0]?.[0];
expect(request).toBeInstanceOf(Request);
await expect((request as Request).clone().json()).resolves.toMatchObject({
snapshotInitialization: 'wait',
});
});

it('lists exact deduplicated effective model IDs for the requested provider', async () => {
const fetchMock = vi.fn().mockResolvedValue(
new Response(
Expand Down Expand Up @@ -467,36 +446,7 @@ describe('createWrapperKiloClient prompt handoff', () => {
expect(url.searchParams.get('workspace')).toBe(workspacePath);
});

it('passes snapshot wait policy through command requests', async () => {
const fetchMock = vi.fn().mockResolvedValue(
new Response(JSON.stringify(completion), {
status: 200,
headers: { 'content-type': 'application/json' },
})
);
vi.stubGlobal('fetch', fetchMock);
const client = createWrapperKiloClient(createSdkClient(), 'http://127.0.0.1:0', workspacePath);

await client.sendCommand({
sessionId: 'kilo_sess_wait',
command: 'review',
args: 'selected changes',
messageId: 'msg_wait',
snapshotInitialization: 'wait',
});

const request = fetchMock.mock.calls[0]?.[0];
expect(request).toBeInstanceOf(Request);
expect(new URL((request as Request).url).pathname).toBe('/session/kilo_sess_wait/command');
await expect((request as Request).clone().json()).resolves.toEqual({
command: 'review',
arguments: 'selected changes',
messageID: 'msg_wait',
snapshotInitialization: 'wait',
});
});

it('omits snapshot wait policy from default command requests', async () => {
it('serializes default command requests with only command and arguments', async () => {
const fetchMock = vi.fn().mockResolvedValue(
new Response(JSON.stringify(completion), {
status: 200,
Expand Down
86 changes: 0 additions & 86 deletions services/cloud-agent-next/test/unit/wrapper/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,48 +639,6 @@ describe('createPromptHandler', () => {
expect(deps.openConnection).toHaveBeenCalled();
});

it('waits silently for slow snapshot initialization in Cloud Agent web prompts', async () => {
const state = new WrapperState();
const deps = createMockDeps(state);
const handler = createPromptHandler(
{ ...defaultServerConfig, platform: 'cloud-agent-web' },
deps
);

const response = await handler(
jsonRequest({
message: { id: 'msg_web_snapshot', prompt: 'Hello' },
session: completeBinding,
})
);

expect(response.status).toBe(200);
expect(deps.kiloClient.sendPromptAsync).toHaveBeenCalledWith(
expect.objectContaining({ snapshotInitialization: 'wait' })
);
});

it.each([undefined, 'slack', 'code-review', 'app-builder'])(
'does not wait for snapshot initialization in %s-origin prompts',
async platform => {
const state = new WrapperState();
const deps = createMockDeps(state);
const handler = createPromptHandler({ ...defaultServerConfig, platform }, deps);

const response = await handler(
jsonRequest({
message: { id: 'msg_non_web_snapshot', prompt: 'Hello' },
session: completeBinding,
})
);

expect(response.status).toBe(200);
expect(deps.kiloClient.sendPromptAsync).toHaveBeenCalledWith(
expect.not.objectContaining({ snapshotInitialization: expect.anything() })
);
}
);

it('materializes a PDF before opening ingest and sends its local file part to Kilo', async () => {
const state = new WrapperState();
const deps = createMockDeps(state);
Expand Down Expand Up @@ -1106,50 +1064,6 @@ describe('createPromptHandler', () => {
// ---------------------------------------------------------------------------

describe('createCommandHandler', () => {
it('waits silently for slow snapshot initialization in Cloud Agent web commands', async () => {
const state = new WrapperState();
const deps = createMockDeps(state);
const handler = createCommandHandler(
{ ...defaultServerConfig, platform: 'cloud-agent-web' },
deps
);

const response = await handler(
jsonRequest({ command: 'review', messageId: 'msg_web_command', session: completeBinding })
);

expect(response.status).toBe(200);
expect(deps.kiloClient.sendCommand).toHaveBeenCalledWith({
sessionId: 'kilo_sess_1',
command: 'review',
args: undefined,
messageId: 'msg_web_command',
snapshotInitialization: 'wait',
});
});

it.each([undefined, 'slack', 'code-review', 'app-builder'])(
'does not wait for snapshot initialization in %s-origin commands',
async platform => {
const state = new WrapperState();
const deps = createMockDeps(state);
const handler = createCommandHandler({ ...defaultServerConfig, platform }, deps);

const response = await handler(
jsonRequest({
command: 'review',
messageId: 'msg_non_web_command',
session: completeBinding,
})
);

expect(response.status).toBe(200);
expect(deps.kiloClient.sendCommand).toHaveBeenCalledWith(
expect.not.objectContaining({ snapshotInitialization: expect.anything() })
);
}
);

it('routes compact through session summarize with the selected model', async () => {
const state = new WrapperState();
const sendToIngest = vi.fn();
Expand Down
8 changes: 0 additions & 8 deletions services/cloud-agent-next/wrapper/src/kilo-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ type PromptOptions = {
model?: { providerID?: string; modelID: string };
system?: string;
tools?: Record<string, boolean>;
snapshotInitialization?: 'wait';
directory?: string;
signal?: AbortSignal;
};
Expand Down Expand Up @@ -271,7 +270,6 @@ export type WrapperKiloClient = {
agent?: string;
model?: { providerID?: string; modelID: string };
variant?: string;
snapshotInitialization?: 'wait';
directory?: string;
signal?: AbortSignal;
}) => Promise<SessionCommandResponse>;
Expand Down Expand Up @@ -364,9 +362,6 @@ export function createWrapperKiloClient(
...(opts.system ? { system: opts.system } : {}),
...(opts.tools ? { tools: opts.tools } : {}),
...(opts.agent ? { agent: opts.agent } : {}),
...(opts.snapshotInitialization
? { snapshotInitialization: opts.snapshotInitialization }
: {}),
};
}

Expand Down Expand Up @@ -513,9 +508,6 @@ export function createWrapperKiloClient(
? { model: `${opts.model.providerID ?? 'kilo'}/${opts.model.modelID}` }
: {}),
...(opts.variant ? { variant: opts.variant } : {}),
...(opts.snapshotInitialization
? { snapshotInitialization: opts.snapshotInitialization }
: {}),
},
{ signal: opts.signal }
);
Expand Down
8 changes: 0 additions & 8 deletions services/cloud-agent-next/wrapper/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ function wrapperFinalizingResponse(state: WrapperState): Response {
);
}

function snapshotInitializationForPlatform(platform?: string): 'wait' | undefined {
return platform === 'cloud-agent-web' ? 'wait' : undefined;
}

async function applyCommitAttribution(
workspacePath: string,
commitCoAuthor: WrapperCommitCoAuthor | undefined,
Expand Down Expand Up @@ -550,7 +546,6 @@ export function createPromptHandler(config: ServerConfig, deps: ServerDependenci
});

try {
const snapshotInitialization = snapshotInitializationForPlatform(session.platform);
await kiloClient.sendPromptAsync({
sessionId: session.kiloSessionId,
messageId,
Expand All @@ -561,7 +556,6 @@ export function createPromptHandler(config: ServerConfig, deps: ServerDependenci
model: prompt.agent?.model,
system: prompt.agent?.system,
tools: prompt.agent?.tools,
...(snapshotInitialization ? { snapshotInitialization } : {}),
});
logToFile(`job/prompt: sent messageId=${messageId}`);
acknowledgeDelivery('async-prompt');
Expand Down Expand Up @@ -668,13 +662,11 @@ export function createCommandHandler(config: ServerConfig, deps: ServerDependenc
});
}
} else {
const snapshotInitialization = snapshotInitializationForPlatform(session.platform);
result = await kiloClient.sendCommand({
sessionId: session.kiloSessionId,
command: body.command,
args: body.args,
messageId,
...(snapshotInitialization ? { snapshotInitialization } : {}),
});
}
state.updateActivity();
Expand Down