generate_retry_message
Generate a canonical retry feedback message for an LLM from a tool name, validation error, and attempted arguments, using the same formatting as runtime callers.
Instructions
Given a tool name, validation error, and attempted args, build the canonical LLM-facing retry feedback message. Uses agentvet's ToolArgError.toLLMFeedback() formatting so the wording matches what runtime callers see.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tool_name | Yes | ||
| validation_error | Yes | ||
| attempted_args | Yes |
Implementation Reference
- src/server.ts:218-229 (handler)The handler function that executes the 'generate_retry_message' tool logic. It creates a ToolArgError with the tool name, validation error, and attempted args, then calls toLLMFeedback() to build the LLM-facing retry message.
function generateRetryMessageTool(input: { tool_name: string; validation_error: string; attempted_args: any }) { const err = new ToolArgError(input.tool_name, input.validation_error, input.attempted_args); const feedback = err.toLLMFeedback?.() ?? err.message; return { content: [ { type: 'text', text: JSON.stringify({ retry_message: feedback }, null, 2), }, ], }; } - src/server.ts:95-108 (schema)The input schema definition for 'generate_retry_message' tool. It defines three required properties: tool_name (string), validation_error (string), and attempted_args (object).
{ name: 'generate_retry_message', description: 'Given a tool name, validation error, and attempted args, build the canonical LLM-facing retry feedback message. Uses agentvet\'s ToolArgError.toLLMFeedback() formatting so the wording matches what runtime callers see.', inputSchema: { type: 'object', properties: { tool_name: { type: 'string' }, validation_error: { type: 'string' }, attempted_args: { type: 'object' }, }, required: ['tool_name', 'validation_error', 'attempted_args'], }, }, - src/server.ts:53-109 (registration)The tool is registered in the TOOLS array (line 95-108) which is served via ListToolsRequestSchema handler. The tool dispatch in the CallToolRequestSchema handler (line 125-126) routes the tool name to the handler function.
const TOOLS = [ { name: 'validate_tool_args', description: 'Validate a tool-call args object against a small shape spec. Returns { valid, error?, retry_hint? } where retry_hint is a ready-to-send LLM feedback message describing exactly what was wrong.', inputSchema: { type: 'object', properties: { tool_name: { type: 'string', description: 'Name of the tool being called (surfaces in retry_hint).', }, args: { type: 'object', description: 'The args object the LLM wants to pass.', }, shape: SHAPE_SCHEMA, }, required: ['tool_name', 'args', 'shape'], }, }, { name: 'lint_tool_definition', description: 'Sanity-check a tool definition for common mistakes that hurt LLM tool-use accuracy: missing description, vague description, no required fields, schema fields without descriptions, non-snake_case names.', inputSchema: { type: 'object', properties: { tool: { type: 'object', description: 'A tool definition: { name, description, inputSchema }.', properties: { name: { type: 'string' }, description: { type: 'string' }, inputSchema: { type: 'object' }, }, required: ['name'], }, }, required: ['tool'], }, }, { name: 'generate_retry_message', description: 'Given a tool name, validation error, and attempted args, build the canonical LLM-facing retry feedback message. Uses agentvet\'s ToolArgError.toLLMFeedback() formatting so the wording matches what runtime callers see.', inputSchema: { type: 'object', properties: { tool_name: { type: 'string' }, validation_error: { type: 'string' }, attempted_args: { type: 'object' }, }, required: ['tool_name', 'validation_error', 'attempted_args'], }, }, ] as const; - src/server.ts:125-126 (registration)Dispatch case in CallToolRequestSchema handler that routes 'generate_retry_message' to the generateRetryMessageTool function.
case 'generate_retry_message': return generateRetryMessageTool(args as { tool_name: string; validation_error: string; attempted_args: any });