fix(remoteagent): cancel A2A task after early context cancellation #1324
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.49) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.49 · 325 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.346
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1324"
general
weight: 0.35
ktsoator
Linked issue
Closes #1076.
Canceling an invocation before the first A2A task event arrives can leave the remote task running because the client does not yet know its ID. This change briefly keeps the stream open to obtain a cleanup target and cancel the task, without emitting further session events or running response callbacks during that wait.
Behavior change
The wait is limited to five seconds and respects the caller's deadline. If the deadline expires before task information arrives, cleanup cannot discover the task. Terminal tasks and final message responses are left alone; an artifact's task ID can be used when no task state is available.
The default
CancelTaskcall uses the remaining cleanup budget if at least 100 ms remain; otherwise, it gets a detached five-second timeout. Cleanup can therefore extend beyond the caller's deadline. These timing values are still awaiting maintainer feedback.Non-streaming responses now retain their cleanup target too: working tasks are canceled, while completed tasks and input-required tasks without an error are preserved.
Unlike adk-python, which closes the stream without this wait, Go keeps it open briefly to recover the task ID needed for cleanup. No public API or dependency changes are introduced.
Testing Plan
TestRemoteAgent_AuthCleanupReusesTheInvocationCredentialfail; restoring it makes the test pass.Checklist