Skip to content

feat(ai-components): parse agent reply steps from message attachments - #3920

Open
isekovanic wants to merge 1 commit into
developfrom
feat/ai-message-parts
Open

isekovanic wants to merge 1 commit into
developfrom
feat/ai-message-parts

Conversation

@isekovanic

Copy link
Copy Markdown
Contributor

Ticket: https://linear.app/stream/issue/RN-485

🎯 Goal

First of a stack of PRs that bring agent conversations to ai-components: reasoning, tool calls, approvals, sign-in and the conversation view, as in StreamChatAI, ai-compose and stream-chat-react#3376.

This one adds only the data model. No UI.

πŸ›  Implementation details

An agent writes each step of its reply as an attachment (ai_reasoning, ai_tool_call). parseMessageParts(message.attachments) turns those into typed parts and skips everything else, such as images and files.

Ported from React #3376 with the same names and behaviour:

  • Lenient decoding: missing fields get defaults and wrong types are ignored.
  • Unknown kinds and newer versions (v > 1) keep their payload but have no typed view.
  • approval and authorization are parsed on tool calls.
  • Helpers for the views to come: isAwaitingApproval, isAwaitingAuthorization, isAwaitingClient, isDeclined, isToolCallFinished, isAuthorizationExpired, isSupportedPart.

One deviation from React: the sign-in URL check doesn't use URL. On RN < 0.80 its protocol and host getters throw "not implemented", which would silently drop every sign-in on 0.76–0.79. It's a regex instead.

Exported from the ai-components entry only. The main entry is unaffected.

🎨 UI Changes

None.

πŸ§ͺ Testing

  • React's messageParts suite ported to Jest.
  • A fixture taken from a real reply written by a local Vision-Agents router (reasoning β†’ search tool call β†’ reasoning).
  • A regression test that fakes the pre-0.80 URL and checks a sign-in still parses.
  • yarn lint, yarn test:typecheck, yarn build and yarn test:unit pass.

β˜‘οΈ Checklist

  • I have signed the Stream CLA (required)
  • PR targets the develop branch
  • Documentation is updated
  • New code is tested in main example apps, including all possible scenarios
    • SampleApp iOS and Android
    • Expo iOS and Android

@Stream-SDK-Bot

Copy link
Copy Markdown
Contributor

SDK Size

title develop branch diff status
js_bundle_size 2037 KB 2037 KB 0 B 🟒
ai_components_size 163 KB 167 KB +4751 B 🟑

This branch has not been deployed

No deployments
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.

2 participants