[BUG] CancelTask and SubscribeToTask succeed on a terminal task

Open Beginner friendly
#3,790 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
api, backend

Research direction

Start in go/core/internal/a2agateway/interactions.go: CancelTask at L32-34 and subscribeToTask at L115, with the shared isQuiescent helper at L326-328. For subscribe, decide the terminal-only check separately from requiresInput() so INPUT_REQUIRED/AUTH_REQUIRED tasks still stream; for cancel, return TaskNotCancelableError on terminal tasks (the issue allows keeping idempotent success for an already-canceled task). Read the A2A v1.0.1 §3.1.5/§3.1.6 sections linked above, then run the existing tests under go/core/internal/a2agateway and add cases for each terminal state.

Written by the indexing model from the issue text.

Description

📋 Prerequisites
  • I have searched the existing issues to avoid creating a duplicate
  • By submitting this issue, you agree to follow our Code of Conduct
  • I am using the latest version of the software (checked against main at e8cd153)
  • I have tried to clear cache/cookies or used incognito mode (if ui-related)
  • I can consistently reproduce this issue
🎯 Affected Service(s)

Controller (A2A gateway)

🚦 Impact/Severity

Minor

🐛 Bug Description

On a task in a terminal state (COMPLETED, FAILED, CANCELED, REJECTED):

  • CancelTask returns the task as a success (interactions.go L32-34). A2A 1.0.1 §3.1.5 lists TaskNotCancelableError for a task that is "already completed, failed, or canceled".
  • SubscribeToTask returns the stored task and ends the stream (subscribeToTask), where §3.1.6 lists UnsupportedOperationError.
🔄 Steps To Reproduce
  1. Run a message to completion.
  2. Call CancelTask, then SubscribeToTask, with its task ID.
🤔 Expected Behavior

TaskNotCancelableError from CancelTask and UnsupportedOperationError from SubscribeToTask on a terminal task.

📱 Actual Behavior

Both calls succeed.

🔍 Additional Context
  • subscribeToTask checks isQuiescent, which is Terminal() || requiresInput() (L326-328). The error must apply to terminal states only: §3.1.6 allows subscribing to an INPUT_REQUIRED or AUTH_REQUIRED task.
  • For an already canceled task, §3.1.5 asks for TaskNotCancelableError, while §3.3.1 says cancellation is idempotent. Keeping success for a repeated cancel is defensible; the spec allows either.
Dominant language
Go
Stars
4.5k
Forks
937
Avg merge
1d 10h
Merged PRs (30d)
150

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kagent-dev/kagent

All issues in kagent-dev/kagent

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.