expose function to get kagent / adk metadata#1339
Conversation
Signed-off-by: Jet Chiang <pokyuen.jetchiang-ext@solo.io>
There was a problem hiding this comment.
Pull request overview
This pull request extracts a previously private function getMetadataValue from the chat TUI component and exposes it as a public utility function GetMetadataValue in a new go/pkg/utils package. This refactoring enables code reuse across the codebase for handling A2A metadata lookups that support both the adk_ and kagent_ prefixes for backward compatibility.
Changes:
- Created new
go/pkg/utilspackage withGetMetadataValuefunction for looking up metadata values with prefix fallback - Removed private
getMetadataValuefunction from chat.go and updated usage to reference the new public utility
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| go/pkg/utils/utils.go | New utility package containing GetMetadataValue function for A2A metadata lookups with adk_/kagent_ prefix support |
| go/cli/internal/tui/chat.go | Removed duplicate getMetadataValue function and updated to use utils.GetMetadataValue |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func GetMetadataValue(metadata map[string]any, key string) (any, bool) { | ||
| if metadata == nil { | ||
| return nil, false | ||
| } | ||
| if v, ok := metadata["adk_"+key]; ok { | ||
| return v, true | ||
| } | ||
| if v, ok := metadata["kagent_"+key]; ok { | ||
| return v, true | ||
| } | ||
| return nil, false | ||
| } |
There was a problem hiding this comment.
The GetMetadataValue function lacks test coverage. Given that other packages in go/pkg/ (like adk and app) have comprehensive test files, this package should follow the same convention. Consider adding a utils_test.go file with test cases covering:
- Nil metadata map
- Key found with adk_ prefix
- Key found with kagent_ prefix (fallback)
- Key not found with either prefix
- Priority when both prefixes exist (adk_ should take precedence)
No description provided.