Files
archie/internal/app/archiegateway/toolsummary.go
T
sam fa58050281 refactor(archiegateway): own package for the Gateway service
archie-gateway no longer links the daemon, the web UI or archied. Shared
runtime layering, watches, catalog, NATS discovery and the State Store client
live in servicekit; chat task profiles in chattask. The Gateway waits for the
daemon's NATS endpoint instead of starting a second broker, and chat
approvals go through the task-action client instead of a local service with
no daemon behind it. Version stamping uses buildinfo only.
2026-10-04 00:59:02 +10:00

37 lines
964 B
Go

package archiegateway
import (
"slices"
"strings"
aicore "github.com/samcharles93/ai-sdk/core"
"github.com/samcharles93/archie-core/internal/gateway"
)
// toolSummaries converts the toolset handed to the model into the capability
// metadata advertised in its system prompt, so the two can never disagree.
//
// core.ToolSet is a map, so the result is sorted by name: an unstable tool
// order would change the system prompt on every turn and defeat provider-side
// prompt caching.
func toolSummaries(set aicore.ToolSet) []gateway.ToolSummary {
summaries := make([]gateway.ToolSummary, 0, len(set))
for name, tool := range set {
if tool == nil {
continue
}
summaries = append(summaries, gateway.ToolSummary{
Name: name,
Description: tool.Description,
})
}
if len(summaries) == 0 {
return nil
}
slices.SortFunc(summaries, func(a, b gateway.ToolSummary) int {
return strings.Compare(a.Name, b.Name)
})
return summaries
}