Skip to content

feat: support abort parameter in runner, agent, model, tool and processors#234

Open
kalenkevich wants to merge 1 commit intomainfrom
feat/abort_support
Open

feat: support abort parameter in runner, agent, model, tool and processors#234
kalenkevich wants to merge 1 commit intomainfrom
feat/abort_support

Conversation

@kalenkevich
Copy link
Copy Markdown
Collaborator

Please ensure you have read the contribution guide before creating a pull request.

Description of Change

Problem:
I needed to add abort functionality across the core execution and streaming paths (Gemini model streaming, LlmAgent steps, and Runner execution). Without this, long-running operations or streaming sessions could not be cancelled gracefully by clients (like gemini-cli), potentially leading to resource leaks or unhandled rejections during cancellation attempts.

Solution:
Added and verified abort handling via AbortSignal in the key components:

  • Gemini (core/test/models/google_llm_test.ts): Added tests to verify that abortSignal is passed to generateContentStream and that it handles abortion correctly.
  • LlmAgent (core/test/agents/llm_agent_test.ts): Added a test to verify that execution stops when the signal is aborted between steps.
  • Runner (core/test/runner/streaming_runner_test.ts): Added tests to verify runAsync respects the abort signal generally and specifically during asynchronous tool execution.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Summary of passed npm test results:

  • core/test/runner/streaming_runner_test.ts passed with 13 tests.
  • Tests in llm_agent_test.ts and google_llm_test.ts were also verified to contain the new abort logic

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

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.

2 participants