[BUG] Parsing of tool calls does not support arrays in the "arguments" #3388
Labels
bug
Something isn't working
no-recent-activity
There has been no recent activity on this issue/pull request
Describe the bug
The current regex pattern used for parsing tool calls results in an incomplete parsing when nested objects are used within the tool call definition. This severely limits the usefulness of tool calls within Prompty since any arguments with nested objects break parsing.
Relevant code:
promptflow/src/promptflow-core/promptflow/core/_prompty_utils.py
Lines 656 to 657 in 96dbf33
How To Reproduce the bug
Successful parsing
Match group from
try_parse_tool_calls
'[{\n "id": "call_dks134",\n "type": "function",\n "function": { \n "name":"update",\n "arguments": \'{"items": {"name": "test_name"}}\'\n }\n}]'
Match group from
try_parse_tool_calls
'[{\n "id": "call_dks134",\n "type": "function",\n "function": { \n "name":"update",\n "arguments": \'{"items": [{"name": "test_name"}]'
The bugged match group ends at the closing of the
"items"
property rather than the full tool call definition.Expected behavior
Tool call definitions with arrays in arguments are correctly parsed.
Running Information(please complete the following information):
pf -v
: 1.11.0python --version
: python==3.12.3The text was updated successfully, but these errors were encountered: