mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-21 07:45:38 +00:00
fix(acp): report the restored model’s thinking level
Restoring the saved model can change the active thinking level before Paseo replays a saved preference. Read the level from the model response so a stale preference falls back to the current model’s setting.
This commit is contained in:
@@ -2501,6 +2501,8 @@ export class ACPAgentSession implements AgentSession, ACPClient {
|
||||
requestedValue: modelId,
|
||||
label: "model",
|
||||
});
|
||||
this.thinkingOptionId =
|
||||
deriveCurrentConfigValue(this.configOptions, "thought_level") ?? this.thinkingOptionId;
|
||||
this.reportFeatureChanges(before);
|
||||
this.pushEvent({
|
||||
type: "model_changed",
|
||||
@@ -3300,10 +3302,7 @@ export class ACPAgentSession implements AgentSession, ACPClient {
|
||||
configOptions: this.configOptions,
|
||||
category: "thought_level",
|
||||
});
|
||||
if (
|
||||
!option ||
|
||||
flattenSelectOptions(option.options).some((choice) => choice.value === requested)
|
||||
) {
|
||||
if (!option || findSelectConfigChoice({ option, value: requested })) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,9 @@ function configOptions() {
|
||||
"effort",
|
||||
"thought_level",
|
||||
effort,
|
||||
loaded ? ["minimal", "low", "medium", "high", "xhigh"] : ["low", "high", "max"],
|
||||
loaded && model === "second-model"
|
||||
? ["minimal", "low", "medium", "high", "xhigh"]
|
||||
: ["low", "high", "max"],
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -58,14 +60,15 @@ readline.createInterface({ input: process.stdin }).on("line", (line) => {
|
||||
break;
|
||||
case "session/load":
|
||||
loaded = true;
|
||||
model = "second-model";
|
||||
effort = "high";
|
||||
model = process.env.ACP_TEST_LOAD_MODEL;
|
||||
effort = model === "second-model" ? "high" : "low";
|
||||
assistantMessage("Response from the saved session");
|
||||
result = { configOptions: configOptions() };
|
||||
break;
|
||||
case "session/set_config_option":
|
||||
if (params.configId === "model") {
|
||||
model = params.value;
|
||||
if (loaded && model === "second-model") effort = "high";
|
||||
} else if (loaded && params.value === "max") {
|
||||
send({
|
||||
id,
|
||||
|
||||
@@ -577,69 +577,74 @@ test("bundled goose lists configured providers and switches models across provid
|
||||
}
|
||||
}, 60_000);
|
||||
|
||||
test("reopens an ACP chat and lets the user replace a rejected saved thinking level", async () => {
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), "paseo-acp-thinking-resume-"));
|
||||
const options = {
|
||||
paseoHomeRoot: root,
|
||||
staticDir: path.join(root, "static"),
|
||||
cleanup: false,
|
||||
mcpEnabled: false,
|
||||
pluginsEnabled: false,
|
||||
providerOverrides: {
|
||||
"thinking-fixture": {
|
||||
extends: "acp" as const,
|
||||
label: "Thinking fixture",
|
||||
command: [
|
||||
process.execPath,
|
||||
path.join(import.meta.dirname, "acp-thinking-resume-fixture.cjs"),
|
||||
],
|
||||
test.each([{ loadModel: "second-model" }, { loadModel: "startup-model" }])(
|
||||
"reopens an ACP chat with a rejected saved thinking level after loading $loadModel",
|
||||
async ({ loadModel }) => {
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), "paseo-acp-thinking-resume-"));
|
||||
const options = {
|
||||
paseoHomeRoot: root,
|
||||
staticDir: path.join(root, "static"),
|
||||
cleanup: false,
|
||||
mcpEnabled: false,
|
||||
pluginsEnabled: false,
|
||||
providerOverrides: {
|
||||
"thinking-fixture": {
|
||||
extends: "acp" as const,
|
||||
label: "Thinking fixture",
|
||||
env: { ACP_TEST_LOAD_MODEL: loadModel },
|
||||
command: [
|
||||
process.execPath,
|
||||
path.join(import.meta.dirname, "acp-thinking-resume-fixture.cjs"),
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
try {
|
||||
const first = await createDaemonTestContext(options);
|
||||
let agentId: string;
|
||||
};
|
||||
try {
|
||||
const agent = await first.client.createAgent({
|
||||
provider: "thinking-fixture",
|
||||
cwd: root,
|
||||
model: "second-model",
|
||||
thinkingOptionId: "max",
|
||||
});
|
||||
agentId = agent.id;
|
||||
expect(agent.thinkingOptionId).toBe("max");
|
||||
await first.client.sendMessage(agentId, "Save this conversation");
|
||||
expect((await first.client.waitForFinish(agentId, 10_000)).status).toBe("idle");
|
||||
} finally {
|
||||
await first.cleanup();
|
||||
}
|
||||
const first = await createDaemonTestContext(options);
|
||||
let agentId: string;
|
||||
try {
|
||||
const agent = await first.client.createAgent({
|
||||
provider: "thinking-fixture",
|
||||
cwd: root,
|
||||
model: "second-model",
|
||||
thinkingOptionId: "max",
|
||||
});
|
||||
agentId = agent.id;
|
||||
expect(agent.thinkingOptionId).toBe("max");
|
||||
await first.client.sendMessage(agentId, "Save this conversation");
|
||||
expect((await first.client.waitForFinish(agentId, 10_000)).status).toBe("idle");
|
||||
} finally {
|
||||
await first.cleanup();
|
||||
}
|
||||
|
||||
const reopened = await createDaemonTestContext(options);
|
||||
try {
|
||||
const timeline = await reopened.client.fetchAgentTimeline(agentId, { limit: 40 });
|
||||
expect(timeline.entries.map(({ item }) => item)).toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: "assistant_message",
|
||||
text: "Response from the saved session",
|
||||
}),
|
||||
);
|
||||
expect((await reopened.client.fetchAgent(agentId))?.agent.runtimeInfo?.thinkingOptionId).toBe(
|
||||
"high",
|
||||
);
|
||||
const reopened = await createDaemonTestContext(options);
|
||||
try {
|
||||
const timeline = await reopened.client.fetchAgentTimeline(agentId, { limit: 40 });
|
||||
expect(timeline.entries.map(({ item }) => item)).toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: "assistant_message",
|
||||
text: "Response from the saved session",
|
||||
}),
|
||||
);
|
||||
expect(
|
||||
(await reopened.client.fetchAgent(agentId))?.agent.runtimeInfo?.thinkingOptionId,
|
||||
).toBe("high");
|
||||
|
||||
// Interactive writes still surface a provider rejection.
|
||||
await expect(reopened.client.setAgentThinkingOption(agentId, "max")).rejects.toThrow(
|
||||
"Invalid params",
|
||||
);
|
||||
await reopened.client.setAgentThinkingOption(agentId, "low");
|
||||
expect((await reopened.client.fetchAgent(agentId))?.agent).toMatchObject({
|
||||
thinkingOptionId: "low",
|
||||
runtimeInfo: { thinkingOptionId: "low" },
|
||||
});
|
||||
// Interactive writes still surface a provider rejection.
|
||||
await expect(reopened.client.setAgentThinkingOption(agentId, "max")).rejects.toThrow(
|
||||
"Invalid params",
|
||||
);
|
||||
await reopened.client.setAgentThinkingOption(agentId, "low");
|
||||
expect((await reopened.client.fetchAgent(agentId))?.agent).toMatchObject({
|
||||
thinkingOptionId: "low",
|
||||
runtimeInfo: { thinkingOptionId: "low" },
|
||||
});
|
||||
} finally {
|
||||
await reopened.cleanup();
|
||||
}
|
||||
} finally {
|
||||
await reopened.cleanup();
|
||||
await rm(root, { recursive: true, force: true });
|
||||
}
|
||||
} finally {
|
||||
await rm(root, { recursive: true, force: true });
|
||||
}
|
||||
}, 60_000);
|
||||
},
|
||||
60_000,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user