MCPcopy Index your code
hub / github.com/FIND-Lab/AgentWard / formatToolCallWarning

Function formatToolCallWarning

core/warnings.ts:65–83  ·  view source on GitHub ↗
(error: Warning | Warning[], level: number)

Source from the content-addressed store, hash-verified

63}
64
65export function formatToolCallWarning(error: Warning | Warning[], level: number): string {
66 // Backward compatible:
67 // - legacy levels: 1(one-time) / 2(temp) / 3(perm)
68 // - extended levels: 10(one-time) / 15(requireApproval) / 20(temp) / 30(perm)
69 const normalizedLevel =
70 level === 3 ? 30 : level === 2 ? 20 : level === 1 ? 10 : level;
71
72 if (normalizedLevel >= 30) { // permanent (before user's next request)
73 return `${formatBasic(error)}\nYour permission for any tool calls has been revoked. Stop the task immediately and tell the user to request again to recover the permission.`;
74 } else if (normalizedLevel >= 20) { // temporary (until next assistant response)
75 return `${formatBasic(error)}\nYour permission for tool calls has been temporarily suspended. The next assistant response will restore the permission.`;
76 } else if (normalizedLevel >= 15) { // require approval
77 return `${formatBasic(error)}\nThis action requires your confirmation before proceeding.`;
78 } else if (normalizedLevel >= 10) { // one-time (only for this tool call)
79 return `${formatBasic(error)}\nYour request for this tool call is rejected.`;
80 }
81
82 return formatBasic(error);
83}
84
85export function formatUserPrependWarning(error: Warning | Warning[], blockToolCall: boolean): string {
86 if (blockToolCall)

Callers 1

registerFunction · 0.90

Calls 1

formatBasicFunction · 0.85

Tested by

no test coverage detected