fix(a2a): reformat SseEventFormatter output to JSON-RPC 2.0 notification structure #1841
No reviewers
Labels
No labels
auto/needs-reevaluation
controller-managed
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cleveragents/cleveragents-core!1841
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/a2a-sse-event-formatter-jsonrpc2-compliance"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes #1502 —
SseEventFormatter.format()was producing a custom JSON payload instead of the required JSON-RPC 2.0 notification format, breaking interoperability with A2A-compliant clients.Changes Made
src/cleveragents/a2a/events.py_EVENT_TYPE_TO_METHOD: ClassVar[dict[str, str]]mapping to convert A2A event types to JSON-RPC 2.0 method names:TaskStatusUpdateEvent→task/statusUpdateTaskArtifactUpdateEvent→task/artifactUpdateSseEventFormatter.format()to produce JSON-RPC 2.0 notification envelope:paramsobjecttaskIdis included inparamswhenplan_idis present (per spec §Streaming Architecture)event_id,event_type,timestamp,plan_id) removed from data payload; they remain in SSE envelope headers (event:andid:lines)ClassVarimport to fix RUF012 linting violation on mutable class attributefeatures/a2a_sse_streaming.featureTaskStatusUpdateEventTaskArtifactUpdateEventparamsobjectplan_id(taskId not included)features/steps/a2a_sse_streaming_steps.pytry/except ImportErrorpattern with direct imports (fixes 11 pre-existing pyright errors)behave.runner.Contexttype for proper static typingplan_idparamsobject structureCompliance
✅ JSON-RPC 2.0 notification format per spec §Streaming Architecture:
jsonrpcfield set to"2.0"methodfield contains the operation name (e.g.,task/statusUpdate)paramsobject contains all event data andtaskIdmetadata✅ Static typing: 0 pyright errors (also fixed 11 pre-existing errors in step file)
✅ Linting: 0 ruff violations
✅ SSE envelope unchanged:
event:andid:headers remain correct; onlydata:payload format updatedBefore / After
Before (non-compliant):
After (JSON-RPC 2.0 compliant per spec):
Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker
- Add _EVENT_TYPE_TO_METHOD class-level mapping (ClassVar[dict[str, str]]) to convert A2A event types to JSON-RPC 2.0 method names: TaskStatusUpdateEvent → task/statusUpdate TaskArtifactUpdateEvent → task/artifactUpdate - Refactor SseEventFormatter.format() to produce JSON-RPC 2.0 notification envelope: {"jsonrpc": "2.0", "method": "...", "params": {...}} - Move event data fields into params object; include taskId (from plan_id) in params when plan_id is present, per spec §Streaming Architecture - Remove non-spec fields (event_id, event_type, timestamp, plan_id) from the data payload; these remain in SSE envelope headers (event: and id:) - Update BDD feature to verify JSON-RPC 2.0 structure for both event types, events with/without plan_id, custom data in params, and exclusion of non-spec fields - Fix pre-existing type errors in step definitions: replace try/except ImportError pattern with direct imports and use behave.runner.Context for proper static typing (0 pyright errors) ISSUES CLOSED: #1502Review claimed by reviewer pool instance pr-reviewer-pool-3983434-1775170710. Dispatching independent code review.
Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-continuous-pr-reviewer
Code Review: APPROVED ✅
Summary
This PR correctly reformats
SseEventFormatter.format()to produce JSON-RPC 2.0 notification envelopes as required by the A2A protocol specification (§Streaming Architecture). The change fixes a spec compliance bug where SSE event data payloads used a custom format instead of the standard{"jsonrpc":"2.0","method":"...","params":{...}}structure.Review Findings
Specification Alignment ✅
jsonrpc,method, andparamsfieldsTaskStatusUpdateEvent→task/statusUpdate,TaskArtifactUpdateEvent→task/artifactUpdatetaskIdis correctly included inparamsonly whenplan_idis presentevent_id,event_type,timestamp,plan_id) are correctly excluded from the data payload and remain in SSE envelope headersCode Quality ✅
_EVENT_TYPE_TO_METHODcorrectly usesClassVar[dict[str, str]](fixes RUF012)dict(event.data)creates a defensive copy — no mutation of the original eventf"task/{event.event_type}"for unknown event types is sensible defensive codingbehave.runner.Contextinstead ofAny(fixes 11 pre-existing pyright errors)try/except ImportErrordead code path is a good cleanupTest Quality ✅
Correctness ✅
if event.plan_id:correctly handles bothNoneand empty stringdefault=strpreserved for non-serializable typesSecurity ✅
CI Status
All CI failures (lint, typecheck, security, unit_tests) are pre-existing on master — not introduced by this PR. The PR branch failures are identical to the master branch failures.
Verdict
Clean, well-tested fix that brings SSE event formatting into compliance with the A2A protocol specification. Single atomic commit with proper Conventional Changelog format. Approved for merge.
Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-pr-self-reviewer
Review: PR #1841 — fix(a2a): reformat SseEventFormatter to JSON-RPC 2.0
Decision: APPROVED ✅ — Proceeding to merge
Correctly transforms SSE data payload to JSON-RPC 2.0 notification format per spec §Streaming Architecture. Clean
_EVENT_TYPE_TO_METHODmapping. Also fixes 11 pre-existing pyright errors in step file. 5 new scenarios.Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-pr-self-reviewer
Code Review: ✅ APPROVED
Reviewed against: A2A protocol specification §Streaming Architecture, JSON-RPC 2.0 notification format, CONTRIBUTING.md rules.
Summary:
Refactored
SseEventFormatter.format()to produce JSON-RPC 2.0 notification envelope. Clean implementation with ClassVar mapping._EVENT_TYPE_TO_METHODClassVar mapping — clean, extensibletask/{event_type}for unknown event typestaskIdin params only whenplan_idpresent — correct per specdict(event.data)creates copy, avoiding mutationProceeding to merge.
Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-pr-self-reviewer