diff --git a/apps/server/src/routes/sessions.ts b/apps/server/src/routes/sessions.ts index 0fb702c..8425db9 100644 --- a/apps/server/src/routes/sessions.ts +++ b/apps/server/src/routes/sessions.ts @@ -5,7 +5,6 @@ import type { Config } from '../config.js'; import type { Broker } from '../services/broker.js'; import type { Session } from '../types/api.js'; import { getSetting } from './settings.js'; -import { getAgentsForProject } from '../services/agents.js'; const CreateBody = z.object({ name: z.string().min(1).max(200).optional(), @@ -29,13 +28,6 @@ async function resolveDefaultModel(sql: Sql, config: Config): Promise { return config.DEFAULT_MODEL; } -// First agent in the project's effective list (file-defined or builtin), -// or null if somehow none exist. -async function resolveDefaultAgent(projectPath: string): Promise { - const { agents } = await getAgentsForProject(projectPath); - return agents[0]?.id ?? null; -} - export function registerSessionRoutes( app: FastifyInstance, sql: Sql, @@ -69,14 +61,13 @@ export function registerSessionRoutes( reply.code(400); return { error: 'invalid body', details: parsed.error.flatten() }; } - const project = await sql<{ id: string; path: string }[]>` - SELECT id, path FROM projects WHERE id = ${req.params.id} + const project = await sql<{ id: string }[]>` + SELECT id FROM projects WHERE id = ${req.params.id} `; if (project.length === 0) { reply.code(404); return { error: 'project not found' }; } - const projectPath = project[0]!.path; let model = parsed.data.model; if (!model) { @@ -91,12 +82,11 @@ export function registerSessionRoutes( const name = parsed.data.name ?? 'New session'; const systemPrompt = parsed.data.system_prompt ?? ''; - // If the client provided agent_id (string or null), use it; otherwise - // resolve to the project's first agent (file-defined or builtin), or null. - const agentId = - parsed.data.agent_id !== undefined - ? parsed.data.agent_id - : await resolveDefaultAgent(projectPath); + // v1.11.5.2: default is null (no agent / raw chat) when the client + // omits agent_id. Sam can still pick one from the AgentPicker after + // the session loads. Was: first agent in the project's effective list + // (alphabetically — usually "Code Reviewer"), which felt presumptuous. + const agentId = parsed.data.agent_id ?? null; const row = await sql.begin(async (tx) => { const [session] = await tx`