718884210b
- fix(hooks): skip todo continuation when agent has pending question (#1888) Add pending-question-detection module that walks messages backwards to detect unanswered question tool_use, preventing CONTINUATION_PROMPT injection while awaiting user response. - fix(config): allow custom agent names in disabled_agents (#1693) Change disabled_agents schema from BuiltinAgentNameSchema to z.string() and add filterDisabledAgents helper in agent-config-handler to filter user, project, and plugin agents with case-insensitive matching. - fix(agents): change primary agents mode to 'all' (#1891) Update Sisyphus, Hephaestus, and Atlas agent modes from 'primary' to 'all' so they are available for @mention routing and task() delegation in addition to direct chat.
41 lines
985 B
TypeScript
41 lines
985 B
TypeScript
import { log } from "../../shared/logger"
|
|
import { HOOK_NAME } from "./constants"
|
|
|
|
interface MessagePart {
|
|
type: string
|
|
name?: string
|
|
toolName?: string
|
|
}
|
|
|
|
interface Message {
|
|
info?: { role?: string }
|
|
role?: string
|
|
parts?: MessagePart[]
|
|
}
|
|
|
|
export function hasUnansweredQuestion(messages: Message[]): boolean {
|
|
if (!messages || messages.length === 0) return false
|
|
|
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
const msg = messages[i]
|
|
const role = msg.info?.role ?? msg.role
|
|
|
|
if (role === "user") return false
|
|
|
|
if (role === "assistant" && msg.parts) {
|
|
const hasQuestion = msg.parts.some(
|
|
(part) =>
|
|
(part.type === "tool_use" || part.type === "tool-invocation") &&
|
|
(part.name === "question" || part.toolName === "question"),
|
|
)
|
|
if (hasQuestion) {
|
|
log(`[${HOOK_NAME}] Detected pending question tool in last assistant message`)
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|