Skip to content

fix: propagate cancelation signal using task store#272

Merged
yarolegovich merged 4 commits intomainfrom
yarolegovich/propagate-cancel-new
Mar 10, 2026
Merged

fix: propagate cancelation signal using task store#272
yarolegovich merged 4 commits intomainfrom
yarolegovich/propagate-cancel-new

Conversation

@yarolegovich
Copy link
Copy Markdown
Member

fixes #245

@yarolegovich yarolegovich changed the title fix: propagate cancel new fix: propagate cancelation signal using task store Mar 10, 2026
@yarolegovich
Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the handling of task cancellation and concurrent modifications within the system. It ensures that cancellation signals are reliably propagated across different components, particularly when multiple operations attempt to modify a task simultaneously. By introducing a dedicated mechanism for reporting the underlying cause of execution failures and integrating the task store more deeply into the processing logic, the changes improve the robustness and clarity of error handling, leading to more predictable system behavior during concurrent task lifecycles.

Highlights

  • Error Handling Refinement: Updated error handling for concurrent task modifications, replacing a2a.ErrConcurrentTaskModification with taskstore.ErrConcurrentModification and removing the old error definition.
  • Task Processor Enhancement: Modified the processor and newProcessor functions in a2asrv/agentexec.go to include the taskstore.Store, enabling better state management during task processing and cancellation.
  • Cancellation Signal Propagation: Implemented logic in processor.Process to handle taskstore.ErrConcurrentModification by checking the task's terminal state and returning appropriate results, ensuring cancellation signals are propagated effectively.
  • Detailed Error Context: Introduced ExecutionFailureCause in internal/taskexec/api.go's ProcessorResult to provide a more detailed error context for execution failures, and adjusted internal/taskexec/execution_handler.go to return this cause.
  • New Test Coverage: Added new end-to-end and unit tests (e2e/cancellation_test.go, internal/taskexec/execution_handler_test.go) to validate the correct propagation of cancellation signals and error causes during concurrent operations.
Changelog
  • a2a/errors.go
    • Removed ErrConcurrentTaskModification error definition.
  • a2asrv/agentexec.go
    • Passed f.taskStore to newProcessor in CreateExecutor and CreateCanceler.
    • Added store taskstore.Store field to processor struct.
    • Updated newProcessor function signature and initialization to accept and store taskstore.Store.
    • Modified Process method to handle taskstore.ErrConcurrentModification by checking task status and returning ExecutionFailureCause.
    • Updated setTaskFailed to include ExecutionFailureCause in ProcessorResult.
  • e2e/cancellation_test.go
    • Added e2e/cancellation_test.go to test concurrent cancellation scenarios.
  • internal/taskexec/api.go
    • Added ExecutionFailureCause field to ProcessorResult struct.
  • internal/taskexec/execution_handler.go
    • Modified processEvents to return processResult.ExecutionFailureCause.
  • internal/taskexec/execution_handler_test.go
    • Imported taskstore.
    • Added TestRunProducerConsumer_CausePropagation to verify error cause propagation.
  • internal/taskupdate/manager.go
    • Replaced a2a.ErrConcurrentTaskModification with taskstore.ErrConcurrentModification in updateStatus.
  • internal/taskupdate/manager_test.go
    • Updated tests to use taskstore.ErrConcurrentModification instead of a2a.ErrConcurrentTaskModification.
Activity
  • No specific activity (comments, reviews, or progress updates) was provided in the context for this pull request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively addresses concurrent task modifications, particularly for propagating cancellation signals. The approach of handling taskstore.ErrConcurrentModification by reloading the task state is robust. The introduction of ExecutionFailureCause to propagate the termination reason to the executor's context is a clean implementation detail. The changes are well-tested with new unit and end-to-end tests. I have one minor suggestion to remove a debugging statement.

if !storedTask.Task.Status.State.Terminal() {
return nil, fmt.Errorf("parallel active execution: %w", processingErr)
}
fmt.Println("storedTask", storedTask.Task.Status.State)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This fmt.Println appears to be a leftover debugging statement and should be removed to avoid polluting logs.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively fixes an issue with propagating cancellation signals across multiple servers by leveraging the shared task store. The approach to handle taskstore.ErrConcurrentModification is robust, and the introduction of ExecutionFailureCause provides a clean mechanism for propagating the cancellation cause to the execution goroutine. The changes are well-tested with new end-to-end and unit tests, ensuring the fix is reliable. I have one minor suggestion to remove a leftover debug print statement.

@yarolegovich yarolegovich merged commit 5e1d462 into main Mar 10, 2026
4 checks passed
@yarolegovich yarolegovich deleted the yarolegovich/propagate-cancel-new branch March 10, 2026 12:28
yarolegovich pushed a commit that referenced this pull request Mar 17, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.0.0](v1.0.0-alpha.3...v1.0.0)
(2026-03-17)


### Features

* implement the new rest error handling
([#282](#282))
([a3bda30](a3bda30))
* use v2 suffix for module ID and provide compat support
([#270](#270))
([dd1b6ba](dd1b6ba)),
closes [#250](#250)


### Bug Fixes

* a2asrv jsonrpc Content-Type
([#265](#265))
([2568a46](2568a46))
* bugs before going from alpha
([#279](#279))
([b1f055c](b1f055c))
* GetTaskRequest nil pointer assignment check
([#258](#258))
([440bb79](440bb79))
* inject headers into service params
([#277](#277))
([d33f3bd](d33f3bd)),
closes [#275](#275)
* propagate cancelation signal using task store
([#272](#272))
([5e1d462](5e1d462)),
closes [#245](#245)
* regenerate spec and fix returnImmediately
([#284](#284))
([2eee0b9](2eee0b9))
* task modified after save
([#266](#266))
([c15febe](c15febe))
* taskupdater result mutable
([#274](#274))
([6038d92](6038d92))
* update pushsender
([#256](#256))
([5f7a594](5f7a594))
* use enum values as in the spec
([#261](#261))
([eb98981](eb98981)),
closes [#251](#251)


### Documentation

* **a2asrv:** add Example_* test functions for pkg.go.dev documentation
([#262](#262))
([7888e37](7888e37))
* add example tests a2a
([#240](#240))
([4fe08a9](4fe08a9))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Do not try to move task to failed state on ErrConcurrentModification

2 participants