fix(hooks): extract model from assistant messages with flat modelID/providerID

OpenCode API returns different structures for user vs assistant messages:
- User: info.model = { providerID, modelID } (nested)
- Assistant: info.modelID, info.providerID (flat top-level)

Previous code only checked nested format, causing model info loss when
continuation hooks fired after assistant messages.

Files modified:
- todo-continuation-enforcer.ts
- ralph-loop/index.ts
- sisyphus-task/tools.ts
- background-agent/manager.ts

Added test for assistant message model extraction.
This commit is contained in:
justsisyphus
2026-01-16 13:54:22 +09:00
parent 1d47d54a51
commit 227cc52f20
5 changed files with 59 additions and 11 deletions
+4 -2
View File
@@ -381,15 +381,17 @@ export function createTodoContinuationEnforcer(
info?: {
agent?: string
model?: { providerID: string; modelID: string }
modelID?: string
providerID?: string
tools?: Record<string, ToolPermission>
}
}>
for (let i = messages.length - 1; i >= 0; i--) {
const info = messages[i].info
if (info?.agent || info?.model) {
if (info?.agent || info?.model || (info?.modelID && info?.providerID)) {
resolvedInfo = {
agent: info.agent,
model: info.model,
model: info.model ?? (info.providerID && info.modelID ? { providerID: info.providerID, modelID: info.modelID } : undefined),
tools: info.tools,
}
break