Commit cae0ebd
Javier Lázaro
fix(openai_compatible): handle None tool.description in function_call format and token counting
PromptMessageTool.description is typed as str but can be None in
practice when using custom OpenAPI-based tool providers. This causes
two crashes:
1. Line 601: Passing None as 'description' in the function_call
payload sent to the LLM API, which may reject it.
2. Line 1130: _get_num_tokens_by_gpt2(tool.description) crashes with
TypeError when description is None, since gpt2 tokenizer expects
a string.
Both are fixed with 'tool.description or ""' — a minimal, safe
fallback consistent with the pattern already used in the azure_openai
plugin (line 472).
Reproduction: Create an OpenAPI tool provider whose endpoints have a
summary but no description, then invoke an agent using those tools.
Related: langgenius/dify-official-plugins#3095 (same bug in the
azure_openai plugin's own _num_tokens_for_tools)1 parent 418d1fd commit cae0ebd
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
601 | | - | |
| 601 | + | |
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
| |||
1127 | 1127 | | |
1128 | 1128 | | |
1129 | 1129 | | |
1130 | | - | |
| 1130 | + | |
1131 | 1131 | | |
1132 | 1132 | | |
1133 | 1133 | | |
| |||
0 commit comments