Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions server/insights.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,12 @@ def _unpack(messages):
"rows": None, "error": None}
steps.append(step)
by_id[call.get("id")] = step
text = getattr(m, "text", "")
if callable(text):
text = text()
# AIMessage.text is a property; it returns a str subclass that
# still answers a call for old code, with a deprecation warning,
# so a callable() check here would walk straight into that
text = getattr(m, "text", None)
if not isinstance(text, str):
text = m.content if isinstance(m.content, str) else ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Call text() when m.text is callable but not a str (not blocking).

The fallback runs only on an older langchain-core, where text is a plain method. On that version, Anthropic replies carry content as a list of blocks. The old text() call extracted the text from those blocks. This fallback returns "" for a list, so the answer is lost.

Suggested change
text = m.content if isinstance(m.content, str) else ""
text = text() if callable(text) else (m.content if isinstance(m.content, str) else "")

The isinstance(text, str) check already catches the new str subclass first, so the deprecation warning cannot fire here. The Dockerfile does not pin langchain, so this path is rare in production.

if text and text.strip():
answer = text.strip()
elif mtype == "tool":
Expand Down
Loading