Skip to content
Open
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: 5 additions & 1 deletion packages/opencode/src/server/routes/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,11 @@ export const SessionRoutes = lazy(() =>
return stream(c, async () => {
const sessionID = c.req.valid("param").sessionID
const body = c.req.valid("json")
SessionPrompt.prompt({ ...body, sessionID })
SessionStatus.set(sessionID, { type: "busy" })
SessionPrompt.prompt({ ...body, sessionID }).catch((error) => {
log.error("prompt_async failed", { sessionID, error })
SessionStatus.set(sessionID, { type: "idle" })
})
})
},
)
Expand Down
5 changes: 4 additions & 1 deletion packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,10 @@ export namespace SessionPrompt {
}

async function createUserMessage(input: PromptInput) {
const agent = await Agent.get(input.agent ?? (await Agent.defaultAgent()))
const agentName = input.agent ?? (await Agent.defaultAgent())
const agent = await Agent.get(agentName)
if (!agent) throw new Error(`Agent not found: "${agentName}"`)


const model = input.model ?? agent.model ?? (await lastModel(input.sessionID))
const full =
Expand Down
Loading