refactor(switch-agent): replace deferred hook system with direct session.create + promptAsync
Adopt the opencode-handoff pattern: switch_agent now creates a new session and sends the context via promptAsync immediately in the tool's execute function, then navigates the TUI to the new session. Removes ~1700 LOC of complexity: persistent state management, event-based hook monitoring, retry logic, session idle waiting, apply verification, and terminal detection — all replaced by 3 SDK calls. Deleted: src/features/agent-switch/ (14 files), src/hooks/agent-switch/ (4 files) Updated: Athena prompt to announce handoff before calling switch_agent
This commit is contained in:
@@ -9,7 +9,6 @@ import {
|
||||
createCompactionContextInjector,
|
||||
createCompactionTodoPreserverHook,
|
||||
createAtlasHook,
|
||||
createAgentSwitchHook,
|
||||
} from "../../hooks"
|
||||
import { safeCreateHook } from "../../shared/safe-create-hook"
|
||||
import { createUnstableAgentBabysitter } from "../unstable-agent-babysitter"
|
||||
@@ -22,7 +21,6 @@ export type ContinuationHooks = {
|
||||
unstableAgentBabysitter: ReturnType<typeof createUnstableAgentBabysitter> | null
|
||||
backgroundNotificationHook: ReturnType<typeof createBackgroundNotificationHook> | null
|
||||
atlasHook: ReturnType<typeof createAtlasHook> | null
|
||||
agentSwitchHook: ReturnType<typeof createAgentSwitchHook> | null
|
||||
}
|
||||
|
||||
type SessionRecovery = {
|
||||
@@ -118,9 +116,6 @@ export function createContinuationHooks(args: {
|
||||
}))
|
||||
: null
|
||||
|
||||
const agentSwitchHook = isHookEnabled("agent-switch")
|
||||
? safeHook("agent-switch", () => createAgentSwitchHook(ctx))
|
||||
: null
|
||||
|
||||
return {
|
||||
stopContinuationGuard,
|
||||
@@ -130,6 +125,5 @@ export function createContinuationHooks(args: {
|
||||
unstableAgentBabysitter,
|
||||
backgroundNotificationHook,
|
||||
atlasHook,
|
||||
agentSwitchHook,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user