Skip to content

Insights: read AIMessage.text as the property it is - #54

Merged
eddietejeda merged 1 commit into
mainfrom
unpack-text
Oct 17, 2026
Merged

eddietejeda merged 1 commit into
mainfrom
unpack-text

Conversation

@eddietejeda

Copy link
Copy Markdown
Contributor

The transcript unpacker called .text() through a callable() fallback meant for older LangChain. The property now returns a str subclass that still answers a call, with a deprecation warning on every run. Read the property and fall back to content. Verified with warnings turned into errors.

The unpacker's callable() fallback for older LangChain walked into the
str subclass the property now returns, which answers a call with a
deprecation warning on every run. Read the property; fall back to content.
@eddietejeda
eddietejeda requested a review from a team as a code owner October 17, 2026 15:11
@eddietejeda
eddietejeda requested review from zfarrell and removed request for a team October 17, 2026 15:11
Comment thread server/insights.py
# 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.

@eddietejeda
eddietejeda merged commit 45ff520 into main Oct 17, 2026
2 checks passed
@eddietejeda
eddietejeda deleted the unpack-text branch October 17, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant