fix: forward agent/model/variant to session creation

createSession() only sent { directory, title } to the OpenCode server,
dropping the agent field. The create() function read payload.agent but
never forwarded it, so every session was created with the OpenCode
default (build) and the agent was only applied later at prompt time.

Now forwards agent/model/variant in the session create POST body so the
session is created with the requested agent from the start.
This commit is contained in:
2026-09-06 17:25:40 +00:00
parent 3991a6432a
commit 4b95b327dd
@@ -196,7 +196,7 @@ const runPromptAsync = async ({ baseUrl, authHeaders, sessionID, directory, payl
}
};
const createSession = async ({ baseUrl, authHeaders, directory, title }) => {
const createSession = async ({ baseUrl, authHeaders, directory, title, agent, model, variant }) => {
const sessionUrl = new URL(`${baseUrl}/session`);
sessionUrl.searchParams.set('directory', directory);
const response = await fetch(sessionUrl.toString(), {
@@ -207,7 +207,13 @@ const createSession = async ({ baseUrl, authHeaders, directory, title }) => {
'content-type': 'application/json',
accept: 'application/json',
},
body: JSON.stringify({ directory, ...(title ? { title } : {}) }),
body: JSON.stringify({
directory,
...(title ? { title } : {}),
...(agent ? { agent } : {}),
...(model ? { model } : {}),
...(variant ? { variant } : {}),
}),
});
if (!response.ok) {
@@ -725,6 +731,9 @@ export const createOpenChamberSessionService = (dependencies) => {
authHeaders,
directory: sessionDirectory,
...(title ? { title } : {}),
...(agent ? { agent } : {}),
...(model ? { model } : {}),
...(variant ? { variant } : {}),
});
let dispatch = { model, agent, variant, promptDispatched: false, dispatchedAsCommand: false };