| parse_tool_arguments | R Documentation |
Robustly parse tool call arguments from various formats that different LLMs may return. Handles edge cases like incomplete JSON, malformed strings, and various empty representations.
Implements multi-layer parsing strategy (inspired by Opencode):
Direct pass-through for already-parsed lists
Empty value detection and normalization
JSON repair for common LLM mistakes
Fallback parsing with JavaScript object literal support
Graceful degradation to empty args on failure
parse_tool_arguments(args, tool_name = "unknown")
args |
The arguments to parse (can be string, list, or NULL). |
tool_name |
Optional tool name for better error messages. |
A named list of parsed arguments (empty named list if no arguments).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.