fix(thinking-block-validator): handle text content parts in message validation

Previously, the validator only checked for tool_use parts, causing 'Expected thinking but found text' errors when messages had text content. Renamed hasToolParts to hasContentParts to include both tool_use and text types.

Also added CommentCheckerConfigSchema support for custom prompt configuration.

🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-28 14:55:27 +09:00
parent 19f504fcfa
commit 092718f82d
3 changed files with 20 additions and 10 deletions

View File

@@ -51,14 +51,15 @@ function isExtendedThinkingModel(modelID: string): boolean {
}
/**
* Check if a message has tool parts (tool_use)
* Check if a message has any content parts (tool_use, text, or other non-thinking content)
*/
function hasToolParts(parts: Part[]): boolean {
function hasContentParts(parts: Part[]): boolean {
if (!parts || parts.length === 0) return false
return parts.some((part: Part) => {
const type = part.type as string
return type === "tool" || type === "tool_use"
// Include tool parts and text parts (anything that's not thinking/reasoning)
return type === "tool" || type === "tool_use" || type === "text"
})
}
@@ -154,8 +155,8 @@ export function createThinkingBlockValidatorHook(): MessagesTransformHook {
// Only check assistant messages
if (msg.info.role !== "assistant") continue
// Check if message has tool parts but doesn't start with thinking
if (hasToolParts(msg.parts) && !startsWithThinkingBlock(msg.parts)) {
// Check if message has content parts but doesn't start with thinking
if (hasContentParts(msg.parts) && !startsWithThinkingBlock(msg.parts)) {
// Find thinking content from previous turns
const previousThinking = findPreviousThinkingContent(messages, i)