Files
oh-my-opencode/src/features/background-agent/council-response-checker.ts
T
ismeth 2b70130c08 feat(athena): council member continuation enforcer, tool allowlist, and prompt fixes
- Add council-continuation-enforcer to nudge council members until they
  output COUNCIL_MEMBER_RESPONSE, replacing the hacky post-compaction hack
- Add background_wait + background_cancel to council member tool allowlist
  so members can properly manage their explore agents before responding
- Update COUNCIL_DELEGATION_ADDENDUM prompt to instruct members to cancel
  pending tasks and wait for explore results before final response
- Fix council_finalize path resolution to use project directory
- Remove post-compaction-continuation.ts and recentlyCompactedSessions hack
- Add council-response-checker for detecting response tag in session messages
2026-04-15 16:46:05 +09:00

43 lines
1.1 KiB
TypeScript

import type { PluginInput } from "@opencode-ai/plugin"
import { log, normalizeSDKResponse } from "../../shared"
type OpencodeClient = PluginInput["client"]
const COUNCIL_RESPONSE_TAG = "</COUNCIL_MEMBER_RESPONSE>"
export async function sessionHasCouncilResponse(
client: OpencodeClient,
sessionID: string,
): Promise<boolean> {
try {
const response = await client.session.messages({
path: { id: sessionID },
})
const messages = normalizeSDKResponse(
response,
[] as Array<{ info?: { role?: string }; parts?: Array<{ type?: string; text?: string }> }>,
{ preferResponseOnMissingData: true },
)
for (let i = messages.length - 1; i >= 0; i--) {
const msg = messages[i]
if (msg.info?.role !== "assistant") continue
const parts = msg.parts ?? []
for (const part of parts) {
if (part.type === "text" && part.text?.includes(COUNCIL_RESPONSE_TAG)) {
return true
}
}
}
return false
} catch (error) {
log("[council-response-checker] Error checking session for response tag:", {
sessionID,
error: String(error),
})
return false
}
}