mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:01:24 +00:00
Agents: validate persisted tool-call names
This commit is contained in:
@@ -96,6 +96,11 @@ export function installSessionToolResultGuard(
|
||||
* Defaults to true.
|
||||
*/
|
||||
allowSyntheticToolResults?: boolean;
|
||||
/**
|
||||
* Optional set/list of tool names accepted for assistant toolCall/toolUse blocks.
|
||||
* When set, tool calls with unknown names are dropped before persistence.
|
||||
*/
|
||||
allowedToolNames?: Iterable<string>;
|
||||
/**
|
||||
* Synchronous hook invoked before any message is written to the session JSONL.
|
||||
* If the hook returns { block: true }, the message is silently dropped.
|
||||
@@ -171,7 +176,9 @@ export function installSessionToolResultGuard(
|
||||
let nextMessage = message;
|
||||
const role = (message as { role?: unknown }).role;
|
||||
if (role === "assistant") {
|
||||
const sanitized = sanitizeToolCallInputs([message]);
|
||||
const sanitized = sanitizeToolCallInputs([message], {
|
||||
allowedToolNames: opts?.allowedToolNames,
|
||||
});
|
||||
if (sanitized.length === 0) {
|
||||
if (allowSyntheticToolResults && pending.size > 0) {
|
||||
flushPendingToolResults();
|
||||
|
||||
Reference in New Issue
Block a user