github →

New request

#20558: In AI chat, Unsupported part type: dynamic-tool

We'll provision a sandbox, run an agent against the issue, and open a draft PR. You can pull the branch and iterate from there.

Issue
sonarly:high

Bug Description Current Behavior: The AI Agent stream fails with a Unsupported part type: dynamic-tool error. This occurs during the StreamAgentChatJob execution, specifically when the system attempts to map message parts to the database after the stream finishes. Even if the user intends to avoid tool usage, the process crashes.

Logs:

Plaintext 2026/05/14 10:00:04,stderr, Error: Unsupported part type: dynamic-tool 2026/05/14 10:00:04,stderr, at /app/packages/twenty-server/dist/engine/metadata-modules/ai/ai-agent-execution/utils/mapUIMessagePartsToDBParts.js:94:23 2026/05/14 10:00:04,stderr, at Array.map (<anonymous>) 2026/05/14 10:00:04,stderr, at mapUIMessagePartsToDBParts (/app/packages/twenty-server/dist/engine/metadata-modules/ai/ai-agent-execution/utils/mapUIMessagePartsToDBParts.js:16:27) 2026/05/14 10:00:04,stderr, at AgentChatService.addMessage (/app/packages/twenty-server/dist/engine/metadata-modules/ai/ai-chat/services/agent-chat.service.js:110:88) 2026/05/14 10:00:04,stderr, at async StreamAgentChatJob.handleStreamFinish (/app/packages/twenty-server/dist/engine/metadata-modules/ai/ai-chat/jobs/stream-agent-chat.job.js:321:9) 2026/05/14 10:00:04,stderr, [StreamAgentChatJob] Stream ZoFyDmKLIKNLgRRY failed: Unsupported part type: dynamic-tool Expected behavior The mapUIMessagePartsToDBParts function should be able to handle the dynamic-tool part type without throwing an error, allowing the chat message to be saved and the stream to complete successfully.

Technical inputs Environment: Twenty v2.2.0 (Docker deployment)

Affected Component: twenty-server (AI Engine)

Specific File: packages/twenty-server/dist/engine/metadata-modules/ai/ai-agent-execution/utils/mapUIMessagePartsToDBParts.js

Context: The error is triggered during the handleStreamFinish phase of StreamAgentChatJob, indicating that the AI SDK is returning a message part of type dynamic-tool which is not yet supported by the server's database mapping logic.

Assessmentadvisory
bug easy95% confidence

The mapUIMessagePartsToDBParts utility lacks a handler for dynamic-tool message parts, causing the AI stream to crash.

Likely files
  • packages/twenty-server/src/engine/metadata-modules/ai/ai-agent-execution/utils/mapUIMessagePartsToDBParts.ts
  • packages/twenty-shared/src/types/ai-message.types.ts
Create the request

This opens a fresh agent run and a draft PR for issue #20558.

Cancel