Skip to content
Merged
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
20 changes: 2 additions & 18 deletions go/cli/internal/tui/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/kagent-dev/kagent/go/cli/internal/tui/theme"
"github.com/kagent-dev/kagent/go/pkg/utils"
"github.com/muesli/reflow/wordwrap"
"trpc.group/trpc-go/trpc-a2a-go/protocol"
)
Expand Down Expand Up @@ -334,7 +335,7 @@ func (m *chatModel) handleMessageParts(msg protocol.Message, shouldDisplay bool)
continue
}

typeVal, found := getMetadataValue(dp.Metadata, "type")
typeVal, found := utils.GetMetadataValue(dp.Metadata, "type")
if !found {
continue
}
Expand Down Expand Up @@ -501,23 +502,6 @@ func (m *chatModel) updateStatus() {
}
}

// getMetadataValue looks up an unprefixed key in A2A metadata, checking
// "adk_<key>" first then falling back to "kagent_<key>". This allows
// interoperability with upstream ADK (adk_ prefix) while preserving
// backward-compatibility with kagent's own kagent_ prefix.
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
}

// getString safely extracts a string value from a map
func getString(m map[string]any, key string) string {
if val, ok := m[key]; ok {
Expand Down
18 changes: 18 additions & 0 deletions go/pkg/utils/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package utils

// GetMetadataValue looks up an unprefixed key in A2A metadata, checking
// "adk_<key>" first then falling back to "kagent_<key>". This allows
// interoperability with upstream ADK (adk_ prefix) while preserving
// backward-compatibility with kagent's own kagent_ prefix.
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
}
Comment on lines +7 to +18
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copilot uses AI. Check for mistakes.
Loading