fix(keyword-detector): use session state for agent-specific ultrawork templates

Bug: When switching from Prometheus to Sisyphus, the Prometheus ultrawork
template was still injected because:
1. setSessionAgent() only sets on first call, ignoring subsequent updates
2. keyword-detector relied solely on input.agent which could be stale

Fix:
- Use updateSessionAgent() instead of setSessionAgent() in index.ts
- keyword-detector now uses getSessionAgent() as primary source, fallback to input.agent
- Added tests for agent switch scenario
This commit is contained in:
justsisyphus
2026-01-16 19:06:00 +09:00
parent 7cd59e9c0a
commit 5ee8996a39
3 changed files with 201 additions and 5 deletions
+3 -2
View File
@@ -51,6 +51,7 @@ import {
setMainSession,
getMainSessionID,
setSessionAgent,
updateSessionAgent,
clearSessionAgent,
} from "./features/claude-code-session-state";
import {
@@ -309,7 +310,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
"chat.message": async (input, output) => {
if (input.agent) {
setSessionAgent(input.sessionID, input.agent);
updateSessionAgent(input.sessionID, input.agent);
}
const message = (output as { message: { variant?: string } }).message
@@ -450,7 +451,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
const agent = info?.agent as string | undefined;
const role = info?.role as string | undefined;
if (sessionID && agent && role === "user") {
setSessionAgent(sessionID, agent);
updateSessionAgent(sessionID, agent);
}
}