From 44e0085eaee983931dced800262d82a2982a6426 Mon Sep 17 00:00:00 2001 From: "shentong.martin" Date: Tue, 20 Jan 2026 10:26:02 +0800 Subject: [PATCH] refactor: use tool package interrupt APIs in follow_up_tool and review_edit_wrapper - follow_up_tool.go: use tool.GetInterruptState, tool.GetResumeContext, tool.StatefulInterrupt - review_edit_wrapper.go: use tool.GetInterruptState, tool.GetResumeContext, tool.StatefulInterrupt - Remove ToolCallID from ReviewEditInfo (compose.GetToolCallID no longer used) - Remove compose import from both files Change-Id: I9fee8a8ef93a5b3eab4700c0850f6dce220e5f98 --- adk/common/tool/follow_up_tool.go | 13 ++++--------- adk/common/tool/review_edit_wrapper.go | 16 ++++++---------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/adk/common/tool/follow_up_tool.go b/adk/common/tool/follow_up_tool.go index c1496b1..bc6f292 100644 --- a/adk/common/tool/follow_up_tool.go +++ b/adk/common/tool/follow_up_tool.go @@ -24,7 +24,6 @@ import ( "github.com/cloudwego/eino/components/tool" "github.com/cloudwego/eino/components/tool/utils" - "github.com/cloudwego/eino/compose" "github.com/cloudwego/eino/schema" ) @@ -59,30 +58,26 @@ func init() { } func FollowUp(ctx context.Context, input *FollowUpToolInput) (string, error) { - wasInterrupted, _, storedState := compose.GetInterruptState[*FollowUpState](ctx) + wasInterrupted, _, storedState := tool.GetInterruptState[*FollowUpState](ctx) if !wasInterrupted { - // First invocation: parse input, create info/state, and interrupt. info := &FollowUpInfo{Questions: input.Questions} state := &FollowUpState{Questions: input.Questions} - return "", compose.StatefulInterrupt(ctx, info, state) + return "", tool.StatefulInterrupt(ctx, info, state) } - // Resume flow: check if we are the target and get the user's answer. - isResumeTarget, hasData, resumeData := compose.GetResumeContext[*FollowUpInfo](ctx) + isResumeTarget, hasData, resumeData := tool.GetResumeContext[*FollowUpInfo](ctx) if !isResumeTarget { - // Not for us. Re-interrupt with the same questions from the stored state. info := &FollowUpInfo{Questions: storedState.Questions} - return "", compose.StatefulInterrupt(ctx, info, storedState) + return "", tool.StatefulInterrupt(ctx, info, storedState) } if !hasData || resumeData.UserAnswer == "" { return "", fmt.Errorf("tool resumed without a user answer") } - // Success. The tool's output is the user's answer. return resumeData.UserAnswer, nil } diff --git a/adk/common/tool/review_edit_wrapper.go b/adk/common/tool/review_edit_wrapper.go index f2b673d..a974056 100644 --- a/adk/common/tool/review_edit_wrapper.go +++ b/adk/common/tool/review_edit_wrapper.go @@ -21,7 +21,6 @@ import ( "fmt" "github.com/cloudwego/eino/components/tool" - "github.com/cloudwego/eino/compose" "github.com/cloudwego/eino/schema" ) @@ -29,7 +28,6 @@ import ( type ReviewEditInfo struct { ToolName string ArgumentsInJSON string - ToolCallID string ReviewResult *ReviewEditResult } @@ -69,21 +67,19 @@ func (i InvokableReviewEditTool) InvokableRun(ctx context.Context, argumentsInJS return "", err } - wasInterrupted, _, storedArguments := compose.GetInterruptState[string](ctx) - if !wasInterrupted { // Initial invocation, interrupt for review. - return "", compose.StatefulInterrupt(ctx, &ReviewEditInfo{ + wasInterrupted, _, storedArguments := tool.GetInterruptState[string](ctx) + if !wasInterrupted { + return "", tool.StatefulInterrupt(ctx, &ReviewEditInfo{ ToolName: toolInfo.Name, ArgumentsInJSON: argumentsInJSON, - ToolCallID: compose.GetToolCallID(ctx), }, argumentsInJSON) } - isResumeTarget, hasData, data := compose.GetResumeContext[*ReviewEditInfo](ctx) - if !isResumeTarget { // Not for us, re-interrupt. - return "", compose.StatefulInterrupt(ctx, &ReviewEditInfo{ + isResumeTarget, hasData, data := tool.GetResumeContext[*ReviewEditInfo](ctx) + if !isResumeTarget { + return "", tool.StatefulInterrupt(ctx, &ReviewEditInfo{ ToolName: toolInfo.Name, ArgumentsInJSON: storedArguments, - ToolCallID: compose.GetToolCallID(ctx), }, storedArguments) } if !hasData || data.ReviewResult == nil {