mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
refactor(agents): reuse thinking block predicate (#130001)
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
committed by
GitHub
parent
68f17b01cc
commit
7da8c19fd0
@@ -1839,7 +1839,7 @@ src/agents/embedded-agent-runner/run/attempt-stop-reason-recovery.ts 3
|
||||
src/agents/embedded-agent-runner/run/attempt-stream-prepare.ts 3
|
||||
src/agents/embedded-agent-runner/run/attempt-stream.ts 9
|
||||
src/agents/embedded-agent-runner/run/attempt-subscription-cleanup.ts 2
|
||||
src/agents/embedded-agent-runner/run/attempt-tool-call-replay-sanitization.ts 18
|
||||
src/agents/embedded-agent-runner/run/attempt-tool-call-replay-sanitization.ts 17
|
||||
src/agents/embedded-agent-runner/run/attempt-tool-call-stream-normalization.ts 7
|
||||
src/agents/embedded-agent-runner/run/attempt-tool-call-text-promotion.ts 3
|
||||
src/agents/embedded-agent-runner/run/attempt-tool-prepare.ts 3
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
sanitizeToolUseResultPairing,
|
||||
sanitizeToolUseResultPairingForModel,
|
||||
} from "../../session-transcript-repair.js";
|
||||
import { isThinkingLikeBlock } from "../../thinking-block.js";
|
||||
import {
|
||||
extractToolCallsFromAssistant,
|
||||
extractToolResultIds,
|
||||
@@ -47,14 +48,6 @@ type AnthropicToolResultContentBlock = {
|
||||
tool_call_id?: unknown;
|
||||
};
|
||||
|
||||
function isThinkingLikeReplayBlock(block: unknown): boolean {
|
||||
if (!block || typeof block !== "object") {
|
||||
return false;
|
||||
}
|
||||
const type = (block as { type?: unknown }).type;
|
||||
return type === "thinking" || type === "redacted_thinking";
|
||||
}
|
||||
|
||||
function isReplaySafeThinkingTurn(content: unknown[], allowedToolNames?: Set<string>): boolean {
|
||||
const seenToolCallIds = new Set<string>();
|
||||
for (const block of content) {
|
||||
@@ -164,7 +157,7 @@ function sanitizeReplayToolCallInputs(
|
||||
}
|
||||
if (
|
||||
allowProviderOwnedThinkingReplay &&
|
||||
message.content.some((block) => isThinkingLikeReplayBlock(block)) &&
|
||||
message.content.some((block) => isThinkingLikeBlock(block)) &&
|
||||
message.content.some((block) => isReplayToolCallBlock(block))
|
||||
) {
|
||||
const replaySafeToolCalls = extractToolCallsFromAssistant(message);
|
||||
@@ -274,7 +267,7 @@ function isSignedThinkingReplayAssistantSpan(message: AgentMessage | undefined):
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
content.some((block) => isThinkingLikeReplayBlock(block)) &&
|
||||
content.some((block) => isThinkingLikeBlock(block)) &&
|
||||
content.some((block) => isReplayToolCallBlock(block))
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user