Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/repository/error-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,25 @@ const DEFAULT_ERROR_RULES = [
},
},
},
// Issue #550: tool_use block missing corresponding tool_result in next message (non-retryable)
{
pattern:
"tool_use.*ids were found without.*tool_result.*immediately after|tool_use.*block must have.*corresponding.*tool_result.*block in the next message",
Comment on lines +529 to +530
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The regex pattern can be slightly refactored to improve readability and performance by factoring out the common tool_use.* prefix. This avoids repeating the prefix and makes the regex engine's job slightly easier by using a non-capturing group for the alternatives.

Suggested change
pattern:
"tool_use.*ids were found without.*tool_result.*immediately after|tool_use.*block must have.*corresponding.*tool_result.*block in the next message",
pattern:
"tool_use.*(?:ids were found without.*tool_result.*immediately after|block must have.*corresponding.*tool_result.*block in the next message)",

category: "validation_error",
description: "tool_use block missing corresponding tool_result in next message (client error)",
matchType: "regex" as const,
isDefault: true,
isEnabled: true,
priority: 88,
overrideResponse: {
type: "error",
error: {
type: "validation_error",
message:
"tool_use 块缺少对应的 tool_result,请确保每个 tool_use 在下一条消息中有对应的 tool_result 块",
},
},
},
// Model-related errors (non-retryable)
{
pattern: '"actualModel" is null|actualModel.*null',
Expand Down
Loading