feat(a2a): Add exclude_history boolean parameter to A2AClientToolProvider to control whether task.history is included in a2a_send_message responses #373
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Add exclude_history boolean parameter to A2AClientToolProvider constructor to control whether task.history is included in a2a_send_message responses.
Related Issues
Fixes #367
Documentation PR
N/A - Documentation updated in this PR (constructor docstring)
Type of Change
Other (please describe): Enhancement to existing tool
Testing
I have created 2 new unit tests for this functionality which run successfully, and all existing tests still run successfully.
I have manually tested the change by creating two strands agents that communicate using a2a. The first Strands agent (the client agent) uses the A2AClientToolProvider and the a2a_send_message tool to invoke another Strands agent (the server agent). In the server, I am returning a verbose response to the client shown below.
For the results of the tests below, we will be looking at the 'text' field in message.content.toolResult.content. (example message json structure below):
{ "message": { "role": "user", "content": [ { "toolResult": { "toolUseId": "tooluse_4Ay532SdFk6lgT_-mI6aSQ", "status": "success", "content": [ { "text": # This is what we will be looking at in the tests } ] } } ] }, "message_id": 2, "redact_message": null, "created_at": "2026-01-20T18:55:13.201295+00:00", "updated_at": "2026-01-20T18:55:13.201308+00:00" }Both tests have the same initial input ("call the downstream agent saying 'Hello'") and the same system prompt
Test 1: The client agent uses
A2AClientToolProviderwithexclude_history=Falseand calls the a2a_send_message tool. This replicates the existing behavior of the a2a_send_message tool.The toolResult content is below (formatted with new lines, history messages truncated because of size), and the content is 17756 characters. This entire content is placed into the agent's context. You can also see that the history is almost entirely useless, given that the combined result is available in the artifacts.
{ 'status': 'success', 'response': { 'task': { 'artifacts': [ { 'artifactId': 'a7e687a7-18b8-46d0-bdb6-78fa8fb3d060', 'name': 'agent_response', 'parts': [ { 'kind': 'text', 'text': 'Hello from the A2A Server Agent! This is a hardcoded greeting.\n Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.\n\nLorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.\n\nLorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.\n' } ] } ], 'contextId': '2f9c4eb7-3546-43bd-b25c-61959c57668f', 'history': [ {'contextId': '2f9c4eb7-3546-43bd-b25c-61959c57668f', 'kind': 'message', 'messageId': '1ff55166c92f4e2a9001a93aea10283a', 'parts': [{'kind': 'text', 'text': 'Hello'}], 'role': <Role.user: 'user'>, 'taskId': '0ec89d09-38ed-44dd-badf-1342417f6e1c'}, {'contextId': '2f9c4eb7-3546-43bd-b25c-61959c57668f', 'kind': 'message', 'messageId': '1106cd7c-b1f9-4751-8093-baee0f8d345e', 'parts': [{'kind': 'text', 'text': 'Hello'}], 'role': <Role.agent: 'agent'>, 'taskId': '0ec89d09-38ed-44dd-badf-1342417f6e1c'}, {'contextId': '2f9c4eb7-3546-43bd-b25c-61959c57668f', 'kind': 'message', 'messageId': 'fe4a3216-dbf5-48dc-b181-616d7bffdad0', 'parts': [{'kind': 'text', 'text': ' from the A2A Server Agent!'}], 'role': <Role.agent: 'agent'>, 'taskId': '0ec89d09-38ed-44dd-badf-1342417f6e1c'}, {'contextId': '2f9c4eb7-3546-43bd-b25c-61959c57668f', 'kind': 'message', 'messageId': '9c7ecff2-8993-401f-8574-5868b288138d', 'parts': [{'kind': 'text', 'text': ' This is a hardcoded greeting.'}], 'role': <Role.agent: 'agent'>, 'taskId': '0ec89d09-38ed-44dd-badf-1342417f6e1c'}, {'contextId': '2f9c4eb7-3546-43bd-b25c-61959c57668f', 'kind': 'message', 'messageId': 'ff38fbbc-18d4-4a3c-b712-47d809fb3db1', 'parts': [{'kind': 'text', 'text': '\\n '}], 'role': <Role.agent: 'agent'>, 'taskId': '0ec89d09-38ed-44dd-badf-1342417f6e1c'}, {'contextId': '2f9c4eb7-3546-43bd-b25c-61959c57668f', 'kind': 'message', 'messageId': 'ffe78327-cc83-487f-af08-898d1342ef03', 'parts': [{'kind': 'text', 'text': 'Lorem ipsum dolor sit amet consectetur adipis'}], 'role': <Role.agent: 'agent'>, 'taskId': '0ec89d09-38ed-44dd-badf-1342417f6e1c'}, {'contextId': '2f9c4eb7-3546-43bd-b25c-61959c57668f', 'kind': 'message', 'messageId': '8e877585-6c60-4cf6-8087-b4c44be50a79', 'parts': [{'kind': 'text', 'text': 'cing elit. Quisque f'}], 'role': <Role.agent: 'agent'>, 'taskId': '0ec89d09-38ed-44dd-badf-1342417f6e1c'}, # ... (57 more history entries with streaming chunks) {'contextId': '2f9c4eb7-3546-43bd-b25c-61959c57668f', 'kind': 'message', 'messageId': '3cfd5f9f-4920-4705-91b9-05af622a326a', 'parts': [{'kind': 'text', 'text': ' himenaeos.'}], 'role': <Role.agent: 'agent'>, 'taskId': '0ec89d09-38ed-44dd-badf-1342417f6e1c'} ], 'id': '0ec89d09-38ed-44dd-badf-1342417f6e1c', 'kind': 'task', 'status': { 'state': <TaskState.completed: 'completed'>, 'timestamp': '2026-01-21T17:42:46.675477+00:00' } }, 'update': None }, 'message_id': '1ff55166c92f4e2a9001a93aea10283a', 'target_agent_url': 'http://127.0.0.1:8080' }Test 2: The client agent uses
A2AClientToolProviderwithexclude_history=Trueand calls the a2a_send_message tool. This excludes the history from the toolResult.The toolResult content is below (formatted with new lines), and the content is 1910 characters. This is all put into the Agent's context. As you can see, the artifact text includes the result of the a2a task execution, and the history is not needed.
{ 'status': 'success', 'response': { 'task': { 'artifacts': [ { 'artifactId': 'ffc74dfa-c353-44b1-93fc-63364541805a', 'name': 'agent_response', 'parts': [ { 'kind': 'text', 'text': 'Hello from the A2A Server Agent! This is a hardcoded greeting.\n Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.\n\nLorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.\n\nLorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.\n' } ] } ], 'contextId': 'da59f6fc-3492-4312-9a59-d7ab4a9c98c2', 'id': '09497395-d091-4a68-816d-1dfc941015dd', 'kind': 'task', 'status': { 'state': <TaskState.completed: 'completed'>, 'timestamp': '2026-01-21T17:57:22.973385+00:00' } }, 'update': None }, 'message_id': 'f6719ad5a3384ecf834fa4892c050462', 'target_agent_url': 'http://127.0.0.1:8080' }hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.