Fix incorrect exception reference for json.dumps() (#24329)

Co-authored-by: Yongtao Huang <99629139+hyongtao-db@users.noreply.github.com>
This commit is contained in:
Yongtao Huang
2025-08-24 00:31:04 +08:00
committed by GitHub
parent 8a348bea21
commit 1d09708eb7
2 changed files with 5 additions and 5 deletions

View File

@@ -197,7 +197,7 @@ class CotAgentRunner(BaseAgentRunner, ABC):
final_answer = scratchpad.action.action_input final_answer = scratchpad.action.action_input
else: else:
final_answer = f"{scratchpad.action.action_input}" final_answer = f"{scratchpad.action.action_input}"
except json.JSONDecodeError: except TypeError:
final_answer = f"{scratchpad.action.action_input}" final_answer = f"{scratchpad.action.action_input}"
else: else:
function_call_state = True function_call_state = True

View File

@@ -126,8 +126,8 @@ class FunctionCallAgentRunner(BaseAgentRunner):
tool_call_inputs = json.dumps( tool_call_inputs = json.dumps(
{tool_call[1]: tool_call[2] for tool_call in tool_calls}, ensure_ascii=False {tool_call[1]: tool_call[2] for tool_call in tool_calls}, ensure_ascii=False
) )
except json.JSONDecodeError: except TypeError:
# ensure ascii to avoid encoding error # fallback: force ASCII to handle non-serializable objects
tool_call_inputs = json.dumps({tool_call[1]: tool_call[2] for tool_call in tool_calls}) tool_call_inputs = json.dumps({tool_call[1]: tool_call[2] for tool_call in tool_calls})
if chunk.delta.message and chunk.delta.message.content: if chunk.delta.message and chunk.delta.message.content:
@@ -153,8 +153,8 @@ class FunctionCallAgentRunner(BaseAgentRunner):
tool_call_inputs = json.dumps( tool_call_inputs = json.dumps(
{tool_call[1]: tool_call[2] for tool_call in tool_calls}, ensure_ascii=False {tool_call[1]: tool_call[2] for tool_call in tool_calls}, ensure_ascii=False
) )
except json.JSONDecodeError: except TypeError:
# ensure ascii to avoid encoding error # fallback: force ASCII to handle non-serializable objects
tool_call_inputs = json.dumps({tool_call[1]: tool_call[2] for tool_call in tool_calls}) tool_call_inputs = json.dumps({tool_call[1]: tool_call[2] for tool_call in tool_calls})
if result.usage: if result.usage: