Dismatch between adk api and compose api
Describe the bug
For Stateful Interrupt in adk API,
event := adk.StatefulInterrupt(ctx, result, struct{}{})
// StatefulInterrupt creates an interrupt action that also saves the agent's internal state. // This is used when an agent has internal state that must be restored for it to continue correctly. // Theinfoparameter is user-facing data describing the interrupt. // Thestate` parameter is the agent's internal state object, which will be serialized and stored.
func StatefulInterrupt(ctx context.Context, info any, state any) *AgentEvent {
is, err := core.Interrupt(ctx, info, state, nil,
core.WithLayerPayload(getRunCtx(ctx).RunPath))
if err != nil {
return &AgentEvent{Err: err}
}
return &AgentEvent{
Action: &AgentAction{
Interrupted: &InterruptInfo{},
internalInterrupted: is,
},
}
} `
the info param (user-facing information) is hidden in is (the return value of core.Interrupt) instead of Intterupted field, which causes the info not available in the returning action.
For compose.StatefulInterrupt, we can get the info from the returning value.
To Reproduce
Run
event := adk.StatefulInterrupt(ctx, result, struct{}{})
and try to get InterruptContexts from the action
Expected behavior
pur proper data and context slice into the returning Interrupt Action in adk.StatefulInterrupt
Screenshots
Version:
github.com/cloudwego/eino v0.7.0
Environment:
Additional context
Add any other context about the problem here.
Have you used the adk.Runner to launch your Agent? If you want to use interrupt/resume, you have to use the adk.Runner instead of run the Agent directly.
Yes I did. That's why I want to switch from compose.StatefulInterrupt to adk.StatefulInterrupt cause I use adk.Runner where I though would be better to align with adk level support. And eventually fallback to compose API as issues from above.
As you can see in the code we are returning a empty &InterruptInfo{} instead of anything useful.
Could you elaborate on how exactly you used adk.StatefulInterrupt in your code?
`func (r ReviewAgent) Run(ctx context.Context, input *adk.AgentInput, options ...adk.AgentRunOption) *adk.AsyncIterator[*adk.AgentEvent] { iter, gen := adk.NewAsyncIteratorPair*adk.AgentEvent
go func() {
defer gen.Close()
contentToReview, ok := adk.GetSessionValue(ctx, "content_to_review")
if !ok {
event := &adk.AgentEvent{
Err: errors.New("content_to_review not found in session"),
}
gen.Send(event)
return
}
feInfo := &FeedbackInfo{
OriginalContent: contentToReview.(string),
}
event := adk.StatefulInterrupt(ctx, feInfo, contentToReview.(string))
if event.Action != nil {
// retrieve tool execution result from interrupt context
if event.Action.Interrupted != nil {
contexts := event.Action.Interrupted.InterruptContexts
if len(contexts) == 0 {
fmt.Println("no interrupt context")
}
}
}
gen.Send(event)
}()
return iter
}`
here is how the eino-examples use adk.StatefulInterrupt, and I added some log to it. the output: ` name: WriterAgent path: [{Writer MultiAgent} {WriterAgent}] answer: <|begin_of_box|>Earth's hidden gem, Brown and rough, Simple, enough.<|end_of_box|>
no interrupt context name: ReviewerAgent path: [{Writer MultiAgent} {WriterAgent} {ReviewerAgent}] Original content to review: `
<|begin_of_box|>Earth's hidden gem, Brown and rough, Simple, enough.<|end_of_box|> `.
If you think the content is good as it is, please reply with "No need to edit". Otherwise, please provide your feedback.
your input here: `
I think i'm supposed to get
feInfo := &FeedbackInfo{ OriginalContent: contentToReview.(string), }
from the interrupt context
why do you emit the interrupt event using StatefulInterrupt and immediately read the event? This event is supposed to be used by end-user through the iterator returned by adk.Runner
ohh i see, i will close the issue