@threadplane/chatFunctionv0.3.4

messageContent

Extracts a human-readable string from a message's content.

Message content is either a plain string or an array of typed blocks. Reasoning-capable models (OpenAI gpt-5/o-series, Anthropic) emit complex arrays: {type:'text',text}, {type:'reasoning',...}, tool-use blocks, etc. Only the visible text portions are rendered and anything else is skipped. Stringifying the whole array would dump raw JSON like [{"type":"text",...}] into the chat bubble.

The parameter is structural on purpose. This function reads nothing but .content, and callers hold either the runtime-neutral Message from agent.messages() or a LangChain BaseMessage depending on where the message came from. Both satisfy { content: unknown }, so neither has to cast.

import { messageContent } from '@threadplane/chat';

Declaration · overload 1

export declare function messageContent(message: {
    content: unknown;
}): string;

Parameters

message · required
{ content: unknown; }

Any object carrying a content field.

Returns

string

The concatenated visible text, or '' when there is none.