Repository navigation
Description
** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.
Describe the bug
When making call to a2a remote agent, the first send message request does not contain any context id or task id which is relevant. When the remote agent responds with a task that has task id and context id and task state as Input required, the subsequent send message request sends the context id but not the task id back even though it has it.
To Reproduce
Steps to reproduce the behavior:
the first send message request does not contain any context id or task id which is relevant. When the remote agent responds with a task that has task id and context id and task state as Input required, the subsequent send message request sends the context id but not the task id back even though it has it.
Expected behavior
A clear and concise description of what you expected to happen.
Expected behaviour is to have task id sent along with context id.
Proposed code changes are as below
def _construct_message_parts_from_session(
self, ctx: InvocationContext
) -> tuple[list[A2APart], dict[str, Any], str]:
"""Construct A2A message parts from session events.
Args:
ctx: The invocation context
Returns:
List of A2A parts extracted from session events, context ID, task ID
"""
message_parts: list[A2APart] = []
context_id = None
task_id = None
for event in reversed(ctx.session.events):
if _is_other_agent_reply(self.name, event):
event = _present_other_agent_message(event)
elif event.author == self.name:
# stop on content generated by current a2a agent given it should already
# be in remote session
if event.custom_metadata:
context_id = (
event.custom_metadata.get(A2A_METADATA_PREFIX + "context_id")
if event.custom_metadata
else None
)
task_id = (
event.custom_metadata.get(A2A_METADATA_PREFIX + "task_id")
if event.custom_metadata
else None
)
break
if not event.content or not event.content.parts:
continue
for part in event.content.parts:
converted_part = self._genai_part_converter(part)
if converted_part:
message_parts.append(converted_part)
else:
logger.warning("Failed to convert part to A2A format: %s", part)
return message_parts[::-1], context_id, task_id
async def _run_async_impl(
self, ctx: InvocationContext
) -> AsyncGenerator[Event, None]:
"""Core implementation for async agent execution."""
try:
await self._ensure_resolved()
except Exception as e:
yield Event(
author=self.name,
error_message=f"Failed to initialize remote A2A agent: {e}",
invocation_id=ctx.invocation_id,
branch=ctx.branch,
)
return
# Create A2A request for function response or regular message
a2a_request = self._create_a2a_request_for_user_function_response(ctx)
if not a2a_request:
message_parts, context_id, task_id = self._construct_message_parts_from_session(
ctx
)
if not message_parts:
logger.warning(
"No parts to send to remote A2A agent. Emitting empty event."
)
yield Event(
author=self.name,
content=genai_types.Content(),
invocation_id=ctx.invocation_id,
branch=ctx.branch,
)
return
a2a_request = A2AMessage(
message_id=str(uuid.uuid4()),
parts=message_parts,
role="user",
context_id=context_id,
task_id=task_id,
)
logger.debug(build_a2a_request_log(a2a_request))
try:
async for a2a_response in self._a2a_client.send_message(
request=a2a_request
):
logger.debug(build_a2a_response_log(a2a_response))
event = await self._handle_a2a_response(a2a_response, ctx)
# Add metadata about the request and response
event.custom_metadata = event.custom_metadata or {}
event.custom_metadata[A2A_METADATA_PREFIX + "request"] = (
a2a_request.model_dump(exclude_none=True, by_alias=True)
)
# If the response is a ClientEvent, record the task state, otherwise
# record the message object.
if isinstance(a2a_response, tuple):
event.custom_metadata[A2A_METADATA_PREFIX + "response"] = (
a2a_response[0].model_dump(exclude_none=True, by_alias=True)
)
else:
event.custom_metadata[A2A_METADATA_PREFIX + "response"] = (
a2a_response.model_dump(exclude_none=True, by_alias=True)
)
yield event
Screenshots
Desktop (please complete the following information):
- OS: [e.g. macOS, Linux, Windows]
- Python version(python -V):
- ADK version(pip show google-adk):
Model Information:
Happening with all models
Additional context
NA
Activity
fix: Extract and propagate task_id in RemoteA2aAgent
AneshkaGoyal commentedon Dec 20, 2025
I can see the changes made to close this are not in line with what I recommended and hence does not fix the issue while 1.21.0 marks it as a bug fix @GWeale could you please help me understand.
llalitkumarrr commentedon Feb 3, 2026
Hello @AneshkaGoyal ,
Apologies for the delayed response, we recommend trying our latest version i.e.
google-adk==1.23.0. If this issue is not fixed in this version, kindly share your observations and some reproduction steps along with minimal reproducible code to help us reproduce this and assist you better.adk-bot commentedon Feb 10, 2026
This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.
AneshkaGoyal commentedon Feb 15, 2026
@llalitkumarrr I tired latest version but still only context id is passed for an A2A request, please check the correct fix is not implemented - The same repro steps as mentioned above
I had reported this issue and a fix was pushed but thats not the correct fix.
I have supplied the correct fix in the issue above.
This fix is not upto the mark - 82bd4f3
llalitkumarrr commentedon Feb 24, 2026
Hello @AneshkaGoyal ,
Could you please share minimal reproducible code to help us reproduce this to get to the bottom of this issue?
AneshkaGoyal commentedon Mar 1, 2026
Sure, Just make a call to any A2A compliant Agent from google adk(remote agent), the remote agent sends input required as task state, returns task identifier and asks for additional information, when google ADK sends the reply to the remote agent - It just respects the context id and does not send the task id with the message sent
Please return this from remote agent for a Task thats being processed.
` // Create Input required status
TaskStatus completedStatus = new TaskStatus(
SELECT == agentResponse.getCurrentStep()
? TaskState.COMPLETED
: TaskState.INPUT_REQUIRED,
null, // No status message currently
OffsetDateTime.now()
);
List<Part<?>> parts = ResponseBuilderUtils.buildResponseParts(agentResponse, finalResponseList);
Artifact responseArtifact = new Artifact.Builder()
.artifactId(UUID.randomUUID().toString())
.name("artifact-" + taskId)
.parts(parts)
.build();
sasha-gitg commentedon Mar 2, 2026
Resolved by 82bd4f38
fix: Extract and propagate task_id in RemoteA2aAgent
fix: Extract and propagate task_id in RemoteA2aAgent