fix(agents): tolerate uncloneable adjusted tool params · openclaw/openclaw@d0ae6ea
vincentkoc
·
2026-06-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -913,6 +913,8 @@ describe("before_tool_call loop detection behavior", () => {
|
913 | 913 | type: "tool.execution.started", |
914 | 914 | }); |
915 | 915 | expect(started.paramsSummary).toEqual({ kind: "object" }); |
| 916 | +expect(execute).toHaveBeenCalledTimes(1); |
| 917 | +expect(execute.mock.calls[0]?.[1]).toBe(params); |
916 | 918 | }); |
917 | 919 | }); |
918 | 920 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -352,8 +352,12 @@ export function recordAdjustedParamsForToolCall(
|
352 | 352 | if (!toolCallId) { |
353 | 353 | return; |
354 | 354 | } |
| 355 | +const cloneResult = cloneParamsForAdjustedReplay(params); |
| 356 | +if (!cloneResult.ok) { |
| 357 | +return; |
| 358 | +} |
355 | 359 | const adjustedParamsKey = buildAdjustedParamsKey({ runId, toolCallId }); |
356 | | -adjustedParamsByToolCallId.set(adjustedParamsKey, structuredClone(params)); |
| 360 | +adjustedParamsByToolCallId.set(adjustedParamsKey, cloneResult.value); |
357 | 361 | if (adjustedParamsByToolCallId.size > MAX_TRACKED_ADJUSTED_PARAMS) { |
358 | 362 | const oldest = adjustedParamsByToolCallId.keys().next().value; |
359 | 363 | if (oldest) { |
@@ -362,6 +366,16 @@ export function recordAdjustedParamsForToolCall(
|
362 | 366 | } |
363 | 367 | } |
364 | 368 | |
| 369 | +function cloneParamsForAdjustedReplay( |
| 370 | +params: unknown, |
| 371 | +): { ok: true; value: unknown } | { ok: false } { |
| 372 | +try { |
| 373 | +return { ok: true, value: structuredClone(params) }; |
| 374 | +} catch { |
| 375 | +return { ok: false }; |
| 376 | +} |
| 377 | +} |
| 378 | + |
365 | 379 | /** Record that one concrete core-owned tool call may use structured replay classification. */ |
366 | 380 | export function recordStructuredReplayTrustForToolCall( |
367 | 381 | toolCallId: string | undefined, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。