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
6 changes: 4 additions & 2 deletions src/agent/opencode-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ interface V2CatalogModelEntry {
export interface V2PluginContext {
session?: {
hook?: (name: string, cb: (e: V2HttpRequestEvent) => void | Promise<void>) => void | Promise<V2Registration | undefined>;
synthetic?: (input: { sessionID: string; text: string }) => Promise<unknown>;
synthetic?: (input: { sessionID: string; text: string; description?: string; resume?: boolean }) => Promise<unknown>;
};
tool?: {
transform?: (cb: (editor: V2ToolEditor) => void) => void | Promise<V2Registration | undefined>;
Expand Down Expand Up @@ -256,7 +256,9 @@ export function createOpencodeV2Setup(options: OpencodeV2SetupOptions = {}): (ct
}
}
try {
await ctx.session?.synthetic?.({ sessionID: sid, text });
// resume:false — OpenCode V2 defaults to delivery "steer" + execution.wake(), which would
// start a model turn on every /acp invocation with no user input (spurious empty turns).
await ctx.session?.synthetic?.({ sessionID: sid, text, resume: false });
} catch (err) {
console.error(`[bili-opencode] /acp render failed: ${err instanceof Error ? err.message : String(err)}`);
}
Expand Down
6 changes: 4 additions & 2 deletions tests/opencode-v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function makeFakeCtx() {
let signal: AbortSignal | undefined;
const addedTools: FakeAddedTool[] = [];
const addedCommands: FakeAddedCommand[] = [];
const syntheticCalls: Array<{ sessionID: string; text: string }> = [];
const syntheticCalls: Array<{ sessionID: string; text: string; description?: string; resume?: boolean }> = [];
let modelRequestCb: ((e: Record<string, unknown>) => void | Promise<void>) | undefined;
const disposed: number[] = [];

Expand All @@ -91,7 +91,7 @@ function makeFakeCtx() {
modelRequestCb = cb;
return { dispose: () => { disposed.push(1); } };
},
synthetic: async (input: { sessionID: string; text: string }) => {
synthetic: async (input: { sessionID: string; text: string; description?: string; resume?: boolean }) => {
syntheticCalls.push(input);
return {};
},
Expand Down Expand Up @@ -355,6 +355,7 @@ test("v2 setup: /acp command registered and renders proxy status panel via synth
await until(() => fake.syntheticCalls.length === 1);
assert.equal(fake.syntheticCalls[0].sessionID, "ses_acp_1");
assert.match(fake.syntheticCalls[0].text, /ACP-PANEL-OK/);
assert.equal(fake.syntheticCalls[0].resume, false);
} finally {
cleanup();
}
Expand All @@ -373,6 +374,7 @@ test("v2 setup: /acp reports no proxy detected via synthetic when no proxy", asy
await acp.execute({ sessionID: "s_nopx" });
await until(() => fake.syntheticCalls.length === 1);
assert.match(fake.syntheticCalls[0].text, /no proxy detected/);
assert.equal(fake.syntheticCalls[0].resume, false);
} finally {
cleanup();
}
Expand Down
Loading