



























@@ -3310,6 +3310,89 @@ describe("AcpSessionManager", () => {
33103310});
33113311});
331233123313+it("continues turns when adapters reject optional timeout config", async () => {
3314+const runtimeState = createRuntime();
3315+runtimeState.setConfigOption.mockImplementation(async (input: { key: string }) => {
3316+if (input.key === "timeout") {
3317+throw new AcpRuntimeError(
3318+"ACP_TURN_FAILED",
3319+'Agent rejected session/set_config_option for "timeout": ACP -32602 Invalid params',
3320+);
3321+}
3322+});
3323+hoisted.requireAcpRuntimeBackendMock.mockReturnValue({
3324+id: "acpx",
3325+runtime: runtimeState.runtime,
3326+});
3327+hoisted.readAcpSessionEntryMock.mockReturnValue({
3328+sessionKey: "agent:opencode:acp:session-1",
3329+storeSessionKey: "agent:opencode:acp:session-1",
3330+acp: {
3331+ ...readySessionMeta({ agent: "opencode" }),
3332+runtimeOptions: {
3333+timeoutSeconds: 120,
3334+},
3335+},
3336+});
3337+3338+const manager = new AcpSessionManager();
3339+await manager.runTurn({
3340+cfg: baseCfg,
3341+sessionKey: "agent:opencode:acp:session-1",
3342+text: "do work",
3343+mode: "prompt",
3344+requestId: "run-opencode",
3345+});
3346+3347+expectMockCallFields(runtimeState.setConfigOption, {
3348+key: "timeout",
3349+value: "120",
3350+});
3351+expect(runtimeState.runTurn).toHaveBeenCalledTimes(1);
3352+});
3353+3354+it("fails turns when adapters reject required runtime config", async () => {
3355+const runtimeState = createRuntime();
3356+runtimeState.setConfigOption.mockImplementation(async (input: { key: string }) => {
3357+if (input.key === "model") {
3358+throw new AcpRuntimeError(
3359+"ACP_TURN_FAILED",
3360+'Agent rejected session/set_config_option for "model": ACP -32602 Invalid params',
3361+);
3362+}
3363+});
3364+hoisted.requireAcpRuntimeBackendMock.mockReturnValue({
3365+id: "acpx",
3366+runtime: runtimeState.runtime,
3367+});
3368+hoisted.readAcpSessionEntryMock.mockReturnValue({
3369+sessionKey: "agent:opencode:acp:session-1",
3370+storeSessionKey: "agent:opencode:acp:session-1",
3371+acp: {
3372+ ...readySessionMeta({ agent: "opencode" }),
3373+runtimeOptions: {
3374+model: "opencode/gpt-5.4",
3375+},
3376+},
3377+});
3378+3379+const manager = new AcpSessionManager();
3380+await expectRejectedRecord(
3381+manager.runTurn({
3382+cfg: baseCfg,
3383+sessionKey: "agent:opencode:acp:session-1",
3384+text: "do work",
3385+mode: "prompt",
3386+requestId: "run-opencode",
3387+}),
3388+{
3389+code: "ACP_TURN_FAILED",
3390+},
3391+);
3392+3393+expect(runtimeState.runTurn).not.toHaveBeenCalled();
3394+});
3395+33133396it("maps persisted thinking runtime options to advertised effort config keys before running turns", async () => {
33143397const runtimeState = createRuntime();
33153398runtimeState.getCapabilities.mockResolvedValue({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。