Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions go/adk/pkg/memory/kagent_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,11 @@ func (s *KagentMemoryService) extractSessionContent(session adksession.Session)
// Get text content
text := part.Text
if text == "" && part.FunctionResponse != nil {
// TODO: Extract content from function response if needed
continue
responseJSON, err := json.Marshal(part.FunctionResponse.Response)
if err != nil || len(responseJSON) == 0 {
continue
}
text = fmt.Sprintf("[tool result from %s]: %s", part.FunctionResponse.Name, responseJSON)
}

if text != "" {
Expand Down
18 changes: 18 additions & 0 deletions go/adk/pkg/memory/kagent_service_grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ func TestKagentMemoryServiceExtractSessionContent(t *testing.T) {
name: "function call only",
events: []*adksession.Event{newMockEventWithFunctionCall("agent", "get_weather")},
},
{
name: "function response is extracted",
events: []*adksession.Event{
newMockEventWithFunctionResponse("agent", "get_weather", map[string]any{"temperature": 72, "condition": "sunny"}),
},
wantContent: `"condition":"sunny"`,
},
}

for _, test := range tests {
Expand Down Expand Up @@ -378,3 +385,14 @@ func newMockEventWithFunctionCall(author, functionName string) *adksession.Event
event.Content = &genai.Content{Role: author, Parts: []*genai.Part{{FunctionCall: &genai.FunctionCall{Name: functionName}}}}
return event
}

func newMockEventWithFunctionResponse(author, functionName string, response map[string]any) *adksession.Event {
event := newMockEvent(author, "")
event.Content = &genai.Content{
Role: author,
Parts: []*genai.Part{{
FunctionResponse: &genai.FunctionResponse{Name: functionName, Response: response},
}},
}
return event
}
Loading