fix(look-at): add path alias and validation for LLM compatibility

LLMs often call look_at with 'path' instead of 'file_path' parameter,
causing TypeError and infinite retry loops.

- Add normalizeArgs() to accept both 'path' and 'file_path'
- Add validateArgs() with clear error messages showing correct usage
- Add tests for normalization and validation

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
justsisyphus
2026-01-15 14:49:56 +09:00
parent 4c22d6de76
commit 89fa9ff167
2 changed files with 102 additions and 1 deletions
+29 -1
View File
@@ -5,6 +5,27 @@ import { LOOK_AT_DESCRIPTION, MULTIMODAL_LOOKER_AGENT } from "./constants"
import type { LookAtArgs } from "./types"
import { log } from "../../shared/logger"
interface LookAtArgsWithAlias extends LookAtArgs {
path?: string
}
export function normalizeArgs(args: LookAtArgsWithAlias): LookAtArgs {
return {
file_path: args.file_path ?? args.path ?? "",
goal: args.goal ?? "",
}
}
export function validateArgs(args: LookAtArgs): string | null {
if (!args.file_path) {
return `Error: Missing required parameter 'file_path'. Usage: look_at(file_path="/path/to/file", goal="what to extract")`
}
if (!args.goal) {
return `Error: Missing required parameter 'goal'. Usage: look_at(file_path="/path/to/file", goal="what to extract")`
}
return null
}
function inferMimeType(filePath: string): string {
const ext = extname(filePath).toLowerCase()
const mimeTypes: Record<string, string> = {
@@ -50,7 +71,14 @@ export function createLookAt(ctx: PluginInput): ToolDefinition {
file_path: tool.schema.string().describe("Absolute path to the file to analyze"),
goal: tool.schema.string().describe("What specific information to extract from the file"),
},
async execute(args: LookAtArgs, toolContext) {
async execute(rawArgs: LookAtArgs, toolContext) {
const args = normalizeArgs(rawArgs as LookAtArgsWithAlias)
const validationError = validateArgs(args)
if (validationError) {
log(`[look_at] Validation failed: ${validationError}`)
return validationError
}
log(`[look_at] Analyzing file: ${args.file_path}, goal: ${args.goal}`)
const mimeType = inferMimeType(args.file_path)