Skip to content

Return validation error details to LLM on function call argument failures #5164

@Olivier-tl

Description

@Olivier-tl

Feature Type

Would make my life easier

Feature Description

When the LLM makes a function call with invalid arguments (e.g., missing required fields, wrong types, invalid enum values), Livekit attempts to parse the arguments in a pydantic model (see here) which raises a ValidationError. Livekit does catch the exception and generate a tool output (see here). However it hardcodes "An internal error occurred" in the output (see here). This gives the LLM no feedback about what was wrong with its arguments, so it has no signal to self-correct.

Potential fix: catching the pydantic ValidationError and raising a ToolError would fix it, as tool errors are surfaced to the LLM (see here).

Workarounds / Alternatives

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions