feat(llm): trace model and tool calls via ai-sdk v0.5.0

This commit is contained in:
sam committed 2026-10-25 23:19:40 +11:00
1 parent 8524c38892
commit 18101af821
5 files changed
+30 -14

No files matched your search

+9 -1
View File
@@ -1,9 +1,11 @@
package modelloop
import (
"net/http"
"strings"
"github.com/samcharles93/ai-sdk/runtime"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/domain/agentrun"
@@ -20,6 +22,12 @@ func NewRuntime(providers map[string]agentrun.Provider, limits map[string]config
// NewRuntimeWithKeys binds host-resolved credentials to one runtime without
// exporting them into the process environment or the task protocol.
func NewRuntimeWithKeys(providers map[string]agentrun.Provider, limits map[string]config.ModelLimits, keys map[string]string) *runtime.Runtime {
return NewRuntimeOver(nil, providers, limits, keys)
}
// NewRuntimeOver is NewRuntimeWithKeys with base carrying the provider
// requests, traced; nil means http.DefaultTransport.
func NewRuntimeOver(base http.RoundTripper, providers map[string]agentrun.Provider, limits map[string]config.ModelLimits, keys map[string]string) *runtime.Runtime {
if len(providers) == 0 {
return nil
}
@@ -36,7 +44,7 @@ func NewRuntimeWithKeys(providers map[string]agentrun.Provider, limits map[strin
}
catalog[name] = cfg
}
return runtime.NewRuntime(runtime.Config{Providers: catalog})
return runtime.NewRuntime(runtime.Config{Providers: catalog, HTTPTransport: otelhttp.NewTransport(base)})
}
func reasoningModels(provider string, limits map[string]config.ModelLimits) []runtime.ModelConfig {