fix(agent-switch): clear fallback markers on session.error
processedFallbackMessages was only cleaned up on session.deleted, not session.error. This could leak memory for errored sessions. Mirrors the existing session.deleted cleanup pattern. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -56,6 +56,21 @@ export function createAgentSwitchHook(ctx: PluginInput) {
|
||||
return
|
||||
}
|
||||
|
||||
if (input.event.type === "session.error") {
|
||||
const props = input.event.properties as Record<string, unknown> | undefined
|
||||
const info = props?.info as Record<string, unknown> | undefined
|
||||
const erroredSessionID = info?.id ?? props?.sessionID
|
||||
if (typeof erroredSessionID === "string") {
|
||||
clearPendingSwitchRuntime(erroredSessionID)
|
||||
for (const key of Array.from(processedFallbackMessages)) {
|
||||
if (key.startsWith(`${erroredSessionID}:`)) {
|
||||
processedFallbackMessages.delete(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (input.event.type === "message.updated") {
|
||||
const props = input.event.properties as Record<string, unknown> | undefined
|
||||
const info = props?.info as Record<string, unknown> | undefined
|
||||
|
||||
Reference in New Issue
Block a user