-
Notifications
You must be signed in to change notification settings - Fork 878
Open
Description
ag-ui-adk==0.3.2 is calling frontend tool twice. As we can see on the registered ADK session, where render_ItemsList is called twice.
In my tests, this happens when the full history of messages is passed on the same run: which is a default behavior of HttpAgent from @ag-ui/client present on my implementation.
If each message is passed in different runs, it works normally (I tested through Insomnia).
Here is the scenario where the bug appears:
POST /ag-ui
{
"threadId": "ad474246-bcc9-41a7-af4a-78c63f1e959f",
"runId": "5ad5dcfd-b448-4f90-825b-7a9f2c860b93",
"tools": [
{
"name": "render_ItemsList",
"description": "Renders a visual, interactive list of items in a horizontal scrollable carousel format. Use this tool to display any collection of named items such as products, locations, categories, options, or any other entities that the user can select from. This tool creates a better user experience than displaying items as plain text.",
"parameters": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "string",
"description": "The display name of each item in the list. Each string should be a clear, user-friendly name that represents a selectable option."
},
"description": "An array of item names to be displayed in the visual list. Must contain at least 2 items. Each item will be rendered as a clickable element that users can interact with to make selections.",
"minItems": 2
}
},
"required": [
"items"
]
}
}
],
"context": [],
"forwardedProps": {},
"state": {
"user_id": "user-123",
"user_name": "Joe Doe"
},
"messages": [
{
"id": "system-1762374329547",
"role": "system",
"content": "\n CRITICAL RENDERING RULES - MUST FOLLOW:\n\n 1. NEVER list items as plain text. You MUST use the render_ItemsList tool for ANY list of items.\n \n 2. When you have multiple items to show (products, articles, locations, etc.), follow this EXACT sequence:\n - First: Send a brief text message explaining what you're about to show\n - Second: IMMEDIATELY call render_ItemsList with the items array\n - Do NOT include the items in your text response\n \n 3. FORBIDDEN: Writing items like \"1. Item A, 2. Item B\", \"- Item A - Item B\" or \"Item A, Item B, Item C\" in text\n \n 4. REQUIRED: Use render_ItemsList for ANY collection of 2 or more named items\n \n 5. CORRECT Examples:\n \n Example A - Fruits:\n User: \"Show me some fruits\"\n Assistant: \"Here are some popular fruits:\"\n Assistant: [CALLS render_ItemsList with [\"Apple\", \"Banana\", \"Orange\"]]\n \n Example B - Colors:\n User: \"What are the available colors?\"\n Assistant: \"Here are the current available colors:\"\n Assistant: [CALLS render_ItemsList with [\"Red\", \"Green\", \"Blue\", \"Yellow\"]]\n\n Example C - Products:\n User: \"Show me smartphones\"\n Assistant: \"Here are the available smartphones:\"\n Assistant: [CALLS render_ItemsList with [\"iPhone 15\", \"Samsung Galaxy S24\", \"Google Pixel 8\"]]\n \n 6. INCORRECT Examples (DO NOT DO THIS):\n \"Available colors: 1. Red, 2. Green, 3. Blue\"\n \"The colors are: Red, Green, and Blue\"\n \"• Red • Green • Blue\"\n\n 7. After user selects an item from the visual list, provide detailed information about that specific item.\n \n 8. COMMON USE CASES that REQUIRE render_ItemsList:\n - \"What colors are available?\" → Show colors names\n - \"List the products\" → Show product names \n - \"Show me options\" → Show option names\n - \"What can I choose from?\" → Show available choices\n - Any question asking for multiple named items\n \n Remember: Visual presentation using tools is MANDATORY, not optional. Text lists are strictly prohibited.\n "
},
{
"id": "user-1762374339547",
"role": "user",
"content": "i would like to see the available items\n"
},
{
"id": "adk-0b43dc45-4734-4898-b321-19bd1b063e53",
"role": "assistant",
"toolCalls": [
{
"id": "adk-0b43dc45-4734-4898-b321-19bd1b063e53",
"type": "function",
"function": {
"name": "get_items",
"arguments": ""
}
}
]
},
{
"id": "aef5e421-2d45-4bce-8791-5f8bf82bc1b6",
"toolCallId": "adk-0b43dc45-4734-4898-b321-19bd1b063e53",
"role": "tool",
"content": "{\"result\": [{\"name\": \"Item 1\", \"description\": \"It is the first item of the list\"}, {\"name\": \"Item 2\", \"description\": \"It is the second item of the list\"}, {\"name\": \"Item 3\", \"description\": \"It is the third item of the list\"}, {\"name\": \"Item 4\", \"description\": \"It is the fourth item of the list\"}, {\"name\": \"Item 5\", \"description\": \"It is the fifth item of the list\"}]}"
},
{
"id": "ea812e72-c8ea-477f-a6e0-3b1d07f2e3ac",
"role": "assistant",
"content": "Here are the available items:\n"
},
{
"id": "adk-45f9d318-0fed-44da-b732-19d8e8411753",
"role": "assistant",
"toolCalls": [
{
"id": "adk-45f9d318-0fed-44da-b732-19d8e8411753",
"type": "function",
"function": {
"name": "render_ItemsList", // FIRST CALL, OK
"arguments": "{\"items\": [\"Item 1\", \"Item 2\", \"Item 3\", \"Item 4\", \"Item 5\"]}"
}
}
]
},
{
"id": "tool-result-1762374343175",
"role": "tool",
"content": "{\"result\":\"success\",\"message\":\"Items were rendered successfully.\"}",
"toolCallId": "adk-45f9d318-0fed-44da-b732-19d8e8411753"
},
{
"id": "user-1762374493133",
"role": "user",
"content": "Cool\n"
}
]
}RESPONSE:
data: {"type":"RUN_STARTED","threadId":"ad474246-bcc9-41a7-af4a-78c63f1e959f","runId":"5ad5dcfd-b448-4f90-825b-7a9f2c860b93"}
data: {"type":"TEXT_MESSAGE_START","messageId":"a047cc99-75d4-471f-a0ea-a88e2d511779","role":"assistant"}
data: {"type":"TEXT_MESSAGE_CONTENT","messageId":"a047cc99-75d4-471f-a0ea-a88e2d511779","delta":"Here are the available items:\n"}
data: {"type":"TEXT_MESSAGE_END","messageId":"a047cc99-75d4-471f-a0ea-a88e2d511779"}
// SECOND CALL OF THE SAME TOOL
data: {"type":"TOOL_CALL_START","toolCallId":"adk-9e13c7d4-2e59-48ad-964f-b6b681c64b99","toolCallName":"render_ItemsList"}
data: {"type":"TOOL_CALL_ARGS","toolCallId":"adk-9e13c7d4-2e59-48ad-964f-b6b681c64b99","delta":"{\"items\": [\"Item 1\", \"Item 2\", \"Item 3\", \"Item 4\", \"Item 5\"]}"}
data: {"type":"TOOL_CALL_END","toolCallId":"adk-9e13c7d4-2e59-48ad-964f-b6b681c64b99"}
data: {"type":"RUN_FINISHED","threadId":"ad474246-bcc9-41a7-af4a-78c63f1e959f","runId":"5ad5dcfd-b448-4f90-825b-7a9f2c860b93"}
data: {"type":"RUN_STARTED","threadId":"ad474246-bcc9-41a7-af4a-78c63f1e959f","runId":"5ad5dcfd-b448-4f90-825b-7a9f2c860b93"}
data: {"type":"TEXT_MESSAGE_START","messageId":"010b6ce0-5d9b-48c1-84e3-16882af38baf","role":"assistant"}
data: {"type":"TEXT_MESSAGE_CONTENT","messageId":"010b6ce0-5d9b-48c1-84e3-16882af38baf","delta":"I have listed all the available items for you. Is there anything else I can help you with today, Joe Doe?"}
data: {"type":"TEXT_MESSAGE_END","messageId":"010b6ce0-5d9b-48c1-84e3-16882af38baf"}
data: {"type":"STATE_SNAPSHOT","snapshot":{"context":{"conversation":[],"user":{"name":"Joe Doe","timezone":"UTC"},"app":{"version":"unknown"}},"state":{}}}
data: {"type":"RUN_FINISHED","threadId":"ad474246-bcc9-41a7-af4a-78c63f1e959f","runId":"5ad5dcfd-b448-4f90-825b-7a9f2c860b93"}
data: {"type":"RUN_STARTED","threadId":"ad474246-bcc9-41a7-af4a-78c63f1e959f","runId":"5ad5dcfd-b448-4f90-825b-7a9f2c860b93"}
data: {"type":"TEXT_MESSAGE_START","messageId":"fd65e00c-59ea-421b-bb6f-229618681823","role":"assistant"}
data: {"type":"TEXT_MESSAGE_CONTENT","messageId":"fd65e00c-59ea-421b-bb6f-229618681823","delta":"I'm glad I could help, Joe Doe! Is there anything else you'd like to know or see today?"}
data: {"type":"TEXT_MESSAGE_END","messageId":"fd65e00c-59ea-421b-bb6f-229618681823"}
data: {"type":"STATE_SNAPSHOT","snapshot":{"context":{"conversation":[],"user":{"name":"Joe Doe","timezone":"UTC"},"app":{"version":"unknown"}},"state":{}}}
data: {"type":"RUN_FINISHED","threadId":"ad474246-bcc9-41a7-af4a-78c63f1e959f","runId":"5ad5dcfd-b448-4f90-825b-7a9f2c860b93"}
REGISTERED ADK SESSION:
{
"id":"ad474246-bcc9-41a7-af4a-78c63f1e959f",
"appName":"agent",
"userId":"user-123",
"state":{
"user_id":"user-123",
"user_name":"Joe Doe",
"pending_tool_calls":[
"adk-9e13c7d4-2e59-48ad-964f-b6b681c64b99"
]
},
"events":[
{
"invocationId":"state_update_1762374339",
"author":"system",
"actions":{
"stateDelta":{
"user_id":"user-123",
"user_name":"Joe Doe"
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"a5c5464c-e002-4b57-8ed1-7659d5917d6d",
"timestamp":1762374339.679549
},
{
"content":{
"parts":[
{
"text":"i would like to see the available items\n"
}
],
"role":"user"
},
"invocationId":"e-5e7287cc-53b2-4cd8-b8ff-d3642aa070b1",
"author":"user",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"0f6bf1f7-7023-4b4c-a21a-15569bc7a789",
"timestamp":1762374339.698708
},
{
"content":{
"parts":[
{
"functionCall":{
"id":"adk-0b43dc45-4734-4898-b321-19bd1b063e53",
"args":{
},
"name":"get_items"
},
"thoughtSignature":"CiQB0e2Kby05aMrzOTEDLM11oefO-TLcdYqKi8GQx29NRccl7lQKZAHR7Ypvzvxmkl4d7n8q9KIZxqg-8X5H9rHizJAElJmWczpvu-lgJIL9jduqS4tc9kMJshNXBe7khWDzM3vTjBH3fAxeIyNFsi5DvHMYRQGJ50EBbZJaaONgSxV2uPVTbVBr9OwK9gEB0e2Kb6b6DDQ2DQ8o9ExQa8L0gcg1-hWkV3OxJzzPNiEsN6oBfTnkxEf_2SwchsHWwgbloYt-NLQz7V2uSxd7JI434ezsv9YMQEPY2dmQv_e4RG6y1atHRJKlavRy9Ck5-FNii4-JVvzTgRsrtT_aVZvrOqTBrpn-06BnoMn-EA59SRBCjB37Uks2fGLJnDuiJWxI-3Db9rK_cuXxnSD8NL_SIbpK4NbCngE3qL0HsM940EUakXG6Aj1JXz6iETH63LiA07FDgeQuQSvpiRNjiGT_utrCkx0mg9Ncxjlm3GBvkwDgLMHUfxrFqZ2P4Kp6KiVv7-Q="
}
],
"role":"model"
},
"usageMetadata":{
"candidatesTokenCount":10,
"promptTokenCount":778,
"promptTokensDetails":[
{
"modality":"TEXT",
"tokenCount":778
}
],
"thoughtsTokenCount":69,
"totalTokenCount":857
},
"invocationId":"e-5e7287cc-53b2-4cd8-b8ff-d3642aa070b1",
"author":"GenericAgent",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"9b32bcdc-f212-44b1-b69c-ab131a68d3ed",
"timestamp":1762374339.70406
},
{
"content":{
"parts":[
{
"functionResponse":{
"id":"adk-0b43dc45-4734-4898-b321-19bd1b063e53",
"name":"get_items",
"response":{
"result":[
{
"name":"Item 1",
"description":"It is the first item of the list"
},
{
"name":"Item 2",
"description":"It is the second item of the list"
},
{
"name":"Item 3",
"description":"It is the third item of the list"
},
{
"name":"Item 4",
"description":"It is the fourth item of the list"
},
{
"name":"Item 5",
"description":"It is the fifth item of the list"
}
]
}
}
}
],
"role":"user"
},
"invocationId":"e-5e7287cc-53b2-4cd8-b8ff-d3642aa070b1",
"author":"GenericAgent",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"c181a89b-219a-4414-876a-b9992fb89645",
"timestamp":1762374341.719147
},
{
"content":{
"parts":[
{
"text":"Here are the available items:\n"
}
],
"role":"model"
},
"usageMetadata":{
"cacheTokensDetails":[
{
"modality":"TEXT",
"tokenCount":710
}
],
"cachedContentTokenCount":710,
"candidatesTokenCount":44,
"promptTokenCount":974,
"promptTokensDetails":[
{
"modality":"TEXT",
"tokenCount":974
}
],
"thoughtsTokenCount":77,
"totalTokenCount":1095
},
"invocationId":"e-5e7287cc-53b2-4cd8-b8ff-d3642aa070b1",
"author":"GenericAgent",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"ada8456d-ea87-4bf6-b822-58921c7de9b0",
"timestamp":1762374343.022712
},
{
"content":{
"parts":[
{
"functionCall":{
"id":"adk-45f9d318-0fed-44da-b732-19d8e8411753",
"args":{
"items":[
"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 5"
]
},
"name":"render_ItemsList"
}
}
],
"role":"model"
},
"usageMetadata":{
"cacheTokensDetails":[
{
"modality":"TEXT",
"tokenCount":710
}
],
"cachedContentTokenCount":710,
"candidatesTokenCount":44,
"promptTokenCount":974,
"promptTokensDetails":[
{
"modality":"TEXT",
"tokenCount":974
}
],
"thoughtsTokenCount":77,
"totalTokenCount":1095
},
"invocationId":"e-5e7287cc-53b2-4cd8-b8ff-d3642aa070b1",
"author":"GenericAgent",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
"adk-45f9d318-0fed-44da-b732-19d8e8411753"
],
"id":"4b2799fa-b1fb-4dbc-9719-2835c56aa35a",
"timestamp":1762374343.15892
},
{
"invocationId":"state_update_1762374344",
"author":"system",
"actions":{
"stateDelta":{
"pending_tool_calls":[
"adk-45f9d318-0fed-44da-b732-19d8e8411753"
]
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"4ed9fef3-827f-4468-a608-f80e9aadfd57",
"timestamp":1762374344.18377
},
{
"invocationId":"state_update_1762374493",
"author":"system",
"actions":{
"stateDelta":{
"user_id":"user-123",
"user_name":"Joe Doe"
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"7554bbb6-5c3a-4849-a4b2-add79d5b2ff7",
"timestamp":1762374493.236215
},
{
"content":{
"parts":[
{
"functionResponse":{
"id":"adk-0b43dc45-4734-4898-b321-19bd1b063e53",
"name":"get_items",
"response":{
"result":[
{
"name":"Item 1",
"description":"It is the first item of the list"
},
{
"name":"Item 2",
"description":"It is the second item of the list"
},
{
"name":"Item 3",
"description":"It is the third item of the list"
},
{
"name":"Item 4",
"description":"It is the fourth item of the list"
},
{
"name":"Item 5",
"description":"It is the fifth item of the list"
}
]
}
}
}
],
"role":"function"
},
"invocationId":"e-6680032f-4c7b-4de6-9200-541538a7bc5b",
"author":"user",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"7c0b986f-9316-4686-874c-2c8e26601ac7",
"timestamp":1762374493.247497
},
{
"content":{
"parts":[
{
"text":"Here are the available items:\n"
}
],
"role":"model"
},
"usageMetadata":{
"candidatesTokenCount":44,
"promptTokenCount":974,
"promptTokensDetails":[
{
"modality":"TEXT",
"tokenCount":974
}
],
"thoughtsTokenCount":99,
"totalTokenCount":1117
},
"invocationId":"e-6680032f-4c7b-4de6-9200-541538a7bc5b",
"author":"GenericAgent",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"42c520c6-794e-4cdb-a5ab-a2700f4b7c20",
"timestamp":1762374494.773257
},
{
"content":{
"parts":[
{
"functionCall":{
"id":"adk-9e13c7d4-2e59-48ad-964f-b6b681c64b99",
"args":{
"items":[
"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 5"
]
},
"name":"render_ItemsList"
}
}
],
"role":"model"
},
"usageMetadata":{
"candidatesTokenCount":44,
"promptTokenCount":974,
"promptTokensDetails":[
{
"modality":"TEXT",
"tokenCount":974
}
],
"thoughtsTokenCount":99,
"totalTokenCount":1117
},
"invocationId":"e-6680032f-4c7b-4de6-9200-541538a7bc5b",
"author":"GenericAgent",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
"adk-9e13c7d4-2e59-48ad-964f-b6b681c64b99"
],
"id":"9faf6f3f-5e8a-413f-bd4a-8cd486fbc9e6",
"timestamp":1762374494.920271
},
{
"invocationId":"state_update_1762374495",
"author":"system",
"actions":{
"stateDelta":{
"pending_tool_calls":[
"adk-45f9d318-0fed-44da-b732-19d8e8411753",
"adk-9e13c7d4-2e59-48ad-964f-b6b681c64b99"
]
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"8a7ccdf9-6b4d-4172-87b4-ec836d2c2b45",
"timestamp":1762374495.941159
},
{
"invocationId":"state_update_1762374495",
"author":"system",
"actions":{
"stateDelta":{
"pending_tool_calls":[
"adk-9e13c7d4-2e59-48ad-964f-b6b681c64b99"
]
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"e9193b71-def5-4bc2-82c8-4da3eb78c084",
"timestamp":1762374495.952559
},
{
"invocationId":"state_update_1762374495",
"author":"system",
"actions":{
"stateDelta":{
"user_id":"user-123",
"user_name":"Joe Doe"
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"519faf80-75b4-4d8d-8883-69f2b84335c0",
"timestamp":1762374495.96033
},
{
"content":{
"parts":[
{
"functionResponse":{
"id":"adk-45f9d318-0fed-44da-b732-19d8e8411753",
"name":"render_ItemsList",
"response":{
"result":"success",
"message":"Items were rendered successfully."
}
}
}
],
"role":"function"
},
"invocationId":"e-ec2f4c69-17e6-4fdb-a627-69b3159ed9a1",
"author":"user",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"40f7db59-b376-445b-b9e6-077b228b4c9e",
"timestamp":1762374495.967142
},
{
"content":{
"parts":[
{
"text":"I have listed all the available items for you. Is there anything else I can help you with today, Joe Doe?"
}
],
"role":"model"
},
"usageMetadata":{
"candidatesTokenCount":24,
"promptTokenCount":998,
"promptTokensDetails":[
{
"modality":"TEXT",
"tokenCount":998
}
],
"thoughtsTokenCount":130,
"totalTokenCount":1152
},
"invocationId":"e-ec2f4c69-17e6-4fdb-a627-69b3159ed9a1",
"author":"GenericAgent",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"f93d6550-4e61-4ebb-9684-f657ccd28875",
"timestamp":1762374497.596019
},
{
"invocationId":"state_update_1762374497",
"author":"system",
"actions":{
"stateDelta":{
"user_id":"user-123",
"user_name":"Joe Doe"
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"2870d16c-fe04-4b78-b7c1-a0780a01f96a",
"timestamp":1762374497.621625
},
{
"content":{
"parts":[
{
"text":"Cool\n"
}
],
"role":"user"
},
"invocationId":"e-5facd076-749a-47d5-9f27-f8ab1aba1ae2",
"author":"user",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"b0169c89-0b25-41c9-8804-9d3cff619180",
"timestamp":1762374497.633487
},
{
"content":{
"parts":[
{
"text":"I'm glad I could help, Joe Doe! Is there anything else you'd like to know or see today?"
}
],
"role":"model"
},
"usageMetadata":{
"candidatesTokenCount":25,
"promptTokenCount":1053,
"promptTokensDetails":[
{
"modality":"TEXT",
"tokenCount":1053
}
],
"thoughtsTokenCount":66,
"totalTokenCount":1144
},
"invocationId":"e-5facd076-749a-47d5-9f27-f8ab1aba1ae2",
"author":"GenericAgent",
"actions":{
"stateDelta":{
},
"artifactDelta":{
},
"requestedAuthConfigs":{
},
"requestedToolConfirmations":{
}
},
"longRunningToolIds":[
],
"id":"4931bb0f-9877-483d-bb0d-b7dcd7fb17e5",
"timestamp":1762374498.96628
}
],
"lastUpdateTime":1762374495
}Metadata
Metadata
Assignees
Labels
No labels