Skip to content

feat(agent): add AbstractInterruptableModelHook base class#4529

Open
Riaehtnipu wants to merge 1 commit intoalibaba:mainfrom
Riaehtnipu:feat_add_AbstractInterruptableModelHook
Open

feat(agent): add AbstractInterruptableModelHook base class#4529
Riaehtnipu wants to merge 1 commit intoalibaba:mainfrom
Riaehtnipu:feat_add_AbstractInterruptableModelHook

Conversation

@Riaehtnipu
Copy link
Copy Markdown

Register hooks of type AbstractInterruptableModelHook as full nodes in the ReactAgent initialization logic.
Supports hook registration at both beforeModel and afterModel stages.

Describe what this PR does / why we need it

Add AbstractInterruptableModelHook, a base class for model hooks that require full node-level interruptibility. Previously, ModelHook implementations were registered as method references in the graph, which limited their
ability to leverage graph-level interrupt mechanisms. This base class implements both AsyncNodeActionWithConfig and InterruptableAction, enabling such hooks to be registered as full graph nodes with proper interrupt support.

Does this pull request fix one issue?

NONE

Describe how you did it

  1. Created AbstractInterruptableModelHook extending ModelHook and implementing AsyncNodeActionWithConfig and InterruptableAction.
  2. Updated ReactAgent.initGraph() to detect AbstractInterruptableModelHook instances and register them directly as graph nodes, for both beforeModel and afterModel hook stages, instead of wrapping them as method references.

Describe how to verify it

  1. Create a concrete subclass of AbstractInterruptableModelHook and add it to a ReactAgent via the hook configuration.
  2. Verify the hook is invoked at the expected stage (beforeModel or afterModel) and that graph-level interruption works correctly when triggered by the hook.
  3. Run existing tests: ./mvnw -pl :spring-ai-alibaba-agent-framework test

Special notes for reviews

  • The AbstractInterruptableModelHook check is placed before the existing InterruptionHook / HumanInTheLoopHook / generic ModelHook checks, giving it higher priority in the registration logic.
  • Import statements in ReactAgent.java were consolidated into wildcard imports as part of this change.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 9, 2026

CLA assistant check
All committers have signed the CLA.

@Riaehtnipu Riaehtnipu force-pushed the feat_add_AbstractInterruptableModelHook branch from 3affe23 to 2f98ac9 Compare April 9, 2026 12:46
Register hooks of type AbstractInterruptableModelHook as full nodes
in the ReactAgent initialization logic.
Supports hook registration at both beforeModel and afterModel stages.
@Riaehtnipu Riaehtnipu force-pushed the feat_add_AbstractInterruptableModelHook branch from 2f98ac9 to 59121a2 Compare April 9, 2026 12:48
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