Skip to content

feat(a2a): Add Context ID support to A2A Task communication - #159

Merged
edenreich merged 5 commits into
mainfrom
claude/issue-158-20250917-1558
Sep 17, 2025
Merged

edenreich merged 5 commits into
mainfrom
claude/issue-158-20250917-1558

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Summary

Implements Context ID support for A2A server communication as requested in issue #158.

Changes

  • Extended TaskTracker interface with Context ID methods
  • Updated SimpleTaskTracker to track Context ID per session
  • Modified A2A Task tool to generate and send Context ID
  • Added comprehensive tests for Context ID functionality

Acceptance Criteria Met

  • ✅ Context ID is sent to A2A server
  • ✅ Context ID is tracked per chat session
  • ✅ Context ID is sent regardless of task status

Fixes #158

🤖 Generated with Claude Code

- Extend TaskTracker interface with Context ID methods
- Update SimpleTaskTracker to track Context ID per session
- Modify A2A Task tool to generate and send Context ID to A2A servers
- Add comprehensive tests for Context ID functionality
- Ensure Context ID persists across all tasks in same chat session

This allows A2A servers to group tasks by context and maintain
conversation context as requested in the issue requirements.

Co-authored-by: Eden Reich <[email protected]>
@edenreich

Copy link
Copy Markdown
Contributor Author

@claude Please read the official A2A specification, I don't think the client need to generate the ContextID, it's the job of the A2A server to generate it - the A2A Client (this CLI) only need to track it if I'm not mistaken.

Spec: https://a2a-protocol.org/dev/specification/

@claude

claude Bot commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor

Claude finished @edenreich's task —— View job


Context ID Implementation Fixed ✅

After analyzing the A2A specification from the ADK v0.10.0 source code, I can confirm that you were absolutely correct - the current implementation was wrong.

Todo List

  • Fetch and analyze A2A specification
  • Review current PR implementation
  • Compare implementation against spec requirements
  • Update code to follow server-generated Context ID pattern
  • Run quality checks
  • Commit any necessary changes

Key Findings & Changes Made

Problem Identified:
The original implementation had the CLI client generating Context IDs using uuid.New().String(), which violates the A2A protocol specification.

Correct A2A Protocol Behavior (from ADK task_handler.go:629-633):

contextID := params.Message.ContextID
if contextID == nil {
    newContextID := uuid.New().String()  // SERVER generates it
    contextID = &newContextID
}

Changes Applied:

  1. ✅ Removed client-side Context ID generation - No more uuid.New().String() in the client
  2. ✅ Extract Context ID from server response - Added t.taskTracker.SetContextID(submittedTask.ContextID)
  3. ✅ Maintain session tracking - Context ID is tracked per chat session as required
  4. ✅ Follow protocol correctly - Client sends messages, server generates/manages Context ID, client reuses it

Fixed Implementation:

  • Client sends initial message without Context ID
  • Server generates Context ID and includes it in task response
  • Client extracts and stores Context ID from server response
  • Client reuses stored Context ID for subsequent messages in same session

The implementation now correctly follows the A2A specification where the server is responsible for Context ID generation and management, while the client simply tracks and reuses the server-provided Context ID.

All tests pass and code quality checks are green! ✅

claude Bot and others added 4 commits September 17, 2025 16:17
- Remove client-side Context ID generation using uuid.New()
- Extract Context ID from server task response and store in tracker  
- Follow A2A protocol specification where server manages Context ID generation
- Maintain Context ID tracking per session as required

Based on ADK v0.10.0 source analysis, the A2A server generates Context IDs 
when not provided by the client, and the client should track and reuse the 
server-provided Context ID for subsequent messages in the same conversation.

Co-authored-by: Eden Reich <[email protected]>
…king

The New New New one was updated :)

Now Tasks ID and Context ID are being cleared properly when moving from one chat to another.

TODO - probably need to think about when the user loads the chat from the Database using /conversation I should probably track at least the context id in the database.

Signed-off-by: Eden Reich <[email protected]>
…D management across other shortcuts /new /conversation

Signed-off-by: Eden Reich <[email protected]>
@edenreich
edenreich merged commit aad2466 into main Sep 17, 2025
@edenreich
edenreich deleted the claude/issue-158-20250917-1558 branch September 17, 2025 17:34
inference-gateway-releaser Bot pushed a commit that referenced this pull request Sep 17, 2025
## [0.50.0](v0.49.0...v0.50.0) (2025-09-17)

### 🚀 Features

* **a2a:** Add Context ID support to A2A Task communication ([#159](#159)) ([aad2466](aad2466)), closes [#158](#158) [#158](#158)
* **agent:** Add parallel tool execution support to `infer agent` command ([#157](#157)) ([9f8bd26](9f8bd26)), closes [#156](#156)

### ♻️ Code Refactoring

* Improve AGENTS.md generation with parallel tool execution and efficiency tips ([1c2a090](1c2a090))
* **init:** Simplify `infer init` command to support AI-generated AGENTS.md with model option ([18505da](18505da))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.50.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add Context ID to the task that is being submitted to the A2A Server

1 participant