Skip to content

[FEATURE] Make agent.cancel() a noop when agent is idle #2156

@crazybolillo

Description

@crazybolillo

Problem Statement

Calling cancel() on an idle agent results in its next invocation being immediately cancelled. There is also no public interface to know whether an agent is idle or not and be able to know whether to cancel or not.

Proposed Solution

Cancel should be updated to internally check whether the agent is idle or not and become a no-op if already idle (not running).

Use Case

Expose stop functionality to end-users and prevent weird behavior such as cancelling an agent just as it becomes idle and then having the next invocation fail (immediately cancelled).

Alternatives Solutions

Leaving it up to users of the library to determine deal with this, possibly by looking at whether self._invocation_lock is locked or not. However this is a private field.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions