From e563cff034985253486770be387fef2983939db0 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Sun, 8 Feb 2026 18:44:04 -0500 Subject: [PATCH] core: add handoff API endpoint for session extraction --- .../opencode/src/server/routes/session.ts | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/packages/opencode/src/server/routes/session.ts b/packages/opencode/src/server/routes/session.ts index 82e6f3121b..3dc293e9f1 100644 --- a/packages/opencode/src/server/routes/session.ts +++ b/packages/opencode/src/server/routes/session.ts @@ -7,6 +7,7 @@ import { MessageV2 } from "../../session/message-v2" import { SessionPrompt } from "../../session/prompt" import { SessionCompaction } from "../../session/compaction" import { SessionRevert } from "../../session/revert" +import { SessionHandoff } from "../../session/handoff" import { SessionStatus } from "@/session/status" import { SessionSummary } from "@/session/summary" import { Todo } from "../../session/todo" @@ -935,5 +936,41 @@ export const SessionRoutes = lazy(() => }) return c.json(true) }, + ) + .post( + "/:sessionID/handoff", + describeRoute({ + summary: "Handoff session", + description: "Extract context and relevant files for another agent to continue the conversation.", + operationId: "session.handoff", + responses: { + 200: { + description: "Handoff data extracted", + content: { + "application/json": { + schema: resolver(z.object({ text: z.string(), files: z.string().array() })), + }, + }, + }, + ...errors(400, 404), + }, + }), + validator( + "param", + z.object({ + sessionID: z.string().meta({ description: "Session ID" }), + }), + ), + validator("json", SessionHandoff.handoff.schema.omit({ sessionID: true })), + async (c) => { + const params = c.req.valid("param") + const body = c.req.valid("json") + const result = await SessionHandoff.handoff({ + sessionID: params.sessionID, + model: body.model, + goal: body.goal, + }) + return c.json(result) + }, ), )