feat(athena): add session handoff with Question tool for Atlas/Prometheus routing

After Athena synthesizes council findings, presents user with Question tool
TUI to choose: Atlas (fix now), Prometheus (create plan), or no action.
On selection, session_handoff tool stores intent + calls updateSessionAgent(),
then agent-handoff hook fires on session.idle to switch the main session's
active agent via promptAsync with synthesis context.
This commit is contained in:
ismeth
2026-02-13 12:57:16 +01:00
committed by YeonGyu-Kim
parent 84c91cb8d7
commit 7db0f110ee
16 changed files with 281 additions and 12 deletions
+37
View File
@@ -0,0 +1,37 @@
import type { PluginInput } from "@opencode-ai/plugin"
import { consumePendingHandoff } from "../../features/agent-handoff"
import { log } from "../../shared/logger"
const HOOK_NAME = "agent-handoff" as const
export function createAgentHandoffHook(ctx: PluginInput) {
return {
event: async (input: { event: { type: string; properties?: Record<string, unknown> } }): Promise<void> => {
if (input.event.type !== "session.idle") return
const props = input.event.properties as Record<string, unknown> | undefined
const sessionID = props?.sessionID as string | undefined
if (!sessionID) return
const handoff = consumePendingHandoff(sessionID)
if (!handoff) return
log(`[${HOOK_NAME}] Executing handoff to ${handoff.agent}`, { sessionID })
try {
await ctx.client.session.promptAsync({
path: { id: sessionID },
body: {
agent: handoff.agent,
parts: [{ type: "text", text: handoff.context }],
},
query: { directory: ctx.directory },
})
log(`[${HOOK_NAME}] Handoff to ${handoff.agent} complete`, { sessionID })
} catch (err) {
log(`[${HOOK_NAME}] Handoff failed`, { sessionID, error: String(err) })
}
},
}
}
+1
View File
@@ -0,0 +1 @@
export { createAgentHandoffHook } from "./hook"
+1
View File
@@ -56,3 +56,4 @@ export { createReadImageResizerHook } from "./read-image-resizer"
export { createTodoDescriptionOverrideHook } from "./todo-description-override"
export { createWebFetchRedirectGuardHook } from "./webfetch-redirect-guard"
export { createLegacyPluginToastHook } from "./legacy-plugin-toast"
export { createAgentHandoffHook } from "./agent-handoff";