tool_response was being added to the conversation without tool_call, causing malformed chat sequences.
Variable
- {%- for tool_call in message.tool_call -%}
+ {%- for tool_call in message.tool_calls -%}
- {{- '<parameter=' + args.name + '>\n' -}}
+ {{- '<parameter=' + args_name + '>\n' -}}
After applying the above fixes, the following error surfaced:
packages\jinja2\filters.py", line 249, in do_items
raise TypeError("Can only get item pairs from a mapping.")
So, passing the tool_call arguments as a dict worked for me.
After these changes, tool_call is now added before tool_response