mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-31 13:03:49 +08:00
Fix: agent toolcall null response & schema validation & DeepSeek think history (#14425)
### What problem does this PR solve? agent toolcall null response & schema validation & DeepSeek think history ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -145,7 +145,8 @@ class Agent(LLM, ToolBase):
|
||||
self._param.function_name = self._id.split("-->")[-1]
|
||||
m = super().get_meta()
|
||||
if hasattr(self._param, "user_prompt") and self._param.user_prompt:
|
||||
m["function"]["parameters"]["properties"]["user_prompt"] = self._param.user_prompt
|
||||
# Keep the JSON schema valid; user_prompt is a string field, not a schema node.
|
||||
m["function"]["parameters"]["properties"]["user_prompt"]["default"] = self._param.user_prompt
|
||||
return m
|
||||
|
||||
def get_input_form(self) -> dict[str, dict]:
|
||||
|
||||
@@ -67,6 +67,19 @@ class LLMToolPluginCallSession(ToolCallSession):
|
||||
else:
|
||||
resp = await thread_pool_exec(tool_obj.invoke, **arguments)
|
||||
|
||||
if resp is None and hasattr(tool_obj, "output") and callable(tool_obj.output):
|
||||
try:
|
||||
fallback_output = tool_obj.output()
|
||||
if isinstance(fallback_output, dict) and fallback_output.get("content") not in (None, ""):
|
||||
resp = fallback_output["content"]
|
||||
elif fallback_output not in (None, ""):
|
||||
resp = fallback_output
|
||||
else:
|
||||
resp = fallback_output
|
||||
logging.warning(f"[ToolCall] resp is None, fallback to output name={name} output_keys={list(fallback_output.keys()) if isinstance(fallback_output, dict) else type(fallback_output).__name__}")
|
||||
except Exception as e:
|
||||
logging.warning(f"[ToolCall] resp is None and output fallback failed name={name} err={e}")
|
||||
|
||||
elapsed = timer() - st
|
||||
logging.info(f"[ToolCall] done name={name} elapsed={elapsed:.2f}s result={str(resp)[:200]}")
|
||||
self.callback(name, arguments, resp, elapsed_time=elapsed)
|
||||
|
||||
Reference in New Issue
Block a user