fix(structured): harden structured output for local servers and thinking models

- Local servers (LM Studio, vLLM) reject the object-form tool_choice langchain
  sends for function calling. The generic openai_compatible provider now binds
  the schema as a tool without forcing tool_choice.
- A structured call can return no parsed result (a thinking model answering in
  plain text); fall back to free text with a clear reason instead of an opaque
  render error.
This commit is contained in:
Yijia-Xiao committed 2026-06-21 22:09:43 +00:00
1 parent 9ad98c55c5
commit 517eeaf4b9
4 files changed
+70 -2

No files matched your search

+5
View File
@@ -63,6 +63,11 @@ def invoke_structured_or_freetext(
if structured_llm is not None:
try:
result = structured_llm.invoke(prompt)
if result is None:
# A thinking model can answer in plain text instead of calling
# the tool, leaving the parser with nothing to return. Treat it
# as a structured miss and fall back, with a clear reason.
raise ValueError("structured output returned no parsed result")
return render(result)
except Exception as exc:
logger.warning(