[Bug] schema: converting a tool search result part drops Extra
Describe the bug
convToolOutputPartToMessageInputPart (schema/tool.go), used by (*ToolResult).ToMessageInputParts(), copies ToolOutputPart.Extra into MessageInputPart.Extra for text, image, audio, video and file parts. The ToolPartTypeToolSearchResult branch does not:
return MessageInputPart{
Type: ChatMessagePartTypeToolSearchResult,
ToolSearchResult: toolPart.ToolSearchResult,
}ToolSearchResult itself is kept. Only the part-level Extra map is dropped. ToolOutputPart.Extra is documented as extra information for the part, with no exception for tool search. The branch was added in the same commit as the other five (aa0586e), which all set Extra: toolPart.Extra.
To Reproduce
extra := map[string]any{"k": "v"}
tr := &schema.ToolResult{Parts: []schema.ToolOutputPart{{
Type: schema.ToolPartTypeToolSearchResult,
ToolSearchResult: &schema.ToolSearchResult{Tools: []*schema.ToolInfo{{Name: "get_weather"}}},
Extra: extra,
}}}
parts, _ := tr.ToMessageInputParts()
fmt.Println(parts[0].Extra) // nil, want map[k:v]A text part in the same call keeps Extra. On alpha/10 @ 6fc7859 the tool search part's Extra is nil.
The in-tree tool_search tool does not set Extra today, so that path does not lose data. ToMessageInputParts is used when a tool result becomes a message (compose ToolsNode, adk enhanced tool results, react agent). Metadata a caller attaches to a tool search part is removed there. Message.Extra (message id, tool-search reminder) is a different field and is unaffected.
Expected behavior
Extra is kept for tool search result parts, like the other part types.
Version:
alpha/10 @ 6fc7859 (schema/tool.go ToolPartTypeToolSearchResult branch).
Source: cloudwego/eino