From ab49ae58d9c5cffc29162ade02cfa621316e11ca Mon Sep 17 00:00:00 2001 From: Eitan Yarmush Date: Tue, 13 Oct 2026 10:57:31 +0000 Subject: [PATCH 1/5] refactor: simplify config parsing and compiler inputs Signed-off-by: Eitan Yarmush --- docs/architecture/process-configuration.md | 29 ++++- go/api/gen/kagent/api/v1alpha1/config.pb.go | 20 ++-- go/core/internal/controller/collections.go | 5 +- .../internal/controller/collections_test.go | 22 ++-- .../internal/controller/preparation_test.go | 2 +- go/core/internal/controller/reconciler.go | 6 +- go/core/internal/controller/runtime.go | 5 +- go/core/internal/translator/byo/compiler.go | 14 ++- .../internal/translator/byo/compiler_test.go | 26 ++--- .../internal/translator/claude/compiler.go | 18 +-- .../translator/claude/compiler_test.go | 51 +++++---- go/core/internal/translator/codex/compiler.go | 18 +-- .../translator/codex/compiler_test.go | 31 ++--- go/core/internal/translator/compiler_test.go | 15 +-- .../translator/kagent/agentcard_test.go | 7 +- .../internal/translator/kagent/compiler.go | 14 ++- go/core/internal/translator/otel_test.go | 69 ++++++------ go/core/internal/translator/settings.go | 52 ++------- go/core/pkg/app/app.go | 9 +- go/core/pkg/app/app_test.go | 2 +- go/core/pkg/config/defaults.go | 32 +++++- go/core/pkg/config/load.go | 106 ++---------------- go/core/pkg/config/load_test.go | 69 +++++++++++- proto/kagent/api/v1alpha1/config.proto | 4 +- .../kagent/api/v1alpha1/config_pb.ts | 6 +- 25 files changed, 315 insertions(+), 317 deletions(-) diff --git a/docs/architecture/process-configuration.md b/docs/architecture/process-configuration.md index 937439e8dc..a7d0b71529 100644 --- a/docs/architecture/process-configuration.md +++ b/docs/architecture/process-configuration.md @@ -104,10 +104,31 @@ Push JWT signing is optional: `gateway.push.signingPrivateKeyFile` names an unencrypted PKCS#8 Ed25519 PEM key when enabled. Helm projects the operator-managed Secret selected by `controller.push.signing.secretName`. -Durations use protobuf JSON notation: `60s`, `0.5s`, or `0s`. Unknown fields, -duplicate keys, nulls, YAML aliases/merges, and multiple documents are rejected. -Defaults preserve explicit false and zero values. Zero disables session idle -expiration and leaves share TTL unbounded; nonzero intervals must be positive. +Config files use `sigs.k8s.io/yaml.YAMLToJSONStrict` followed by Go's +`protojson.Unmarshal`. Protovalidate checks the schema after command-line overrides +and application defaults are applied. Parsing follows those libraries: + +- Duplicate keys and unknown protobuf fields are rejected. Supplying both the + camelCase and snake_case names of the same protobuf field is also rejected. +- YAML 1.1 scalar rules apply: unquoted `yes`, `no`, `on`, and `off` are booleans; + quote them when a string is intended. YAML numeric forms such as `0x10` are + converted to numbers, and numeric mapping keys become strings. +- YAML anchors, aliases, and merge keys are resolved by the YAML library. Strict + mode rejects duplicate keys, including an explicit override of a merged key. +- Only the first YAML document is read; subsequent documents are ignored. +- ProtoJSON accepts quoted integers for integer fields, but a quoted boolean is + a string and fails boolean decoding. Durations use `60s`, `0.5s`, or `0s`. +- Field `null` means unset; it does not disable a setting. Null list elements are + rejected. An explicitly empty string is validated against the field's schema. + +Defaults follow protobuf presence. Ordinary scalars use their protobuf zero value; +for example, omitted and explicit zero `database.pool.minConns` both mean zero. +Optional scalars and message fields distinguish omission from an explicit value: +`kubernetes.leaderElection` defaults to true but accepts false, `sessions.idleTtl` +defaults to seven days but `0s` disables expiration, and omitted +`runtimeDefaults.maxContentLength` selects the runtime limit while zero disables +that limit. Session shares have no TTL bound by default; nonzero intervals must +be positive. Helm's top-level `config` block mirrors the schema and includes both controller settings and managed runtime defaults. The chart writes one config file, diff --git a/go/api/gen/kagent/api/v1alpha1/config.pb.go b/go/api/gen/kagent/api/v1alpha1/config.pb.go index b4284b2418..64665000fe 100644 --- a/go/api/gen/kagent/api/v1alpha1/config.pb.go +++ b/go/api/gen/kagent/api/v1alpha1/config.pb.go @@ -972,7 +972,7 @@ func (x *DatabaseLoginConfig) GetRole() string { type PostgresPoolConfig struct { state protoimpl.MessageState `protogen:"open.v1"` - MinConns *int32 `protobuf:"varint,1,opt,name=min_conns,json=minConns,proto3,oneof" json:"min_conns,omitempty"` + MinConns int32 `protobuf:"varint,1,opt,name=min_conns,json=minConns,proto3" json:"min_conns,omitempty"` MaxConns *int32 `protobuf:"varint,2,opt,name=max_conns,json=maxConns,proto3,oneof" json:"max_conns,omitempty"` MaxConnIdleTime *durationpb.Duration `protobuf:"bytes,3,opt,name=max_conn_idle_time,json=maxConnIdleTime,proto3" json:"max_conn_idle_time,omitempty"` MaxConnLifetime *durationpb.Duration `protobuf:"bytes,4,opt,name=max_conn_lifetime,json=maxConnLifetime,proto3" json:"max_conn_lifetime,omitempty"` @@ -1011,8 +1011,8 @@ func (*PostgresPoolConfig) Descriptor() ([]byte, []int) { } func (x *PostgresPoolConfig) GetMinConns() int32 { - if x != nil && x.MinConns != nil { - return *x.MinConns + if x != nil { + return x.MinConns } return 0 } @@ -1970,17 +1970,15 @@ const file_kagent_api_v1alpha1_config_proto_rawDesc = "" + "\x0e_vector_schema\"D\n" + "\x13DatabaseLoginConfig\x12\x19\n" + "\burl_file\x18\x01 \x01(\tR\aurlFile\x12\x12\n" + - "\x04role\x18\x02 \x01(\tR\x04role\"\xd0\x03\n" + - "\x12PostgresPoolConfig\x12)\n" + - "\tmin_conns\x18\x01 \x01(\x05B\a\xbaH\x04\x1a\x02(\x00H\x00R\bminConns\x88\x01\x01\x12)\n" + - "\tmax_conns\x18\x02 \x01(\x05B\a\xbaH\x04\x1a\x02 \x00H\x01R\bmaxConns\x88\x01\x01\x12X\n" + + "\x04role\x18\x02 \x01(\tR\x04role\"\xa2\x03\n" + + "\x12PostgresPoolConfig\x12$\n" + + "\tmin_conns\x18\x01 \x01(\x05B\a\xbaH\x04\x1a\x02(\x00R\bminConns\x12)\n" + + "\tmax_conns\x18\x02 \x01(\x05B\a\xbaH\x04\x1a\x02 \x00H\x00R\bmaxConns\x88\x01\x01\x12X\n" + "\x12max_conn_idle_time\x18\x03 \x01(\v2\x19.google.protobuf.DurationB\x10\xbaH\r\xaa\x01\n" + "\"\x06\b\x84\xfa\x85\xae\"*\x00R\x0fmaxConnIdleTime\x12W\n" + "\x11max_conn_lifetime\x18\x04 \x01(\v2\x19.google.protobuf.DurationB\x10\xbaH\r\xaa\x01\n" + - "\"\x06\b\x84\xfa\x85\xae\"*\x00R\x0fmaxConnLifetime:\x94\x01\xbaH\x90\x01\x1a\x8d\x01\n" + - "\x14postgres_pool.bounds\x12#min_conns must not exceed max_conns\x1aP!has(this.min_conns) || !has(this.max_conns) || this.min_conns <= this.max_connsB\f\n" + - "\n" + - "_min_connsB\f\n" + + "\"\x06\b\x84\xfa\x85\xae\"*\x00R\x0fmaxConnLifetime:z\xbaHw\x1au\n" + + "\x14postgres_pool.bounds\x12#min_conns must not exceed max_conns\x1a8!has(this.max_conns) || this.min_conns <= this.max_connsB\f\n" + "\n" + "_max_conns\"\xe6\x01\n" + "\x0fSubstrateConfig\x12/\n" + diff --git a/go/core/internal/controller/collections.go b/go/core/internal/controller/collections.go index 52f638ad1c..f096e7e566 100644 --- a/go/core/internal/controller/collections.go +++ b/go/core/internal/controller/collections.go @@ -12,6 +12,7 @@ import ( "istio.io/istio/pkg/kube/krt" corev1 "k8s.io/api/core/v1" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" kagentv1alpha3 "github.com/kagent-dev/kagent/go/api/v1alpha3" "github.com/kagent-dev/kagent/go/core/internal/translator" ) @@ -61,7 +62,7 @@ func (p AgentRuntimeObservation) Equals(other AgentRuntimeObservation) bool { // NewCollections creates the complete read-only input graph. An empty // watchNamespaces list watches all namespaces. -func NewCollections(client kube.Client, watchNamespaces []string, opts krt.OptionsBuilder, settings translator.CompilerSettings) Collections { +func NewCollections(client kube.Client, watchNamespaces []string, opts krt.OptionsBuilder, settings *apiv1.RuntimeDefaultsConfig, images translator.BuiltinImages) Collections { sandboxTemplates := typedCollection[*kagentv1alpha3.SandboxTemplate](client, watchNamespaces, "SandboxTemplates", opts) agents := typedCollection[*kagentv1alpha3.Agent](client, watchNamespaces, "Agents", opts) agentTemplates := typedCollection[*kagentv1alpha3.AgentTemplate](client, watchNamespaces, "AgentTemplates", opts) @@ -77,7 +78,7 @@ func NewCollections(client kube.Client, watchNamespaces []string, opts krt.Optio Harnesses: harnesses, AgentTemplates: agentTemplates, ResolvedModelConfigs: resolvedModelConfigs, RemoteMCPServers: remoteMCPServers, ConfigMaps: configMaps, Secrets: secrets, WorkerPools: workerPools, } - reconciliations := newAgentReconciliations(agents, compilerCollections, agentRuntimeObservations, opts, settings) + reconciliations := newAgentReconciliations(agents, compilerCollections, agentRuntimeObservations, opts, settings, images) statuses := newAgentStatuses(agents, reconciliations, opts) return Collections{ diff --git a/go/core/internal/controller/collections_test.go b/go/core/internal/controller/collections_test.go index 9ee4b6c557..5bf58bcdcd 100644 --- a/go/core/internal/controller/collections_test.go +++ b/go/core/internal/controller/collections_test.go @@ -15,7 +15,7 @@ import ( apimeta "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/kagent-dev/kagent/go/api/adk" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" kagentv1alpha3 "github.com/kagent-dev/kagent/go/api/v1alpha3" "github.com/kagent-dev/kagent/go/core/internal/translator" ) @@ -64,7 +64,7 @@ func TestReconciliationCollectionsCompileAndObserveRevision(t *testing.T) { Harnesses: collections.Harnesses, AgentTemplates: collections.AgentTemplates, ResolvedModelConfigs: collections.ResolvedModelConfigs, RemoteMCPServers: collections.RemoteMCPServers, ConfigMaps: collections.ConfigMaps, Secrets: collections.Secrets, WorkerPools: collections.WorkerPools, - }, collections.AgentRuntimeObservations, opts, testCompilerSettings(), + }, collections.AgentRuntimeObservations, opts, testRuntimeDefaults(), translator.BuiltinImages{}, ) collections.AgentStatuses = newAgentStatuses(collections.Agents, collections.Reconciliations, opts) @@ -152,15 +152,15 @@ func TestReconciliationReportsRuntimeValidationAsUnsupported(t *testing.T) { }) configMaps, secrets := krttest.GetMockCollection[*corev1.ConfigMap](mock), krttest.GetMockCollection[*corev1.Secret](mock) _, resolvedModels := newModelConfigReconciliations(krttest.GetMockCollection[*kagentv1alpha3.ModelConfig](mock), configMaps, secrets, opts) - settings := testCompilerSettings() - settings.Process = &adk.RuntimeConfig{MaxContentLength: new(int64(-1))} + settings := testRuntimeDefaults() + settings.MaxContentLength = new(int64(-1)) states := newAgentReconciliations( krt.NewStaticCollection(nil, []*kagentv1alpha3.Agent{testAgent(template, runtimeHarness)}, opts.WithName("Agents")...), translator.Collections{ Harnesses: krttest.GetMockCollection[*kagentv1alpha3.Harness](mock), AgentTemplates: krttest.GetMockCollection[*kagentv1alpha3.AgentTemplate](mock), ResolvedModelConfigs: resolvedModels, ConfigMaps: configMaps, Secrets: secrets, RemoteMCPServers: krttest.GetMockCollection[*kagentv1alpha3.RemoteMCPServer](mock), WorkerPools: krttest.GetMockCollection[*atev1alpha1.WorkerPool](mock), - }, krt.NewStaticCollection[AgentRuntimeObservation](nil, nil, opts.WithName("Observations")...), opts, settings, + }, krt.NewStaticCollection[AgentRuntimeObservation](nil, nil, opts.WithName("Observations")...), opts, settings, translator.BuiltinImages{}, ) waitFor(t, func() bool { return states.GetKey("team-a/assistant") != nil }) state := states.GetKey("team-a/assistant") @@ -230,7 +230,7 @@ func TestReconciliationWorkerPoolSandboxClass(t *testing.T) { Harnesses: krttest.GetMockCollection[*kagentv1alpha3.Harness](mock), AgentTemplates: templates, ResolvedModelConfigs: resolvedModels, RemoteMCPServers: krttest.GetMockCollection[*kagentv1alpha3.RemoteMCPServer](mock), ConfigMaps: configMaps, Secrets: secrets, WorkerPools: workerPools, - }, observations, opts, testCompilerSettings()) + }, observations, opts, testRuntimeDefaults(), translator.BuiltinImages{}) key := "team-a/assistant" waitFor(t, func() bool { state := reconciliations.GetKey(key) @@ -371,7 +371,7 @@ func TestClaudeReconciliationCompilesActorTemplate(t *testing.T) { RemoteMCPServers: krttest.GetMockCollection[*kagentv1alpha3.RemoteMCPServer](mock), ConfigMaps: configMaps, Secrets: secrets, WorkerPools: krttest.GetMockCollection[*atev1alpha1.WorkerPool](mock), - }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testCompilerSettings(), + }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testRuntimeDefaults(), translator.BuiltinImages{}, ) waitFor(t, func() bool { states := reconciliations.List() @@ -427,7 +427,7 @@ func TestCodexReconciliationCompilesActorTemplate(t *testing.T) { RemoteMCPServers: krttest.GetMockCollection[*kagentv1alpha3.RemoteMCPServer](mock), ConfigMaps: configMaps, Secrets: secrets, WorkerPools: krttest.GetMockCollection[*atev1alpha1.WorkerPool](mock), - }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testCompilerSettings(), + }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testRuntimeDefaults(), translator.BuiltinImages{}, ) waitFor(t, func() bool { states := reconciliations.List() @@ -480,7 +480,7 @@ func TestReconciliationTracksSharedAgentTemplate(t *testing.T) { RemoteMCPServers: krttest.GetMockCollection[*kagentv1alpha3.RemoteMCPServer](mock), ConfigMaps: configMaps, Secrets: secrets, WorkerPools: krttest.GetMockCollection[*atev1alpha1.WorkerPool](mock), - }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testCompilerSettings(), + }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testRuntimeDefaults(), translator.BuiltinImages{}, ) var initial string waitFor(t, func() bool { @@ -531,6 +531,6 @@ func testAgent(template *kagentv1alpha3.AgentTemplate, harness *kagentv1alpha3.H }} } -func testCompilerSettings() translator.CompilerSettings { - return translator.CompilerSettings{APIURL: "http://kagent-controller.kagent:8083", GatewayURL: "http://kagent-controller.kagent:8083", LogLevel: "info"} +func testRuntimeDefaults() *apiv1.RuntimeDefaultsConfig { + return &apiv1.RuntimeDefaultsConfig{ControlPlaneUrl: new("http://kagent-controller.kagent:8083"), GatewayUrl: new("http://kagent-controller.kagent:8083"), Logging: &apiv1.LoggingConfig{Level: new("info")}} } diff --git a/go/core/internal/controller/preparation_test.go b/go/core/internal/controller/preparation_test.go index 140da51710..4f55218f1d 100644 --- a/go/core/internal/controller/preparation_test.go +++ b/go/core/internal/controller/preparation_test.go @@ -564,7 +564,7 @@ func newPreparationTestCollections(t *testing.T, workerPool string) (Collections Harnesses: collections.Harnesses, AgentTemplates: collections.AgentTemplates, ResolvedModelConfigs: collections.ResolvedModelConfigs, RemoteMCPServers: collections.RemoteMCPServers, ConfigMaps: collections.ConfigMaps, Secrets: collections.Secrets, WorkerPools: collections.WorkerPools, - }, collections.AgentRuntimeObservations, opts, testCompilerSettings()) + }, collections.AgentRuntimeObservations, opts, testRuntimeDefaults(), translator.BuiltinImages{}) collections.AgentStatuses = newAgentStatuses(collections.Agents, collections.Reconciliations, opts) waitFor(t, func() bool { states := collections.Reconciliations.List() diff --git a/go/core/internal/controller/reconciler.go b/go/core/internal/controller/reconciler.go index ee8d8cb96a..ba832fb910 100644 --- a/go/core/internal/controller/reconciler.go +++ b/go/core/internal/controller/reconciler.go @@ -23,6 +23,7 @@ import ( "k8s.io/client-go/util/workqueue" kagentclient "github.com/kagent-dev/kagent/go/api/clientset/versioned/typed/api/v1alpha3" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" kagentv1alpha3 "github.com/kagent-dev/kagent/go/api/v1alpha3" "github.com/kagent-dev/kagent/go/core/internal/database" "github.com/kagent-dev/kagent/go/core/internal/substrate" @@ -96,7 +97,8 @@ func newAgentReconciliations( collections translator.Collections, agentRuntimeObservations krt.Collection[AgentRuntimeObservation], opts krt.OptionsBuilder, - settings translator.CompilerSettings, + settings *apiv1.RuntimeDefaultsConfig, + images translator.BuiltinImages, ) krt.Collection[AgentReconciliation] { return krt.NewCollection(agents, func(ctx krt.HandlerContext, agent *kagentv1alpha3.Agent) *AgentReconciliation { state := &AgentReconciliation{Agent: agent} @@ -105,7 +107,7 @@ func newAgentReconciliations( translator.HarnessTypeCodex: codextranslator.NewCompiler(ctx, collections, settings), translator.HarnessTypeClaude: claudetranslator.NewCompiler(ctx, collections, settings), translator.HarnessTypeBYO: byotranslator.NewCompiler(ctx, collections, settings), - }, settings.Images).CompileAgent(context.Background(), agent) + }, images).CompileAgent(context.Background(), agent) if err != nil { condition, reason := kagentv1alpha3.AgentConditionResolvedRefs, "ReferenceResolutionFailed" var validation *translator.ValidationError diff --git a/go/core/internal/controller/runtime.go b/go/core/internal/controller/runtime.go index f86ed5d957..0ae55155b7 100644 --- a/go/core/internal/controller/runtime.go +++ b/go/core/internal/controller/runtime.go @@ -8,6 +8,7 @@ import ( "istio.io/istio/pkg/kube/krt" "k8s.io/client-go/rest" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/core/internal/controller/apiclient" "github.com/kagent-dev/kagent/go/core/internal/translator" ) @@ -23,13 +24,13 @@ type Runtime struct { // NewRuntime creates the shared KRT client and collection graph. Handlers are // deliberately registered separately at the eventual application boundary. -func NewRuntime(config *rest.Config, watchNamespaces []string, stop <-chan struct{}, settings translator.CompilerSettings) (*Runtime, error) { +func NewRuntime(config *rest.Config, watchNamespaces []string, stop <-chan struct{}, settings *apiv1.RuntimeDefaultsConfig, images translator.BuiltinImages) (*Runtime, error) { client, err := apiclient.New(config) if err != nil { return nil, fmt.Errorf("create KRT Kubernetes client: %w", err) } options := krt.NewOptionsBuilder(stop, "kagent", krt.GlobalDebugHandler) - collections := NewCollections(client, watchNamespaces, options, settings) + collections := NewCollections(client, watchNamespaces, options, settings, images) return &Runtime{Client: client, Options: options, Collections: collections}, nil } diff --git a/go/core/internal/translator/byo/compiler.go b/go/core/internal/translator/byo/compiler.go index d05731e456..bd339d9f36 100644 --- a/go/core/internal/translator/byo/compiler.go +++ b/go/core/internal/translator/byo/compiler.go @@ -14,6 +14,7 @@ import ( corev1 "k8s.io/api/core/v1" "github.com/kagent-dev/kagent/go/api/adk" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/core/internal/translator" "github.com/kagent-dev/kagent/go/core/internal/translator/adkconfig" "github.com/kagent-dev/kagent/go/pkg/tracing" @@ -22,12 +23,12 @@ import ( // Compiler translates resolved inputs into a BYO A2A runtime revision. type Compiler struct { config *adkconfig.Builder - settings translator.CompilerSettings + settings *apiv1.RuntimeDefaultsConfig } var _ translator.HarnessCompiler = (*Compiler)(nil) -func NewCompiler(ctx krt.HandlerContext, collections translator.Collections, settings translator.CompilerSettings) *Compiler { +func NewCompiler(ctx krt.HandlerContext, collections translator.Collections, settings *apiv1.RuntimeDefaultsConfig) *Compiler { return &Compiler{settings: settings, config: adkconfig.NewBuilder(ctx, collections)} } @@ -38,7 +39,7 @@ func (c *Compiler) Compile(ctx context.Context, input *translator.HarnessInput) } template, harness := input.Root.Template, input.Harness configJSON, err := adk.Marshal(&adk.Config{ - Runtime: c.settings.RuntimeConfig(input.AgentName, template.Namespace), + Runtime: translator.RuntimeConfig(c.settings, input.AgentName, template.Namespace), Agent: compiled.Config, }) if err != nil { @@ -53,7 +54,10 @@ func (c *Compiler) Compile(ctx context.Context, input *translator.HarnessInput) return nil, fmt.Errorf("convert agent card: %w", err) } // An opaque image may export to its own backend, so its own values win. - telemetryConfig := c.settings.Telemetry + telemetryConfig, err := translator.TelemetryConfigFromSettings(c.settings.GetTelemetry()) + if err != nil { + return nil, err + } environment := append([]corev1.EnvVar(nil), compiled.Environment...) environment = append(environment, adkconfig.HarnessEnvironment(harness)...) environment = adkconfig.DedupeEnv(environment) @@ -71,7 +75,7 @@ func (c *Compiler) Compile(ctx context.Context, input *translator.HarnessInput) return nil, err } compiled.Egress = append(compiled.Egress, telemetryConfig.Destinations(environment)...) - compiled.Egress = append(compiled.Egress, c.settings.APIURL) + compiled.Egress = append(compiled.Egress, c.settings.GetControlPlaneUrl()) slices.Sort(compiled.Egress) return &translator.CompileResult{Revision: translator.Revision{ diff --git a/go/core/internal/translator/byo/compiler_test.go b/go/core/internal/translator/byo/compiler_test.go index 1d38f9991d..3ab6a7bb39 100644 --- a/go/core/internal/translator/byo/compiler_test.go +++ b/go/core/internal/translator/byo/compiler_test.go @@ -11,11 +11,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/kagent-dev/kagent/go/api/adk" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/api/v1alpha3" "github.com/kagent-dev/kagent/go/core/internal/substrate" "github.com/kagent-dev/kagent/go/core/internal/translator" - "github.com/kagent-dev/kagent/go/pkg/telemetry" - "github.com/kagent-dev/kagent/go/pkg/tracing" ) func TestCompileOpaqueImage(t *testing.T) { @@ -31,7 +30,7 @@ func TestCompileOpaqueImage(t *testing.T) { Description: "custom A2A agent", SystemPrompt: "be helpful", }} - revision, err := NewCompiler(krt.TestingDummyContext{}, translator.Collections{}, testCompilerSettings()).Compile(context.Background(), &translator.HarnessInput{ + revision, err := NewCompiler(krt.TestingDummyContext{}, translator.Collections{}, testRuntimeDefaults()).Compile(context.Background(), &translator.HarnessInput{ AgentName: "runnable-agent", Harness: harness, Root: &translator.AgentInput{Template: template, Instruction: template.Spec.SystemPrompt}, }) @@ -52,8 +51,8 @@ func TestCompileOpaqueImage(t *testing.T) { } func TestCompileOpaqueImageKeepsItsOwnTelemetry(t *testing.T) { - settings := testCompilerSettings() - settings.Telemetry = translator.TelemetryConfig{Traces: translator.SignalConfig{Enabled: true, Endpoint: "http://collector:4317", Protocol: "grpc"}, Runtime: tracing.RuntimeTelemetry{Exporters: &telemetry.Config{Traces: &telemetry.OTLPConfig{Endpoint: "http://collector:4317", Protocol: "grpc"}}}} + settings := testRuntimeDefaults() + settings.Telemetry = &apiv1.TelemetryConfig{Traces: &apiv1.OTLPConfig{Endpoint: "http://collector:4317", Protocol: new("grpc")}} harness := &translator.HarnessConfiguration{Name: "byo", Namespace: "test", Source: metav1.ObjectMeta{Name: "byo", Namespace: "test"}, Spec: v1alpha3.HarnessSpec{ BYO: &v1alpha3.BYOHarness{}, Workload: v1alpha3.HarnessWorkload{Image: new("example.com/agent@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")}, @@ -82,19 +81,16 @@ func TestCompileOpaqueImageKeepsItsOwnTelemetry(t *testing.T) { require.Contains(t, environment["OTEL_RESOURCE_ATTRIBUTES"], "gen_ai.main_agent.name=runnable-agent") } -func testCompilerSettings() translator.CompilerSettings { - return translator.CompilerSettings{APIURL: "http://kagent-controller.kagent:8083", GatewayURL: "http://kagent-controller.kagent:8083", LogLevel: "info"} +func testRuntimeDefaults() *apiv1.RuntimeDefaultsConfig { + return &apiv1.RuntimeDefaultsConfig{ControlPlaneUrl: new("http://kagent-controller.kagent:8083"), GatewayUrl: new("http://kagent-controller.kagent:8083"), Logging: &apiv1.LoggingConfig{Level: new("info")}} } func TestCompiledTelemetryFitsTheActorEnvironmentBudget(t *testing.T) { - settings := testCompilerSettings() - settings.Telemetry = translator.TelemetryConfig{ - Traces: translator.SignalConfig{Enabled: true}, - Runtime: tracing.RuntimeTelemetry{Exporters: &telemetry.Config{ - Traces: &telemetry.OTLPConfig{Endpoint: "http://collector:4317", Protocol: "grpc"}, - Metrics: &telemetry.OTLPConfig{Endpoint: "http://collector:4317", Protocol: "grpc"}, - Logs: &telemetry.OTLPConfig{Endpoint: "http://collector:4317", Protocol: "grpc"}, - }}, + settings := testRuntimeDefaults() + settings.Telemetry = &apiv1.TelemetryConfig{ + Traces: &apiv1.OTLPConfig{Endpoint: "http://collector:4317", Protocol: new("grpc")}, + Metrics: &apiv1.OTLPConfig{Endpoint: "http://collector:4317", Protocol: new("grpc")}, + Logs: &apiv1.OTLPConfig{Endpoint: "http://collector:4317", Protocol: new("grpc")}, } harness := &translator.HarnessConfiguration{Name: "byo", Namespace: "test", Source: metav1.ObjectMeta{Name: "byo", Namespace: "test"}, Spec: v1alpha3.HarnessSpec{ BYO: &v1alpha3.BYOHarness{}, diff --git a/go/core/internal/translator/claude/compiler.go b/go/core/internal/translator/claude/compiler.go index 7fa1469d9b..9b27c7ba03 100644 --- a/go/core/internal/translator/claude/compiler.go +++ b/go/core/internal/translator/claude/compiler.go @@ -17,6 +17,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/api/v1alpha3" "github.com/kagent-dev/kagent/go/core/internal/egress" "github.com/kagent-dev/kagent/go/core/internal/translator" @@ -25,12 +26,12 @@ import ( ) type Compiler struct { - settings translator.CompilerSettings + settings *apiv1.RuntimeDefaultsConfig ctx krt.HandlerContext collections translator.Collections } -func NewCompiler(ctx krt.HandlerContext, collections translator.Collections, settings translator.CompilerSettings) *Compiler { +func NewCompiler(ctx krt.HandlerContext, collections translator.Collections, settings *apiv1.RuntimeDefaultsConfig) *Compiler { return &Compiler{settings: settings, ctx: ctx, collections: collections} } @@ -45,7 +46,10 @@ func (c *Compiler) Compile(ctx context.Context, input *translator.HarnessInput) if len(model.Spec.DefaultHeaders) != 0 || !model.Spec.TLS.IsEmpty() || model.Spec.APIKeyPassthrough { return nil, translator.NewValidationError("Claude does not support ModelConfig defaultHeaders, TLS, or apiKeyPassthrough yet") } - telemetryConfig := c.settings.Telemetry + telemetryConfig, err := translator.TelemetryConfigFromSettings(c.settings.GetTelemetry()) + if err != nil { + return nil, err + } template, harness := input.Root.Template, input.Harness // The runtime reports this identity on every invocation span and on its // resource, so a user-supplied resource marker is never required. @@ -84,9 +88,9 @@ func (c *Compiler) Compile(ctx context.Context, input *translator.HarnessInput) config := claudeconfig.Production(model.Spec.Model, input.Root.Instruction) config.Agents = localAgents config.RuntimeTelemetry = runtimeTelemetry - config.ControlPlaneURL = c.settings.APIURL - config.MaxContentLength = c.settings.RuntimeConfig(input.AgentName, input.Root.Template.Namespace).MaxContentLength - config.LogLevel = c.settings.LogLevel + config.ControlPlaneURL = c.settings.GetControlPlaneUrl() + config.MaxContentLength = c.settings.MaxContentLength // Preserve unset versus unlimited. + config.LogLevel = c.settings.GetLogging().GetLevel() if len(skillResources.Skills) != 0 || len(skillResources.Plugins) != 0 { config.SkillResources = &skillResources } @@ -114,7 +118,7 @@ func (c *Compiler) Compile(ctx context.Context, input *translator.HarnessInput) egress = append(egress, skillEgress...) egress = append(egress, mcp.egress...) egress = append(egress, telemetryConfig.Destinations(environment)...) - egress = append(egress, c.settings.APIURL) + egress = append(egress, c.settings.GetControlPlaneUrl()) slices.Sort(egress) egress = slices.Compact(egress) return &translator.CompileResult{ diff --git a/go/core/internal/translator/claude/compiler_test.go b/go/core/internal/translator/claude/compiler_test.go index 7ed19492f9..d91ea5d3cb 100644 --- a/go/core/internal/translator/claude/compiler_test.go +++ b/go/core/internal/translator/claude/compiler_test.go @@ -16,11 +16,11 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/api/v1alpha3" "github.com/kagent-dev/kagent/go/core/internal/substrate" "github.com/kagent-dev/kagent/go/core/internal/translator" claudeconfig "github.com/kagent-dev/kagent/go/harness/claude/config" - "github.com/kagent-dev/kagent/go/pkg/telemetry" "github.com/kagent-dev/kagent/go/pkg/tracing" ) @@ -82,7 +82,7 @@ func TestCompileProviderCredentials(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { input, reader := testInput(t, tt.model, tt.secretData) - revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if tt.wantErr != "" { if err == nil || !strings.Contains(err.Error(), tt.wantErr) { t.Fatalf("expected unsupported credential error, got %v", err) @@ -124,7 +124,7 @@ func TestCompileProviderCredentials(t *testing.T) { t.Fatalf("provenance contains gateway-managed Secret: %s", revision.Provenance) } - again, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + again, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil || !reflect.DeepEqual(revision, again) { t.Fatalf("compilation is not deterministic: %v", err) } @@ -151,7 +151,7 @@ func TestCompileRejectsUnsupportedConfiguration(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { input, reader := testInput(t, tt.model, map[string][]byte{"api-key": []byte("secret"), claudeconfig.AWSAccessKeyEnvName: []byte("access"), claudeconfig.AWSSecretKeyEnvName: []byte("secret"), "credentials.json": []byte(`{"type":"service_account"}`)}) - _, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + _, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) var validation *translator.ValidationError if !errors.As(err, &validation) { t.Fatalf("Compile() error = %v, want validation error", err) @@ -168,7 +168,7 @@ func TestCompileRejectsProviderOwnedHarnessEnvironment(t *testing.T) { input, reader := testInput(t, model, map[string][]byte{"api-key": []byte("secret")}) value := "http://mock.example.com" input.Harness.Spec.Env = []v1alpha3.RuntimeEnvVar{{Name: claudeconfig.AnthropicBaseURLEnvName, Value: value}} - _, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + _, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) var validation *translator.ValidationError if !errors.As(err, &validation) { t.Fatalf("Compile() error = %v, want validation error", err) @@ -184,7 +184,7 @@ func TestCompileAllowsRuntimeOTELEndpoint(t *testing.T) { value := "http://other-collector:4317" input.Harness.Spec.Env = []v1alpha3.RuntimeEnvVar{{Name: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", Value: value}} - result, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + result, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatal(err) } @@ -202,7 +202,7 @@ func TestCompileAllowsRuntimeTelemetryOverrides(t *testing.T) { value := "department=engineering" input.Harness.Spec.Env = []v1alpha3.RuntimeEnvVar{{Name: "OTEL_RESOURCE_ATTRIBUTES", Value: value}} - result, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + result, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatal(err) } @@ -227,7 +227,7 @@ func TestCompileRootSkillsAndPluginSelections(t *testing.T) { Skills: []string{"deploy"}, }} - revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatal(err) } @@ -245,7 +245,7 @@ func TestCompileRootSkillsAndPluginSelections(t *testing.T) { } input.Root.Template.Spec.Plugins[0].Skills = []string{"review"} - if _, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input); err == nil || !strings.Contains(err.Error(), "duplicate skill name") { + if _, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input); err == nil || !strings.Contains(err.Error(), "duplicate skill name") { t.Fatalf("duplicate skill Compile() error = %v", err) } } @@ -279,7 +279,7 @@ func TestCompileDirectWholeServerMCP(t *testing.T) { }}} input.Root.MCPTools = []translator.ResolvedMCPTool{{Binding: *input.Root.Template.Spec.Tools[0].MCP.DeepCopy(), Server: server}} - revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatal(err) } @@ -330,7 +330,7 @@ func TestCompileWholeServerMCPSelectionWarnings(t *testing.T) { } binding := v1alpha3.MCPToolBinding{Server: corev1.TypedLocalObjectReference{Kind: "RemoteMCPServer", Name: server.Name}} input.Root.MCPTools = []translator.ResolvedMCPTool{{Binding: binding, Server: server}} - revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatalf("omitted selection Compile() error = %v", err) } @@ -339,7 +339,7 @@ func TestCompileWholeServerMCPSelectionWarnings(t *testing.T) { } input.Root.MCPTools[0].Binding.Tools = []string{"one"} - revision, err = NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + revision, err = NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatalf("partial selection Compile() error = %v", err) } @@ -348,7 +348,7 @@ func TestCompileWholeServerMCPSelectionWarnings(t *testing.T) { } server.Status.ObservedGeneration = 0 - revision, err = NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + revision, err = NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatalf("stale discovery Compile() error = %v", err) } @@ -362,7 +362,7 @@ func TestCompileWholeServerMCPSelectionWarnings(t *testing.T) { server.Spec.TLS = &v1alpha3.TLSConfig{DisableVerify: true} server.Spec.Timeout = &metav1.Duration{Duration: time.Minute} server.Spec.TerminateOnClose = &terminateOnClose - revision, err = NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + revision, err = NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatalf("unsupported MCP options Compile() error = %v", err) } @@ -376,7 +376,7 @@ func TestCompileWholeServerMCPSelectionWarnings(t *testing.T) { } server.Spec.Protocol = v1alpha3.RemoteMCPServerProtocol("STDIO") - if _, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input); err == nil || !strings.Contains(err.Error(), "unsupported protocol") { + if _, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input); err == nil || !strings.Contains(err.Error(), "unsupported protocol") { t.Fatalf("unsupported MCP protocol Compile() error = %v", err) } @@ -386,7 +386,7 @@ func TestCompileWholeServerMCPSelectionWarnings(t *testing.T) { server.Spec.TerminateOnClose = nil input.Root.MCPTools[0].Binding.Tools = []string{"one"} input.Root.MCPTools[0].Binding.RequireApproval = true - revision, err = NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + revision, err = NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatalf("approval-required MCP binding Compile() error = %v", err) } @@ -433,7 +433,7 @@ func TestCompileLocalSharedAgent(t *testing.T) { Name: "specialist", Description: "Handles specialist requests", Agent: child, }} - revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatal(err) } @@ -495,7 +495,7 @@ func TestCompileRejectsUnsupportedLocalAgentConfiguration(t *testing.T) { } tt.mutate(&binding) input.Root.Shared = []translator.AgentInputBinding{binding} - _, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + _, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err == nil || !strings.Contains(err.Error(), tt.want) { t.Fatalf("Compile() error = %v, want containing %q", err, tt.want) } @@ -530,7 +530,7 @@ func TestCompileRuntimeTelemetry(t *testing.T) { input, reader := testInput(t, model, map[string][]byte{"api-key": []byte("secret")}) input.Harness.Name = "fast" - settings := testCompilerSettings() + settings := testRuntimeDefaults() revision, err := NewCompiler(krt.TestingDummyContext{}, reader, settings).Compile(context.Background(), input) if err != nil { t.Fatal(err) @@ -551,8 +551,7 @@ func TestCompileRuntimeTelemetry(t *testing.T) { t.Fatal("content capture is not disabled by default") } - settings.Telemetry.Runtime.CaptureContent = true - settings.Telemetry.Runtime.MaxCaptureBytes = 4096 + settings.Telemetry = &apiv1.TelemetryConfig{CaptureContent: true, MaxCaptureBytes: new(int32(4096))} captured, err := NewCompiler(krt.TestingDummyContext{}, reader, settings).Compile(context.Background(), input) if err != nil { t.Fatal(err) @@ -584,9 +583,9 @@ func TestCompileRuntimeTelemetry(t *testing.T) { } func TestCompiledTelemetryFitsTheActorEnvironmentBudget(t *testing.T) { - settings := testCompilerSettings() - settings.Telemetry = translator.TelemetryConfig{Runtime: tracing.RuntimeTelemetry{CaptureContent: true, CaptureRawAPIBodies: true, MaxCaptureBytes: 4096, - Exporters: &telemetry.Config{Traces: &telemetry.OTLPConfig{Endpoint: "http://traces:4317", Protocol: "grpc"}, Metrics: &telemetry.OTLPConfig{Endpoint: "http://collector:4317", Protocol: "grpc"}, Logs: &telemetry.OTLPConfig{Endpoint: "http://logs:4318/v1/logs", Protocol: "http/protobuf"}}}} + settings := testRuntimeDefaults() + settings.Telemetry = &apiv1.TelemetryConfig{CaptureContent: true, CaptureRawApiBodies: true, MaxCaptureBytes: new(int32(4096)), + Traces: &apiv1.OTLPConfig{Endpoint: "http://traces:4317", Protocol: new("grpc")}, Metrics: &apiv1.OTLPConfig{Endpoint: "http://collector:4317", Protocol: new("grpc")}, Logs: &apiv1.OTLPConfig{Endpoint: "http://logs:4318/v1/logs", Protocol: new("http/protobuf")}} model := v1alpha3.ModelConfigSpec{ Provider: v1alpha3.ModelProviderAnthropic, Model: "claude-sonnet-4-5", APIKeySecret: "model-auth", APIKeySecretKey: "api-key", @@ -620,6 +619,6 @@ func TestCompiledTelemetryFitsTheActorEnvironmentBudget(t *testing.T) { t.Logf("worst-case Claude actor uses %d of 32 environment variables", len(template.GetContainers()[0].GetEnv())) } -func testCompilerSettings() translator.CompilerSettings { - return translator.CompilerSettings{APIURL: "http://kagent-controller.kagent:8083", GatewayURL: "http://kagent-controller.kagent:8083", LogLevel: "info"} +func testRuntimeDefaults() *apiv1.RuntimeDefaultsConfig { + return &apiv1.RuntimeDefaultsConfig{ControlPlaneUrl: new("http://kagent-controller.kagent:8083"), GatewayUrl: new("http://kagent-controller.kagent:8083"), Logging: &apiv1.LoggingConfig{Level: new("info")}} } diff --git a/go/core/internal/translator/codex/compiler.go b/go/core/internal/translator/codex/compiler.go index 908a25d86e..1cfe337f10 100644 --- a/go/core/internal/translator/codex/compiler.go +++ b/go/core/internal/translator/codex/compiler.go @@ -16,6 +16,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/api/v1alpha3" "github.com/kagent-dev/kagent/go/core/internal/egress" "github.com/kagent-dev/kagent/go/core/internal/translator" @@ -40,12 +41,12 @@ var ownedEnvironment = map[string]struct{}{ } type Compiler struct { - settings translator.CompilerSettings + settings *apiv1.RuntimeDefaultsConfig ctx krt.HandlerContext collections translator.Collections } -func NewCompiler(ctx krt.HandlerContext, collections translator.Collections, settings translator.CompilerSettings) *Compiler { +func NewCompiler(ctx krt.HandlerContext, collections translator.Collections, settings *apiv1.RuntimeDefaultsConfig) *Compiler { return &Compiler{settings: settings, ctx: ctx, collections: collections} } @@ -60,7 +61,10 @@ func (c *Compiler) Compile(ctx context.Context, input *translator.HarnessInput) if len(model.Spec.DefaultHeaders) != 0 || !model.Spec.TLS.IsEmpty() || model.Spec.APIKeyPassthrough { return nil, translator.NewValidationError("Codex does not support ModelConfig defaultHeaders, TLS, or apiKeyPassthrough") } - telemetryConfig := c.settings.Telemetry + telemetryConfig, err := translator.TelemetryConfigFromSettings(c.settings.GetTelemetry()) + if err != nil { + return nil, err + } traceConfig, logConfig := telemetryConfig.Traces, telemetryConfig.Logs template, harness := input.Root.Template, input.Harness // The runtime reports this identity on every invocation span and on its @@ -96,9 +100,9 @@ func (c *Compiler) Compile(ctx context.Context, input *translator.HarnessInput) cfg := codexconfig.Production(model.Spec.Model, input.Root.Instruction) cfg.Provider, cfg.Agents, cfg.MCPServers = provider, agents, mcp.servers cfg.RuntimeTelemetry = runtimeTelemetry - cfg.ControlPlaneURL = c.settings.APIURL - cfg.MaxContentLength = c.settings.RuntimeConfig(input.AgentName, input.Root.Template.Namespace).MaxContentLength - cfg.LogLevel = c.settings.LogLevel + cfg.ControlPlaneURL = c.settings.GetControlPlaneUrl() + cfg.MaxContentLength = c.settings.MaxContentLength // Preserve unset versus unlimited. + cfg.LogLevel = c.settings.GetLogging().GetLevel() if traceConfig.Enabled || logConfig.Enabled { cfg.Telemetry = &codexconfig.Telemetry{CaptureContent: telemetryConfig.Runtime.CaptureContent} if traceConfig.Enabled { @@ -133,7 +137,7 @@ func (c *Compiler) Compile(ctx context.Context, input *translator.HarnessInput) egress = append(egress, skillEgress...) egress = append(egress, mcp.egress...) egress = append(egress, telemetryConfig.Destinations(environment)...) - egress = append(egress, c.settings.APIURL) + egress = append(egress, c.settings.GetControlPlaneUrl()) slices.Sort(egress) egress = slices.Compact(egress) return &translator.CompileResult{ diff --git a/go/core/internal/translator/codex/compiler_test.go b/go/core/internal/translator/codex/compiler_test.go index 4b6c1adbbb..949c5ef6aa 100644 --- a/go/core/internal/translator/codex/compiler_test.go +++ b/go/core/internal/translator/codex/compiler_test.go @@ -16,9 +16,11 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/api/v1alpha3" "github.com/kagent-dev/kagent/go/core/internal/translator" codexconfig "github.com/kagent-dev/kagent/go/harness/codex/config" + "github.com/kagent-dev/kagent/go/pkg/telemetry" "github.com/kagent-dev/kagent/go/pkg/tracing" ) @@ -55,7 +57,7 @@ func TestCompileProviderCredentials(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { input, reader := testInput(t, test.model, test.secret) - revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if test.wantErr != "" { if err == nil || !strings.Contains(err.Error(), test.wantErr) { t.Fatalf("expected unsupported credential error, got %v", err) @@ -90,7 +92,7 @@ func TestCompileProviderCredentials(t *testing.T) { if bytes.Contains(revision.ConfigJSON, []byte(credentialValue)) || bytes.Contains(revision.Provenance, []byte(credentialValue)) { t.Fatal("credential leaked into immutable revision") } - again, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + again, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil || !reflect.DeepEqual(revision, again) { t.Fatalf("compilation is not deterministic: %v", err) } @@ -109,7 +111,7 @@ func TestCompileAllowsRuntimeOTELEndpoint(t *testing.T) { value := "http://other-collector:4317" input.Harness.Spec.Env = []v1alpha3.RuntimeEnvVar{{Name: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", Value: value}} - result, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + result, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatal(err) } @@ -129,7 +131,7 @@ func TestCompileAllowsRuntimeTelemetryOverrides(t *testing.T) { value := "x-tenant=team-a" input.Harness.Spec.Env = []v1alpha3.RuntimeEnvVar{{Name: "OTEL_EXPORTER_OTLP_HEADERS", Value: value}} - result, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + result, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatal(err) } @@ -148,7 +150,7 @@ func TestCompileRejectsUnsupportedProviderConfiguration(t *testing.T) { } for _, model := range tests { input, reader := testInput(t, model, map[string][]byte{"api-key": []byte("secret"), awsAccessKeyEnv: []byte("access"), awsSecretKeyEnv: []byte("secret")}) - _, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + _, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) var validation *translator.ValidationError if !errors.As(err, &validation) { t.Errorf("Compile(%s) error = %v, want validation", model.Provider, err) @@ -173,7 +175,7 @@ func TestCompileMCPAndSharedAgent(t *testing.T) { }, Instruction: "Review carefully", }}} - revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + revision, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatal(err) } @@ -216,7 +218,7 @@ func TestCompileMCPCompatibilityWarnings(t *testing.T) { } input.Root.MCPTools = []translator.ResolvedMCPTool{{Binding: v1alpha3.MCPToolBinding{RequireApproval: true}, Server: server}} - compilation, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input) + compilation, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input) if err != nil { t.Fatalf("Compile() error = %v", err) } @@ -237,7 +239,7 @@ func TestCompileMCPCompatibilityWarnings(t *testing.T) { } server.Spec.Protocol = v1alpha3.RemoteMCPServerProtocolSse - if _, err := NewCompiler(krt.TestingDummyContext{}, reader, testCompilerSettings()).Compile(context.Background(), input); err == nil || !strings.Contains(err.Error(), "requires Streamable HTTP") { + if _, err := NewCompiler(krt.TestingDummyContext{}, reader, testRuntimeDefaults()).Compile(context.Background(), input); err == nil || !strings.Contains(err.Error(), "requires Streamable HTTP") { t.Fatalf("unsupported MCP protocol Compile() error = %v", err) } } @@ -271,8 +273,8 @@ func TestCompileRuntimeTelemetry(t *testing.T) { input, reader := testInput(t, model, map[string][]byte{"api-key": []byte("secret")}) input.Harness.Name = "fast" - settings := testCompilerSettings() - settings.Telemetry.Traces = translator.SignalConfig{Enabled: true, Endpoint: "http://collector:4317", Protocol: "grpc", Hostname: "collector"} + settings := testRuntimeDefaults() + settings.Telemetry = &apiv1.TelemetryConfig{Traces: &apiv1.OTLPConfig{Endpoint: "http://collector:4317", Protocol: new("grpc")}} revision, err := NewCompiler(krt.TestingDummyContext{}, reader, settings).Compile(context.Background(), input) if err != nil { t.Fatal(err) @@ -285,15 +287,16 @@ func TestCompileRuntimeTelemetry(t *testing.T) { want := tracing.RuntimeTelemetry{ Runtime: tracing.RuntimeCodex, AgentName: "runnable-agent", AgentNamespace: "test", Provider: "openai", Model: "gpt-5.2-codex", + Exporters: &telemetry.Config{Traces: &telemetry.OTLPConfig{Endpoint: "http://collector:4317", Protocol: "grpc"}}, } - if config.RuntimeTelemetry != want { + if !reflect.DeepEqual(config.RuntimeTelemetry, want) { t.Fatalf("runtime telemetry = %#v, want %#v", config.RuntimeTelemetry, want) } if config.RuntimeTelemetry.CaptureLimit() != 0 { t.Fatal("content capture is not disabled by default") } - settings.Telemetry.Runtime.CaptureContent = true + settings.Telemetry.CaptureContent = true captured, err := NewCompiler(krt.TestingDummyContext{}, reader, settings).Compile(context.Background(), input) if err != nil { t.Fatal(err) @@ -328,6 +331,6 @@ func TestCompileRuntimeTelemetry(t *testing.T) { } } -func testCompilerSettings() translator.CompilerSettings { - return translator.CompilerSettings{APIURL: "http://kagent-controller.kagent:8083", GatewayURL: "http://kagent-controller.kagent:8083", LogLevel: "info"} +func testRuntimeDefaults() *apiv1.RuntimeDefaultsConfig { + return &apiv1.RuntimeDefaultsConfig{ControlPlaneUrl: new("http://kagent-controller.kagent:8083"), GatewayUrl: new("http://kagent-controller.kagent:8083"), Logging: &apiv1.LoggingConfig{Level: new("info")}} } diff --git a/go/core/internal/translator/compiler_test.go b/go/core/internal/translator/compiler_test.go index fde22b82ac..08a4ce87c0 100644 --- a/go/core/internal/translator/compiler_test.go +++ b/go/core/internal/translator/compiler_test.go @@ -18,6 +18,7 @@ import ( "k8s.io/apimachinery/pkg/types" "github.com/kagent-dev/kagent/go/api/adk" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/api/v1alpha3" "github.com/kagent-dev/kagent/go/core/internal/substrate" "github.com/kagent-dev/kagent/go/core/internal/translator" @@ -208,10 +209,10 @@ func compilerWithImages(t *testing.T, images translator.BuiltinImages, objects . collections := mockCollections(t, append(objects, defaultWorkerPool())...) ctx := krt.TestingDummyContext{} return translator.NewCompiler(ctx, collections, map[translator.HarnessType]translator.HarnessCompiler{ - translator.HarnessTypeKagent: kagenttranslator.NewCompiler(ctx, collections, testCompilerSettings()), - translator.HarnessTypeCodex: codextranslator.NewCompiler(ctx, collections, testCompilerSettings()), - translator.HarnessTypeClaude: claudetranslator.NewCompiler(ctx, collections, testCompilerSettings()), - translator.HarnessTypeBYO: byotranslator.NewCompiler(ctx, collections, testCompilerSettings()), + translator.HarnessTypeKagent: kagenttranslator.NewCompiler(ctx, collections, testRuntimeDefaults()), + translator.HarnessTypeCodex: codextranslator.NewCompiler(ctx, collections, testRuntimeDefaults()), + translator.HarnessTypeClaude: claudetranslator.NewCompiler(ctx, collections, testRuntimeDefaults()), + translator.HarnessTypeBYO: byotranslator.NewCompiler(ctx, collections, testRuntimeDefaults()), }, images) } @@ -622,7 +623,7 @@ func TestCompileAgentInjectsCredentialsAtGateway(t *testing.T) { rotated.UID = "replacement-secret" rotated.Data["token"] = []byte("rotated-token") rotatedCompiler := translator.NewCompiler(krt.TestingDummyContext{}, mockCollections(t, modelConfig(), server, secondServer, rotated, secondSecret, defaultWorkerPool(), harness), map[translator.HarnessType]translator.HarnessCompiler{ - translator.HarnessTypeKagent: kagenttranslator.NewCompiler(krt.TestingDummyContext{}, mockCollections(t, modelConfig(), server, secondServer, rotated, secondSecret), testCompilerSettings()), + translator.HarnessTypeKagent: kagenttranslator.NewCompiler(krt.TestingDummyContext{}, mockCollections(t, modelConfig(), server, secondServer, rotated, secondSecret), testRuntimeDefaults()), }, testBuiltinImages) next, err := rotatedCompiler.CompileAgent(t.Context(), inlineAgent(harness, template)) require.NoError(t, err) @@ -996,6 +997,6 @@ func TestResolveModelConfigMistral(t *testing.T) { require.Equal(t, "APIKeySecretNotFound", resolved.Failure().Reason) } -func testCompilerSettings() translator.CompilerSettings { - return translator.CompilerSettings{APIURL: "http://kagent-controller.kagent:8083", GatewayURL: "http://kagent-controller.kagent:8083", LogLevel: "info"} +func testRuntimeDefaults() *apiv1.RuntimeDefaultsConfig { + return &apiv1.RuntimeDefaultsConfig{ControlPlaneUrl: new("http://kagent-controller.kagent:8083"), GatewayUrl: new("http://kagent-controller.kagent:8083"), Logging: &apiv1.LoggingConfig{Level: new("info")}} } diff --git a/go/core/internal/translator/kagent/agentcard_test.go b/go/core/internal/translator/kagent/agentcard_test.go index d64b01d9ef..94fb02ea20 100644 --- a/go/core/internal/translator/kagent/agentcard_test.go +++ b/go/core/internal/translator/kagent/agentcard_test.go @@ -9,12 +9,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" apia2a "github.com/kagent-dev/kagent/go/api/a2a" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/api/v1alpha3" "github.com/kagent-dev/kagent/go/core/internal/translator" ) func TestCompilerRequiresModelConfig(t *testing.T) { - _, err := NewCompiler(krt.TestingDummyContext{}, translator.Collections{}, testCompilerSettings()).Compile(context.Background(), &translator.HarnessInput{ + _, err := NewCompiler(krt.TestingDummyContext{}, translator.Collections{}, testRuntimeDefaults()).Compile(context.Background(), &translator.HarnessInput{ Harness: &translator.HarnessConfiguration{Spec: v1alpha3.HarnessSpec{Kagent: &v1alpha3.KagentHarness{}}}, Root: &translator.AgentInput{Template: &translator.TemplateConfiguration{}}, }) @@ -60,6 +61,6 @@ func TestAgentTemplateCardDeclaresHumanInTheLoop(t *testing.T) { } } -func testCompilerSettings() translator.CompilerSettings { - return translator.CompilerSettings{APIURL: "http://kagent-controller.kagent:8083", GatewayURL: "http://kagent-controller.kagent:8083", LogLevel: "info"} +func testRuntimeDefaults() *apiv1.RuntimeDefaultsConfig { + return &apiv1.RuntimeDefaultsConfig{ControlPlaneUrl: new("http://kagent-controller.kagent:8083"), GatewayUrl: new("http://kagent-controller.kagent:8083"), Logging: &apiv1.LoggingConfig{Level: new("info")}} } diff --git a/go/core/internal/translator/kagent/compiler.go b/go/core/internal/translator/kagent/compiler.go index 8df820e014..d4d49f269a 100644 --- a/go/core/internal/translator/kagent/compiler.go +++ b/go/core/internal/translator/kagent/compiler.go @@ -11,31 +11,35 @@ import ( "istio.io/istio/pkg/kube/krt" "github.com/kagent-dev/kagent/go/api/adk" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/core/internal/translator" "github.com/kagent-dev/kagent/go/core/internal/translator/adkconfig" ) // Compiler translates resolved inputs into a kagent runtime revision. type Compiler struct { - settings translator.CompilerSettings + settings *apiv1.RuntimeDefaultsConfig config *adkconfig.Builder } var _ translator.HarnessCompiler = (*Compiler)(nil) -func NewCompiler(ctx krt.HandlerContext, collections translator.Collections, settings translator.CompilerSettings) *Compiler { +func NewCompiler(ctx krt.HandlerContext, collections translator.Collections, settings *apiv1.RuntimeDefaultsConfig) *Compiler { return &Compiler{settings: settings, config: adkconfig.NewBuilder(ctx, collections)} } func (c *Compiler) Compile(ctx context.Context, input *translator.HarnessInput) (*translator.CompileResult, error) { - telemetryConfig := c.settings.Telemetry + telemetryConfig, err := translator.TelemetryConfigFromSettings(c.settings.GetTelemetry()) + if err != nil { + return nil, err + } compiled, err := c.config.Build(ctx, input) if err != nil { return nil, err } template, harness := input.Root.Template, input.Harness configJSON, err := adk.Marshal(&adk.Config{ - Runtime: c.settings.RuntimeConfig(input.AgentName, template.Namespace), + Runtime: translator.RuntimeConfig(c.settings, input.AgentName, template.Namespace), Agent: compiled.Config, }) if err != nil { @@ -62,7 +66,7 @@ func (c *Compiler) Compile(ctx context.Context, input *translator.HarnessInput) return nil, err } compiled.Egress = append(compiled.Egress, telemetryConfig.Destinations(environment)...) - compiled.Egress = append(compiled.Egress, c.settings.APIURL) + compiled.Egress = append(compiled.Egress, c.settings.GetControlPlaneUrl()) slices.Sort(compiled.Egress) compiled.Egress = slices.Compact(compiled.Egress) return &translator.CompileResult{Revision: translator.Revision{ diff --git a/go/core/internal/translator/otel_test.go b/go/core/internal/translator/otel_test.go index 09ad98242e..c5dc1b2d01 100644 --- a/go/core/internal/translator/otel_test.go +++ b/go/core/internal/translator/otel_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/sdk/resource" semconv "go.opentelemetry.io/otel/semconv/v1.43.0" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" corev1 "k8s.io/api/core/v1" @@ -17,44 +18,35 @@ import ( "github.com/kagent-dev/kagent/go/pkg/tracing" ) -func TestCompilerSettingsIgnoreProcessEnvironment(t *testing.T) { +func TestRuntimeDefaultsIgnoreProcessEnvironment(t *testing.T) { cfg := &apiv1.ControllerConfig{} config.DefaultController(cfg) cfg.RuntimeDefaults.Telemetry.Traces = &apiv1.OTLPConfig{Endpoint: "http://collector:4317", Protocol: new("grpc"), Timeout: durationpb.New(time.Second)} - first, err := translator.NewCompilerSettings(cfg.RuntimeDefaults) + first, err := translator.TelemetryConfigFromSettings(cfg.GetRuntimeDefaults().GetTelemetry()) require.NoError(t, err) + firstRuntime := translator.RuntimeConfig(cfg.GetRuntimeDefaults(), "assistant", "team") t.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://other:4317") t.Setenv("OTEL_SDK_DISABLED", "true") - second, err := translator.NewCompilerSettings(cfg.RuntimeDefaults) + second, err := translator.TelemetryConfigFromSettings(cfg.GetRuntimeDefaults().GetTelemetry()) require.NoError(t, err) require.Equal(t, first, second) - require.Equal(t, []string{"http://collector:4317"}, first.Telemetry.Destinations(nil)) - require.Equal(t, int64(1000), first.Telemetry.Runtime.Exporters.Traces.TimeoutMillis) -} - -func TestCompilerPreservesSharedRuntimeTelemetry(t *testing.T) { - cfg := &apiv1.TelemetryConfig{ - CaptureContent: true, CaptureRawApiBodies: true, OpenaiNativeTracing: true, MaxCaptureBytes: new(int32(4096)), - ResourceAttributes: map[string]string{"deployment.environment.name": "test"}, - Traces: &apiv1.OTLPConfig{Endpoint: "http://collector:4317", Timeout: durationpb.New(time.Second)}, - } - compiled, err := translator.TelemetryConfigFromSettings(cfg) - require.NoError(t, err) - want := config.RuntimeTelemetry(cfg) - want.Runtime, want.AgentName, want.AgentNamespace = tracing.RuntimeADKGo, "assistant", "team" - want.Provider, want.Model = "openai", "gpt-4" - actual := compiled.RuntimeTelemetry(tracing.RuntimeADKGo, "assistant", "team", v1alpha3.ModelConfigSpec{Provider: v1alpha3.ModelProviderOpenAI, Model: "gpt-4"}) - require.Equal(t, want, actual) + secondRuntime := translator.RuntimeConfig(cfg.GetRuntimeDefaults(), "assistant", "team") + require.True(t, proto.Equal(firstRuntime, secondRuntime)) + require.Equal(t, "assistant", secondRuntime.GetName()) + require.Equal(t, "team", secondRuntime.GetNamespace()) + require.Equal(t, "http://collector:4317", secondRuntime.GetTelemetry().GetTraces().GetEndpoint()) + require.Equal(t, []string{"http://collector:4317"}, first.Destinations(nil)) + require.Equal(t, int64(1000), first.Runtime.Exporters.Traces.TimeoutMillis) } func TestBYOTelemetryGenericEnvironmentOverridesFileDefaults(t *testing.T) { cfg := &apiv1.ControllerConfig{} config.DefaultController(cfg) cfg.RuntimeDefaults.Telemetry.Traces = &apiv1.OTLPConfig{Endpoint: "http://file-collector:4317", Protocol: new("grpc")} - settings, err := translator.NewCompilerSettings(cfg.RuntimeDefaults) + settings, err := translator.TelemetryConfigFromSettings(cfg.GetRuntimeDefaults().GetTelemetry()) require.NoError(t, err) credential := corev1.EnvVar{Name: "OPENAI_API_KEY", ValueFrom: &corev1.EnvVarSource{SecretKeyRef: &corev1.SecretKeySelector{Key: "api-key", LocalObjectReference: corev1.LocalObjectReference{Name: "model-auth"}}}} - environment := settings.Telemetry.TelemetryEnvironment(tracing.RuntimeTelemetry{}, []corev1.EnvVar{ + environment := settings.TelemetryEnvironment(tracing.RuntimeTelemetry{}, []corev1.EnvVar{ credential, {Name: "OTEL_EXPORTER_OTLP_ENDPOINT", Value: "http://runtime-collector:4318"}, {Name: "OTEL_EXPORTER_OTLP_PROTOCOL", Value: "http/protobuf"}, @@ -63,23 +55,13 @@ func TestBYOTelemetryGenericEnvironmentOverridesFileDefaults(t *testing.T) { for _, variable := range environment { require.NotEqual(t, "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", variable.Name) } - destinations := settings.Telemetry.Destinations(environment) + destinations := settings.Destinations(environment) require.NotEmpty(t, destinations) for _, destination := range destinations { require.Equal(t, "http://runtime-collector:4318", destination) } } -func TestCompilerSettingsRejectInvalidCaptureAndEndpoints(t *testing.T) { - for _, input := range []string{`runtimeDefaults: {telemetry: {maxCaptureBytes: -1}}`, `runtimeDefaults: {telemetry: {traces: {endpoint: 'file:///private'}}}`} { - cfg := &apiv1.ControllerConfig{} - require.NoError(t, config.Decode([]byte(input), cfg)) - config.DefaultController(cfg) - _, err := translator.NewCompilerSettings(cfg.RuntimeDefaults) - require.Error(t, err) - } -} - func TestBYOTelemetryServiceNameDefault(t *testing.T) { for _, tc := range []struct { name, serviceName, attributes, want string @@ -93,9 +75,9 @@ func TestBYOTelemetryServiceNameDefault(t *testing.T) { cfg := &apiv1.ControllerConfig{} config.DefaultController(cfg) cfg.RuntimeDefaults.Telemetry.ResourceAttributes = map[string]string{"deployment.environment.name": "production"} - settings, err := translator.NewCompilerSettings(cfg.RuntimeDefaults) + settings, err := translator.TelemetryConfigFromSettings(cfg.GetRuntimeDefaults().GetTelemetry()) require.NoError(t, err) - environment := settings.Telemetry.TelemetryEnvironment(tracing.RuntimeTelemetry{AgentName: "assistant", AgentNamespace: "team"}, []corev1.EnvVar{{Name: "OTEL_RESOURCE_ATTRIBUTES", Value: tc.attributes}}) + environment := settings.TelemetryEnvironment(tracing.RuntimeTelemetry{AgentName: "assistant", AgentNamespace: "team"}, []corev1.EnvVar{{Name: "OTEL_RESOURCE_ATTRIBUTES", Value: tc.attributes}}) for _, variable := range environment { if variable.Name == "OTEL_RESOURCE_ATTRIBUTES" { t.Setenv(variable.Name, variable.Value) @@ -107,7 +89,22 @@ func TestBYOTelemetryServiceNameDefault(t *testing.T) { name, ok := res.Set().Value(semconv.ServiceNameKey) require.True(t, ok) require.Equal(t, tc.want, name.AsString()) - require.Equal(t, map[string]string{"deployment.environment.name": "production"}, settings.Telemetry.Runtime.Exporters.ResourceAttributes) + require.Equal(t, map[string]string{"deployment.environment.name": "production"}, settings.Runtime.Exporters.ResourceAttributes) }) } } + +func TestCompilerPreservesSharedRuntimeTelemetry(t *testing.T) { + cfg := &apiv1.TelemetryConfig{ + CaptureContent: true, CaptureRawApiBodies: true, OpenaiNativeTracing: true, MaxCaptureBytes: new(int32(4096)), + ResourceAttributes: map[string]string{"deployment.environment.name": "test"}, + Traces: &apiv1.OTLPConfig{Endpoint: "http://collector:4317", Timeout: durationpb.New(time.Second)}, + } + compiled, err := translator.TelemetryConfigFromSettings(cfg) + require.NoError(t, err) + want := config.RuntimeTelemetry(cfg) + want.Runtime, want.AgentName, want.AgentNamespace = tracing.RuntimeADKGo, "assistant", "team" + want.Provider, want.Model = "openai", "gpt-4" + actual := compiled.RuntimeTelemetry(tracing.RuntimeADKGo, "assistant", "team", v1alpha3.ModelConfigSpec{Provider: v1alpha3.ModelProviderOpenAI, Model: "gpt-4"}) + require.Equal(t, want, actual) +} diff --git a/go/core/internal/translator/settings.go b/go/core/internal/translator/settings.go index 2d5a88682f..3b2e1f7bfd 100644 --- a/go/core/internal/translator/settings.go +++ b/go/core/internal/translator/settings.go @@ -11,38 +11,6 @@ import ( "github.com/kagent-dev/kagent/go/core/pkg/config" ) -// CompilerSettings contains only deployment inputs needed by harness compilers. -// It is resolved once at startup, independently of reconciliation and env. -type CompilerSettings struct { - APIURL string - GatewayURL string - LogLevel string - Telemetry TelemetryConfig - Process *adk.RuntimeConfig - Images BuiltinImages -} - -func NewCompilerSettings(cfg *apiv1.RuntimeDefaultsConfig) (CompilerSettings, error) { - if cfg == nil { - return CompilerSettings{}, fmt.Errorf("runtime defaults are required") - } - if err := config.Validate(cfg); err != nil { - return CompilerSettings{}, err - } - telemetry, err := TelemetryConfigFromSettings(cfg.GetTelemetry()) - if err != nil { - return CompilerSettings{}, err - } - return CompilerSettings{APIURL: cfg.GetControlPlaneUrl(), GatewayURL: cfg.GetGatewayUrl(), LogLevel: cfg.GetLogging().GetLevel(), Telemetry: telemetry, Process: &adk.RuntimeConfig{ - // Preserve presence: nil selects the runtime default; zero disables the limit. - MaxContentLength: cfg.MaxContentLength, - FileSearchTools: cfg.GetFileSearchTools(), - BashVenvPath: cfg.GetBashVenvPath(), - TokenPropagation: proto.CloneOf(cfg.GetTokenPropagation()), - Telemetry: proto.CloneOf(cfg.GetTelemetry()), - }}, nil -} - func TelemetryConfigFromSettings(cfg *apiv1.TelemetryConfig) (TelemetryConfig, error) { result := TelemetryConfig{Runtime: config.RuntimeTelemetry(cfg)} if cfg == nil { @@ -62,14 +30,16 @@ func TelemetryConfigFromSettings(cfg *apiv1.TelemetryConfig) (TelemetryConfig, e return result, nil } -// RuntimeConfig supplies process settings for root ADK and BYO JSON only. -func (s CompilerSettings) RuntimeConfig(name, namespace string) *adk.RuntimeConfig { - result := proto.CloneOf(s.Process) - if result == nil { - result = &adk.RuntimeConfig{} +// RuntimeConfig builds the per-agent ADK or BYO process configuration from the +// controller's validated runtime defaults, without reading process environment. +func RuntimeConfig(cfg *apiv1.RuntimeDefaultsConfig, name, namespace string) *adk.RuntimeConfig { + return &adk.RuntimeConfig{ + ControlPlaneUrl: cfg.GetControlPlaneUrl(), GatewayUrl: cfg.GetGatewayUrl(), + Name: name, Namespace: namespace, LogLevel: cfg.GetLogging().GetLevel(), Port: new(uint32(80)), + // Preserve optional presence: zero disables the runtime's request limit. + MaxContentLength: cfg.MaxContentLength, + FileSearchTools: cfg.GetFileSearchTools(), BashVenvPath: cfg.GetBashVenvPath(), + TokenPropagation: proto.CloneOf(cfg.GetTokenPropagation()), + Telemetry: proto.CloneOf(cfg.GetTelemetry()), } - result.ControlPlaneUrl, result.GatewayUrl = s.APIURL, s.GatewayURL - result.Name, result.Namespace = name, namespace - result.LogLevel, result.Port = s.LogLevel, new(uint32(80)) - return result } diff --git a/go/core/pkg/app/app.go b/go/core/pkg/app/app.go index c229fabfce..efb3e50007 100644 --- a/go/core/pkg/app/app.go +++ b/go/core/pkg/app/app.go @@ -67,7 +67,6 @@ import ( "github.com/kagent-dev/kagent/go/core/internal/service/taskstore" toolservice "github.com/kagent-dev/kagent/go/core/internal/service/tool" "github.com/kagent-dev/kagent/go/core/internal/substrate" - "github.com/kagent-dev/kagent/go/core/internal/translator" "github.com/kagent-dev/kagent/go/core/internal/version" "github.com/kagent-dev/kagent/go/core/pkg/auth" "github.com/kagent-dev/kagent/go/core/pkg/config" @@ -185,11 +184,7 @@ func Run(ctx context.Context, input *apiv1.ControllerConfig, opts Options) error quiescenceInterval := cfg.GetSessions().GetQuiescenceRecoveryInterval().AsDuration() logger := slog.Default() ctx = logging.IntoContext(ctx, logger) - compilerSettings, err := translator.NewCompilerSettings(cfg.GetRuntimeDefaults()) - if err != nil { - return err - } - compilerSettings.Images, err = builtinImages(cfg.GetHarnessImages(), version.Version) + images, err := builtinImages(cfg.GetHarnessImages(), version.Version) if err != nil { return err } @@ -278,7 +273,7 @@ func Run(ctx context.Context, input *apiv1.ControllerConfig, opts Options) error if err != nil { return fmt.Errorf("create controller manager: %w", err) } - runtime, err := controller.NewRuntime(kubeConfig, watchNamespaces, ctx.Done(), compilerSettings) + runtime, err := controller.NewRuntime(kubeConfig, watchNamespaces, ctx.Done(), cfg.GetRuntimeDefaults(), images) if err != nil { return err } diff --git a/go/core/pkg/app/app_test.go b/go/core/pkg/app/app_test.go index 57ad9b4e4a..4a820966fc 100644 --- a/go/core/pkg/app/app_test.go +++ b/go/core/pkg/app/app_test.go @@ -111,7 +111,7 @@ func TestNamespaceCache(t *testing.T) { func TestPostgresConfig(t *testing.T) { input := &apiv1.DatabaseConfig{VectorEnabled: true, Schema: new("kagent_test"), VectorSchema: new("vectors_test"), Pool: &apiv1.PostgresPoolConfig{ - MaxConns: new(int32(8)), MinConns: new(int32(1)), MaxConnIdleTime: durationpb.New(time.Minute), MaxConnLifetime: durationpb.New(10 * time.Minute), + MaxConns: new(int32(8)), MinConns: 1, MaxConnIdleTime: durationpb.New(time.Minute), MaxConnLifetime: durationpb.New(10 * time.Minute), }} pool := &pgxpool.Config{} config := postgresConfig(input, pool) diff --git a/go/core/pkg/config/defaults.go b/go/core/pkg/config/defaults.go index 494d291115..54a387e0b9 100644 --- a/go/core/pkg/config/defaults.go +++ b/go/core/pkg/config/defaults.go @@ -2,8 +2,11 @@ package config import ( "runtime" + "strings" "time" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/known/durationpb" apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" @@ -34,7 +37,7 @@ func DefaultController(cfg *apiv1.ControllerConfig) { Server: &apiv1.ControllerServerConfig{BindAddress: new(":8083"), Auth: &apiv1.AuthenticationConfig{Mode: new("insecure")}}, Database: defaultDatabase(), Substrate: &apiv1.SubstrateConfig{ApiEndpoint: new("dns:///api.ate-system.svc:443"), RouterUrl: new("http://atenet-router.ate-system.svc:80")}, - Sessions: &apiv1.SessionsConfig{IdleTtl: durationpb.New(7 * 24 * time.Hour), ShareMaxTtl: durationpb.New(0), ExpirationInterval: durationpb.New(time.Minute), QuiescenceRecoveryInterval: durationpb.New(time.Minute)}, + Sessions: &apiv1.SessionsConfig{IdleTtl: durationpb.New(7 * 24 * time.Hour), ExpirationInterval: durationpb.New(time.Minute), QuiescenceRecoveryInterval: durationpb.New(time.Minute)}, Gateway: &apiv1.GatewayConfig{PublicUrl: new("http://localhost:8083"), Push: &apiv1.PushConfig{}}, Sandboxes: &apiv1.SandboxConfig{Cpu: new("1"), Memory: new("1Gi"), DefaultTtl: durationpb.New(time.Hour), MaxTtl: durationpb.New(24 * time.Hour), ExpirationInterval: durationpb.New(time.Second)}, ScheduledRuns: &apiv1.ScheduledRunsConfig{PollInterval: durationpb.New(time.Second), ExecutionInterval: durationpb.New(time.Second)}, @@ -52,7 +55,7 @@ func DefaultController(cfg *apiv1.ControllerConfig) { } func defaultDatabase() *apiv1.DatabaseConfig { - return &apiv1.DatabaseConfig{Schema: new(consts.DefaultPostgresTableSchema), VectorSchema: new(consts.DefaultPgvectorSchema), Pool: &apiv1.PostgresPoolConfig{MinConns: new(int32(0)), MaxConns: new(int32(max(4, runtime.NumCPU()))), MaxConnIdleTime: durationpb.New(30 * time.Minute), MaxConnLifetime: durationpb.New(time.Hour)}} + return &apiv1.DatabaseConfig{Schema: new(consts.DefaultPostgresTableSchema), VectorSchema: new(consts.DefaultPgvectorSchema), Pool: &apiv1.PostgresPoolConfig{MaxConns: new(int32(max(4, runtime.NumCPU()))), MaxConnIdleTime: durationpb.New(30 * time.Minute), MaxConnLifetime: durationpb.New(time.Hour)}} } func defaultTelemetry(cfg *apiv1.TelemetryConfig) { @@ -93,3 +96,28 @@ func resolveLoginPath(login *apiv1.DatabaseLoginConfig, path string) { login.UrlFile = FilePath(path, login.UrlFile) } } + +// defaults applies application defaults using protobuf field presence. Optional +// scalars retain explicit zero values; ordinary scalars use their protobuf zero. +// Duration messages are whole values, so an explicit 0s is not filled recursively. +func defaults(dst, src proto.Message) { + fillDefaults(dst.ProtoReflect(), src.ProtoReflect()) +} + +func fillDefaults(dst, src protoreflect.Message) { + src.Range(func(field protoreflect.FieldDescriptor, value protoreflect.Value) bool { + if !dst.Has(field) { + if field.Kind() == protoreflect.MessageKind && !field.IsMap() && !field.IsList() { + dst.Set(field, protoreflect.ValueOfMessage(proto.Clone(value.Message().Interface()).ProtoReflect())) + } else { + dst.Set(field, value) + } + } else if field.Kind() == protoreflect.MessageKind && !field.IsMap() && !field.IsList() { + // Well-known values (especially Duration{seconds:0}) are atomic. + if !strings.HasPrefix(string(field.Message().FullName()), "google.protobuf.") { + fillDefaults(dst.Get(field).Message(), value.Message()) + } + } + return true + }) +} diff --git a/go/core/pkg/config/load.go b/go/core/pkg/config/load.go index d545f7cd1d..8e1aa0f97c 100644 --- a/go/core/pkg/config/load.go +++ b/go/core/pkg/config/load.go @@ -2,23 +2,18 @@ package config import ( - "bytes" - "encoding/json" "fmt" - "io" "os" "path/filepath" - "strconv" "strings" "buf.build/go/protovalidate" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - "gopkg.in/yaml.v3" + "sigs.k8s.io/yaml" ) -// Load decodes one YAML or JSON document. Defaults and validation run after +// Load decodes a YAML or JSON config file. Defaults and validation run after // explicit command-line overrides have been applied. func Load(path string, dst proto.Message) error { data, err := os.ReadFile(path) @@ -31,82 +26,19 @@ func Load(path string, dst proto.Message) error { return nil } -// Decode preserves scalar types and rejects duplicates before a map can discard -// them. Aliases and merge keys are deliberately outside the config format. +// Decode uses strict YAML conversion followed by ProtoJSON decoding. YAML aliases +// and scalar resolution follow sigs.k8s.io/yaml; only the first document is read. func Decode(data []byte, dst proto.Message) error { - decoder := yaml.NewDecoder(bytes.NewReader(data)) - var doc yaml.Node - if err := decoder.Decode(&doc); err != nil { - return fmt.Errorf("invalid configuration document: %w", err) - } - var extra yaml.Node - if err := decoder.Decode(&extra); err != io.EOF { - return fmt.Errorf("configuration must contain exactly one document") - } - if len(doc.Content) != 1 || doc.Content[0].Kind != yaml.MappingNode { - return fmt.Errorf("configuration must be an object") - } - value, err := jsonValue(doc.Content[0], "config") + encoded, err := yaml.YAMLToJSONStrict(data) if err != nil { - return err + return fmt.Errorf("failed to convert configuration to JSON: %w", err) } - encoded, err := json.Marshal(value) - if err != nil { - return fmt.Errorf("failed to encode configuration: %w", err) - } - if err := (protojson.UnmarshalOptions{DiscardUnknown: false}).Unmarshal(encoded, dst); err != nil { + if err := protojson.Unmarshal(encoded, dst); err != nil { return fmt.Errorf("invalid configuration fields: %w", err) } return nil } -func jsonValue(node *yaml.Node, path string) (any, error) { - switch node.Kind { - case yaml.MappingNode: - values := make(map[string]any, len(node.Content)/2) - for i := 0; i < len(node.Content); i += 2 { - key := node.Content[i] - if key.Kind != yaml.ScalarNode || key.Tag != "!!str" || key.Value == "<<" { - return nil, fmt.Errorf("%s: keys must be strings", path) - } - if _, exists := values[key.Value]; exists { - return nil, fmt.Errorf("%s.%s: duplicate field", path, key.Value) - } - value, err := jsonValue(node.Content[i+1], path+"."+key.Value) - if err != nil { - return nil, err - } - values[key.Value] = value - } - return values, nil - case yaml.SequenceNode: - values := make([]any, len(node.Content)) - for i, child := range node.Content { - value, err := jsonValue(child, fmt.Sprintf("%s[%d]", path, i)) - if err != nil { - return nil, err - } - values[i] = value - } - return values, nil - case yaml.ScalarNode: - switch node.Tag { - case "!!str": - return node.Value, nil - case "!!bool": - value, err := strconv.ParseBool(strings.ToLower(node.Value)) - if err == nil { - return value, nil - } - case "!!int", "!!float": - if json.Valid([]byte(node.Value)) { - return json.Number(node.Value), nil - } - } - } - return nil, fmt.Errorf("%s: unsupported value (null, aliases, and non-JSON scalars are not allowed)", path) -} - // Validate evaluates the source .proto rules without accessing external state. func Validate(cfg proto.Message) error { if err := protovalidate.Validate(cfg); err != nil { @@ -115,30 +47,6 @@ func Validate(cfg proto.Message) error { return nil } -// defaults fills absent fields, recursively. Unlike proto.Merge it never appends -// lists, and optional scalar presence preserves explicit false, zero, or empty. -func defaults(dst, src proto.Message) { - fillDefaults(dst.ProtoReflect(), src.ProtoReflect()) -} - -func fillDefaults(dst, src protoreflect.Message) { - src.Range(func(field protoreflect.FieldDescriptor, value protoreflect.Value) bool { - if !dst.Has(field) { - if field.Kind() == protoreflect.MessageKind && !field.IsMap() && !field.IsList() { - dst.Set(field, protoreflect.ValueOfMessage(proto.Clone(value.Message().Interface()).ProtoReflect())) - } else { - dst.Set(field, value) - } - } else if field.Kind() == protoreflect.MessageKind && !field.IsMap() && !field.IsList() { - // Well-known values (especially Duration{seconds:0}) are atomic. - if !strings.HasPrefix(string(field.Message().FullName()), "google.protobuf.") { - fillDefaults(dst.Get(field).Message(), value.Message()) - } - } - return true - }) -} - // FilePath resolves paths in a document relative to that document. func FilePath(configPath, value string) string { if value == "" || filepath.IsAbs(value) { diff --git a/go/core/pkg/config/load_test.go b/go/core/pkg/config/load_test.go index e9912c3677..dce615ebee 100644 --- a/go/core/pkg/config/load_test.go +++ b/go/core/pkg/config/load_test.go @@ -24,10 +24,14 @@ func TestControllerConfig(t *testing.T) { {"images JSON string", "harnessImages: '{}'", true}, {"duplicate", "logging:\n level: info\n level: debug", true}, {"unknown", "loging: {}", true}, - {"null", "logging: null", true}, + {"duplicate JSON", `{"logging":{"level":"info","level":"debug"}}`, true}, + {"null list item", "kubernetes: {watchNamespaces: [null]}", true}, + {"negative capture limit", "runtimeDefaults: {telemetry: {maxCaptureBytes: -1}}", true}, + {"invalid telemetry endpoint", "runtimeDefaults: {telemetry: {traces: {endpoint: 'file:///private'}}}", true}, + {"null", "logging: null", false}, {"type", "kubernetes: {leaderElection: 'false'}", true}, - {"alias", "logging: &log {level: info}\nruntimeDefaults: {logging: *log}", true}, - {"documents", "{}\n---\n{}", true}, + {"alias", "logging: &log {level: info}\nruntimeDefaults: {logging: *log}", false}, + {"documents", "{}\n---\n{}", false}, {"field aliases", "kubernetes: {leaderElection: true, leader_election: false}", true}, {"pool bounds", "database: {pool: {minConns: 9, maxConns: 4}}", true}, {"database schemas", "database: {schema: tenant, vectorSchema: public}", false}, @@ -95,7 +99,7 @@ func TestDefaultingPreservesPresence(t *testing.T) { require.Empty(t, cfg.Gateway.Push.SigningPrivateKeyFile) } -func TestEmptyIsNotAbsent(t *testing.T) { +func TestExplicitEmptyStringFailsSchemaValidation(t *testing.T) { cfg := &apiv1.CLIConfig{} require.NoError(t, config.Decode([]byte("connection: {userId: ''}"), cfg)) config.DefaultCLI(cfg) @@ -131,3 +135,60 @@ func TestDatabaseLogins(t *testing.T) { }) } } + +func TestDefaultingUsesProtoPresence(t *testing.T) { + for _, tc := range []struct { + name, input string + leaderElection bool + idleTTL time.Duration + limit *int64 + }{ + {name: "omitted", input: "{}", leaderElection: true, idleTTL: 7 * 24 * time.Hour}, + {name: "null", input: "kubernetes: {leaderElection: null}\nsessions: {idleTtl: null}\nruntimeDefaults: {maxContentLength: null}\ndatabase: {pool: {minConns: null}}", leaderElection: true, idleTTL: 7 * 24 * time.Hour}, + {name: "explicit zero", input: "kubernetes: {leaderElection: false}\nsessions: {idleTtl: 0s}\nruntimeDefaults: {maxContentLength: 0}\ndatabase: {pool: {minConns: 0}}", limit: new(int64(0))}, + } { + t.Run(tc.name, func(t *testing.T) { + cfg := &apiv1.ControllerConfig{} + require.NoError(t, config.Decode([]byte(tc.input), cfg)) + config.DefaultController(cfg) + setLogins(cfg) + require.NoError(t, config.Validate(cfg)) + require.Equal(t, tc.leaderElection, cfg.GetKubernetes().GetLeaderElection()) + require.Equal(t, tc.idleTTL, cfg.GetSessions().GetIdleTtl().AsDuration()) + require.Equal(t, tc.limit, cfg.GetRuntimeDefaults().MaxContentLength) + require.Zero(t, cfg.GetDatabase().GetPool().GetMinConns()) + require.Zero(t, cfg.GetSessions().GetShareMaxTtl().AsDuration()) + }) + } +} + +func TestYAMLConfigUsesLibraryScalarAndAliasSemantics(t *testing.T) { + cfg := &apiv1.ControllerConfig{} + require.NoError(t, config.Decode([]byte(` +logging: &logging + level: debug +runtimeDefaults: + logging: + <<: *logging +kubernetes: + leaderElection: off +database: + pool: {minConns: 0x10, maxConns: '32'} +telemetry: + resourceAttributes: {123: 'off'} +`), cfg)) + config.DefaultController(cfg) + setLogins(cfg) + require.NoError(t, config.Validate(cfg)) + require.Equal(t, "debug", cfg.GetRuntimeDefaults().GetLogging().GetLevel()) + require.False(t, cfg.GetKubernetes().GetLeaderElection()) + require.Equal(t, int32(16), cfg.GetDatabase().GetPool().GetMinConns()) + require.Equal(t, int32(32), cfg.GetDatabase().GetPool().GetMaxConns()) + require.Equal(t, map[string]string{"123": "off"}, cfg.GetTelemetry().GetResourceAttributes()) +} + +func TestYAMLConfigReadsOnlyFirstDocument(t *testing.T) { + cfg := &apiv1.ControllerConfig{} + require.NoError(t, config.Decode([]byte("logging: {level: debug}\n---\n["), cfg)) + require.Equal(t, "debug", cfg.GetLogging().GetLevel()) +} diff --git a/proto/kagent/api/v1alpha1/config.proto b/proto/kagent/api/v1alpha1/config.proto index 06a463a6ba..224547721c 100644 --- a/proto/kagent/api/v1alpha1/config.proto +++ b/proto/kagent/api/v1alpha1/config.proto @@ -178,9 +178,9 @@ message PostgresPoolConfig { option (buf.validate.message).cel = { id: "postgres_pool.bounds" message: "min_conns must not exceed max_conns" - expression: "!has(this.min_conns) || !has(this.max_conns) || this.min_conns <= this.max_conns" + expression: "!has(this.max_conns) || this.min_conns <= this.max_conns" }; - optional int32 min_conns = 1 [(buf.validate.field).int32.gte = 0]; + int32 min_conns = 1 [(buf.validate.field).int32.gte = 0]; optional int32 max_conns = 2 [(buf.validate.field).int32.gt = 0]; google.protobuf.Duration max_conn_idle_time = 3 [(buf.validate.field).duration = { gt: {} diff --git a/ui/src/generated/kagent/api/v1alpha1/config_pb.ts b/ui/src/generated/kagent/api/v1alpha1/config_pb.ts index 66960faa33..69eb04ad7c 100644 --- a/ui/src/generated/kagent/api/v1alpha1/config_pb.ts +++ b/ui/src/generated/kagent/api/v1alpha1/config_pb.ts @@ -13,7 +13,7 @@ import type { Message } from "@bufbuild/protobuf"; * Describes the file kagent/api/v1alpha1/config.proto. */ export const file_kagent_api_v1alpha1_config: GenFile = /*@__PURE__*/ - fileDesc("CiBrYWdlbnQvYXBpL3YxYWxwaGExL2NvbmZpZ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riAEBSACIAQESLgoJcmVzb3VyY2VzGAMgAygJQhu6SBiSARUiE3IREAEyDV5cUyg/Oi4qXFMpPyQSLgoJYXVkaWVuY2VzGAQgAygJQhu6SBiSARUiE3IREAEyDV5cUyg/Oi4qXFMpPyRCFQoTX3N0c193ZWxsX2tub3duX3VyaUJJWkdnaXRodWIuY29tL2thZ2VudC1kZXYva2FnZW50L2dvL2FwaS9nZW4va2FnZW50L2FwaS92MWFscGhhMTthcGl2MWFscGhhMWIGcHJvdG8z", [file_buf_validate_validate, file_google_protobuf_duration]); + fileDesc("CiBrYWdlbnQvYXBpL3YxYWxwaGExL2NvbmZpZy5wcm90bxITa2FnZW50LmFwaS52MWFscGhhMSKaAgoJQ0xJQ29uZmlnEjkKCmNvbm5lY3Rpb24YASABKAsyJS5rYWdlbnQuYXBpLnYxYWxwaGExLkNvbm5lY3Rpb25Db25maWcSMQoGb3V0cHV0GAIgASgLMiEua2FnZW50LmFwaS52MWFscGhhMS5PdXRwdXRDb25maWcSMwoHbG9nZ2luZxgDIAEoCzIiLmthZ2VudC5hcGkudjFhbHBoYTEuTG9nZ2luZ0NvbmZpZxIzCgdpbnN0YWxsGAQgASgLMiIua2FnZW50LmFwaS52MWFscGhhMS5JbnN0YWxsQ29uZmlnEjUKCGRhdGFiYXNlGAUgASgLMiMua2FnZW50LmFwaS52MWFscGhhMS5EYXRhYmFzZUNvbmZpZyLuAgoQQ29ubmVjdGlvbkNvbmZpZxIxCgdhcGlfdXJsGAEgASgJQhu6SBhyFjIRXmh0dHBzPzovL1teLz8jXSuIAQFIAIgBARI1CgtnYXRld2F5X3VybBgCIAEoCUIbukgYchYyEV5odHRwcz86Ly9bXi8/I10riAEBSAGIAQESHwoJbmFtZXNwYWNlGAMgASgJQge6SARyAhABSAKIAQESJAoHdXNlcl9pZBgEIAEoCUIOukgLcgkQATIFXlxTKyRIA4gBARI8Cgd0aW1lb3V0GAUgASgLMhkuZ29vZ2xlLnByb3RvYnVmLkR1cmF0aW9uQhC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25Db25maWcSGQoRZmlsZV9zZWFyY2hfdG9vbHMYByABKAgSFgoOYmFzaF92ZW52X3BhdGgYCCABKAlCFAoSX2NvbnRyb2xfcGxhbmVfdXJsQg4KDF9nYXRld2F5X3VybEIVChNfbWF4X2NvbnRlbnRfbGVuZ3RoIt4BChZUb2tlblByb3BhZ2F0aW9uQ29uZmlnEg8KB2VuYWJsZWQYASABKAgSPAoSc3RzX3dlbGxfa25vd25fdXJpGAIgASgJQhu6SBhyFjIRXmh0dHBzPzovL1teLz8jXSuIAQFIAIgBARIuCglyZXNvdXJjZXMYAyADKAlCG7pIGJIBFSITchEQATINXlxTKD86LipcUyk/JBIuCglhdWRpZW5jZXMYBCADKAlCG7pIGJIBFSITchEQATINXlxTKD86LipcUyk/JEIVChNfc3RzX3dlbGxfa25vd25fdXJpQklaR2dpdGh1Yi5jb20va2FnZW50LWRldi9rYWdlbnQvZ28vYXBpL2dlbi9rYWdlbnQvYXBpL3YxYWxwaGExO2FwaXYxYWxwaGExYgZwcm90bzM", [file_buf_validate_validate, file_google_protobuf_duration]); /** * CLIConfig is local CLI configuration. The executable selects this message; @@ -488,9 +488,9 @@ export const DatabaseLoginConfigSchema: GenMessage = /*@__P */ export type PostgresPoolConfig = Message<"kagent.api.v1alpha1.PostgresPoolConfig"> & { /** - * @generated from field: optional int32 min_conns = 1; + * @generated from field: int32 min_conns = 1; */ - minConns?: number | undefined; + minConns: number; /** * @generated from field: optional int32 max_conns = 2; From 64bbe6da203a2e409aac4195fa7cb1f4c8ac5e8b Mon Sep 17 00:00:00 2001 From: Eitan Yarmush Date: Tue, 13 Oct 2026 12:02:59 +0000 Subject: [PATCH 2/5] refactor: pass harness image config directly Signed-off-by: Eitan Yarmush --- go/core/internal/controller/collections.go | 2 +- .../internal/controller/collections_test.go | 10 +++---- .../internal/controller/preparation_test.go | 2 +- go/core/internal/controller/reconciler.go | 2 +- go/core/internal/controller/runtime.go | 3 +-- go/core/internal/translator/compiler.go | 7 ++--- go/core/internal/translator/compiler_test.go | 18 ++++++------- .../translator/image_compilation_test.go | 15 ++++++----- go/core/internal/translator/images.go | 21 ++++++--------- go/core/internal/translator/images_test.go | 27 ++++++++++--------- go/core/pkg/app/app.go | 5 ++-- go/core/pkg/app/images.go | 7 +++-- go/core/pkg/app/images_test.go | 7 ++--- 13 files changed, 59 insertions(+), 67 deletions(-) diff --git a/go/core/internal/controller/collections.go b/go/core/internal/controller/collections.go index f096e7e566..86cf4f1d4b 100644 --- a/go/core/internal/controller/collections.go +++ b/go/core/internal/controller/collections.go @@ -62,7 +62,7 @@ func (p AgentRuntimeObservation) Equals(other AgentRuntimeObservation) bool { // NewCollections creates the complete read-only input graph. An empty // watchNamespaces list watches all namespaces. -func NewCollections(client kube.Client, watchNamespaces []string, opts krt.OptionsBuilder, settings *apiv1.RuntimeDefaultsConfig, images translator.BuiltinImages) Collections { +func NewCollections(client kube.Client, watchNamespaces []string, opts krt.OptionsBuilder, settings *apiv1.RuntimeDefaultsConfig, images *apiv1.HarnessImagesConfig) Collections { sandboxTemplates := typedCollection[*kagentv1alpha3.SandboxTemplate](client, watchNamespaces, "SandboxTemplates", opts) agents := typedCollection[*kagentv1alpha3.Agent](client, watchNamespaces, "Agents", opts) agentTemplates := typedCollection[*kagentv1alpha3.AgentTemplate](client, watchNamespaces, "AgentTemplates", opts) diff --git a/go/core/internal/controller/collections_test.go b/go/core/internal/controller/collections_test.go index 5bf58bcdcd..67252419b9 100644 --- a/go/core/internal/controller/collections_test.go +++ b/go/core/internal/controller/collections_test.go @@ -64,7 +64,7 @@ func TestReconciliationCollectionsCompileAndObserveRevision(t *testing.T) { Harnesses: collections.Harnesses, AgentTemplates: collections.AgentTemplates, ResolvedModelConfigs: collections.ResolvedModelConfigs, RemoteMCPServers: collections.RemoteMCPServers, ConfigMaps: collections.ConfigMaps, Secrets: collections.Secrets, WorkerPools: collections.WorkerPools, - }, collections.AgentRuntimeObservations, opts, testRuntimeDefaults(), translator.BuiltinImages{}, + }, collections.AgentRuntimeObservations, opts, testRuntimeDefaults(), nil, ) collections.AgentStatuses = newAgentStatuses(collections.Agents, collections.Reconciliations, opts) @@ -230,7 +230,7 @@ func TestReconciliationWorkerPoolSandboxClass(t *testing.T) { Harnesses: krttest.GetMockCollection[*kagentv1alpha3.Harness](mock), AgentTemplates: templates, ResolvedModelConfigs: resolvedModels, RemoteMCPServers: krttest.GetMockCollection[*kagentv1alpha3.RemoteMCPServer](mock), ConfigMaps: configMaps, Secrets: secrets, WorkerPools: workerPools, - }, observations, opts, testRuntimeDefaults(), translator.BuiltinImages{}) + }, observations, opts, testRuntimeDefaults(), nil) key := "team-a/assistant" waitFor(t, func() bool { state := reconciliations.GetKey(key) @@ -371,7 +371,7 @@ func TestClaudeReconciliationCompilesActorTemplate(t *testing.T) { RemoteMCPServers: krttest.GetMockCollection[*kagentv1alpha3.RemoteMCPServer](mock), ConfigMaps: configMaps, Secrets: secrets, WorkerPools: krttest.GetMockCollection[*atev1alpha1.WorkerPool](mock), - }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testRuntimeDefaults(), translator.BuiltinImages{}, + }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testRuntimeDefaults(), nil, ) waitFor(t, func() bool { states := reconciliations.List() @@ -427,7 +427,7 @@ func TestCodexReconciliationCompilesActorTemplate(t *testing.T) { RemoteMCPServers: krttest.GetMockCollection[*kagentv1alpha3.RemoteMCPServer](mock), ConfigMaps: configMaps, Secrets: secrets, WorkerPools: krttest.GetMockCollection[*atev1alpha1.WorkerPool](mock), - }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testRuntimeDefaults(), translator.BuiltinImages{}, + }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testRuntimeDefaults(), nil, ) waitFor(t, func() bool { states := reconciliations.List() @@ -480,7 +480,7 @@ func TestReconciliationTracksSharedAgentTemplate(t *testing.T) { RemoteMCPServers: krttest.GetMockCollection[*kagentv1alpha3.RemoteMCPServer](mock), ConfigMaps: configMaps, Secrets: secrets, WorkerPools: krttest.GetMockCollection[*atev1alpha1.WorkerPool](mock), - }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testRuntimeDefaults(), translator.BuiltinImages{}, + }, krttest.GetMockCollection[AgentRuntimeObservation](mock), opts, testRuntimeDefaults(), nil, ) var initial string waitFor(t, func() bool { diff --git a/go/core/internal/controller/preparation_test.go b/go/core/internal/controller/preparation_test.go index 4f55218f1d..1e1db8b8eb 100644 --- a/go/core/internal/controller/preparation_test.go +++ b/go/core/internal/controller/preparation_test.go @@ -564,7 +564,7 @@ func newPreparationTestCollections(t *testing.T, workerPool string) (Collections Harnesses: collections.Harnesses, AgentTemplates: collections.AgentTemplates, ResolvedModelConfigs: collections.ResolvedModelConfigs, RemoteMCPServers: collections.RemoteMCPServers, ConfigMaps: collections.ConfigMaps, Secrets: collections.Secrets, WorkerPools: collections.WorkerPools, - }, collections.AgentRuntimeObservations, opts, testRuntimeDefaults(), translator.BuiltinImages{}) + }, collections.AgentRuntimeObservations, opts, testRuntimeDefaults(), nil) collections.AgentStatuses = newAgentStatuses(collections.Agents, collections.Reconciliations, opts) waitFor(t, func() bool { states := collections.Reconciliations.List() diff --git a/go/core/internal/controller/reconciler.go b/go/core/internal/controller/reconciler.go index ba832fb910..3346943515 100644 --- a/go/core/internal/controller/reconciler.go +++ b/go/core/internal/controller/reconciler.go @@ -98,7 +98,7 @@ func newAgentReconciliations( agentRuntimeObservations krt.Collection[AgentRuntimeObservation], opts krt.OptionsBuilder, settings *apiv1.RuntimeDefaultsConfig, - images translator.BuiltinImages, + images *apiv1.HarnessImagesConfig, ) krt.Collection[AgentReconciliation] { return krt.NewCollection(agents, func(ctx krt.HandlerContext, agent *kagentv1alpha3.Agent) *AgentReconciliation { state := &AgentReconciliation{Agent: agent} diff --git a/go/core/internal/controller/runtime.go b/go/core/internal/controller/runtime.go index 0ae55155b7..e9acd3b91f 100644 --- a/go/core/internal/controller/runtime.go +++ b/go/core/internal/controller/runtime.go @@ -10,7 +10,6 @@ import ( apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/core/internal/controller/apiclient" - "github.com/kagent-dev/kagent/go/core/internal/translator" ) // Runtime owns the Kubernetes client and common options shared by the KRT @@ -24,7 +23,7 @@ type Runtime struct { // NewRuntime creates the shared KRT client and collection graph. Handlers are // deliberately registered separately at the eventual application boundary. -func NewRuntime(config *rest.Config, watchNamespaces []string, stop <-chan struct{}, settings *apiv1.RuntimeDefaultsConfig, images translator.BuiltinImages) (*Runtime, error) { +func NewRuntime(config *rest.Config, watchNamespaces []string, stop <-chan struct{}, settings *apiv1.RuntimeDefaultsConfig, images *apiv1.HarnessImagesConfig) (*Runtime, error) { client, err := apiclient.New(config) if err != nil { return nil, fmt.Errorf("create KRT Kubernetes client: %w", err) diff --git a/go/core/internal/translator/compiler.go b/go/core/internal/translator/compiler.go index 54ac618881..b98b1636d4 100644 --- a/go/core/internal/translator/compiler.go +++ b/go/core/internal/translator/compiler.go @@ -9,6 +9,7 @@ import ( "istio.io/istio/pkg/kube/krt" "k8s.io/apimachinery/pkg/types" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/api/v1alpha3" ) @@ -18,7 +19,7 @@ type Compiler struct { ctx krt.HandlerContext collections Collections harnessCompilers map[HarnessType]HarnessCompiler - images BuiltinImages + images *apiv1.HarnessImagesConfig } // HarnessType identifies the runtime selected by a Harness. @@ -89,7 +90,7 @@ type AgentInputBinding struct { } // NewCompiler constructs the runtime compiler. -func NewCompiler(ctx krt.HandlerContext, collections Collections, harnessCompilers map[HarnessType]HarnessCompiler, images BuiltinImages) *Compiler { +func NewCompiler(ctx krt.HandlerContext, collections Collections, harnessCompilers map[HarnessType]HarnessCompiler, images *apiv1.HarnessImagesConfig) *Compiler { return &Compiler{ctx: ctx, collections: collections, harnessCompilers: maps.Clone(harnessCompilers), images: images} } @@ -155,7 +156,7 @@ func (c *Compiler) compileConfiguration(ctx context.Context, agentName string, h return nil, err } input.AgentName = agentName - image, err := c.images.image(harness) + image, err := harnessImage(harness, c.images) if err != nil { return nil, err } diff --git a/go/core/internal/translator/compiler_test.go b/go/core/internal/translator/compiler_test.go index 08a4ce87c0..94cb1290b7 100644 --- a/go/core/internal/translator/compiler_test.go +++ b/go/core/internal/translator/compiler_test.go @@ -193,7 +193,7 @@ func remoteMCPServer(name, url string) *v1alpha3.RemoteMCPServer { }} } -var testBuiltinImages = translator.BuiltinImages{ +var testHarnessImages = &apiv1.HarnessImagesConfig{ Kagent: "example.com/kagent@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", Codex: "example.com/codex@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", Claude: "example.com/claude@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", @@ -201,10 +201,10 @@ var testBuiltinImages = translator.BuiltinImages{ func compiler(t *testing.T, objects ...any) *translator.Compiler { t.Helper() - return compilerWithImages(t, testBuiltinImages, objects...) + return compilerWithImages(t, testHarnessImages, objects...) } -func compilerWithImages(t *testing.T, images translator.BuiltinImages, objects ...any) *translator.Compiler { +func compilerWithImages(t *testing.T, images *apiv1.HarnessImagesConfig, objects ...any) *translator.Compiler { t.Helper() collections := mockCollections(t, append(objects, defaultWorkerPool())...) ctx := krt.TestingDummyContext{} @@ -476,10 +476,10 @@ func TestCompilerAcceptsExternalHarnessCompiler(t *testing.T) { revision, err := translator.NewCompiler(krt.TestingDummyContext{}, collections, map[translator.HarnessType]translator.HarnessCompiler{ translator.HarnessTypeCodex: adapter, - }, testBuiltinImages).CompileAgent(context.Background(), inlineAgent(harness, template)) + }, testHarnessImages).CompileAgent(context.Background(), inlineAgent(harness, template)) require.NoError(t, err) require.Equal(t, "runnable-agent", revision.AgentName) - require.Equal(t, testBuiltinImages.Codex, revision.Image) + require.Equal(t, testHarnessImages.GetCodex(), revision.Image) require.Nil(t, adapter.input.Harness.Spec.Workload.Image, "adapters receive the requested spec") require.Equal(t, "runnable-agent", adapter.input.Root.Template.Name) require.Equal(t, modelConfig().Spec, adapter.input.Root.ResolvedModelConfig.Config.Spec) @@ -502,7 +502,7 @@ func TestCompilerRejectsStructuredOutputForUnsupportedHarness(t *testing.T) { _, err := translator.NewCompiler(krt.TestingDummyContext{}, collections, map[translator.HarnessType]translator.HarnessCompiler{ translator.HarnessTypeCodex: adapter, - }, testBuiltinImages).CompileAgent(context.Background(), inlineAgent(harness, template)) + }, testHarnessImages).CompileAgent(context.Background(), inlineAgent(harness, template)) require.ErrorContains(t, err, `Harness runtime "codex" does not support structured output`) require.Nil(t, adapter.input) } @@ -521,7 +521,7 @@ func TestCompilerRejectsUnusableModelConfigBeforeHarnessCompiler(t *testing.T) { _, err := translator.NewCompiler(krt.TestingDummyContext{}, collections, map[translator.HarnessType]translator.HarnessCompiler{ translator.HarnessTypeCodex: adapter, - }, testBuiltinImages).CompileAgent(context.Background(), inlineAgent(harness, template)) + }, testHarnessImages).CompileAgent(context.Background(), inlineAgent(harness, template)) require.ErrorContains(t, err, `resolve ModelConfig "default-model": secret missing not found`) require.Nil(t, adapter.input) } @@ -537,7 +537,7 @@ func TestCompilerPermitsBYOWithoutModelConfig(t *testing.T) { _, err := translator.NewCompiler(krt.TestingDummyContext{}, mockCollections(t, defaultWorkerPool(), harness), map[translator.HarnessType]translator.HarnessCompiler{ translator.HarnessTypeBYO: adapter, - }, testBuiltinImages).CompileAgent(context.Background(), inlineAgent(harness, template)) + }, testHarnessImages).CompileAgent(context.Background(), inlineAgent(harness, template)) require.NoError(t, err) require.Nil(t, adapter.input.Root.ResolvedModelConfig) } @@ -624,7 +624,7 @@ func TestCompileAgentInjectsCredentialsAtGateway(t *testing.T) { rotated.Data["token"] = []byte("rotated-token") rotatedCompiler := translator.NewCompiler(krt.TestingDummyContext{}, mockCollections(t, modelConfig(), server, secondServer, rotated, secondSecret, defaultWorkerPool(), harness), map[translator.HarnessType]translator.HarnessCompiler{ translator.HarnessTypeKagent: kagenttranslator.NewCompiler(krt.TestingDummyContext{}, mockCollections(t, modelConfig(), server, secondServer, rotated, secondSecret), testRuntimeDefaults()), - }, testBuiltinImages) + }, testHarnessImages) next, err := rotatedCompiler.CompileAgent(t.Context(), inlineAgent(harness, template)) require.NoError(t, err) nextDigest, err := next.Digest() diff --git a/go/core/internal/translator/image_compilation_test.go b/go/core/internal/translator/image_compilation_test.go index 901ffa881d..f6125ed806 100644 --- a/go/core/internal/translator/image_compilation_test.go +++ b/go/core/internal/translator/image_compilation_test.go @@ -7,6 +7,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/api/v1alpha3" "github.com/kagent-dev/kagent/go/core/internal/translator" ) @@ -17,9 +18,9 @@ func TestCompileDefaultImageRevision(t *testing.T) { spec v1alpha3.HarnessSpec image string }{ - {"kagent", v1alpha3.HarnessSpec{Kagent: &v1alpha3.KagentHarness{}}, testBuiltinImages.Kagent}, - {"claude", v1alpha3.HarnessSpec{Claude: &v1alpha3.ClaudeHarness{}}, testBuiltinImages.Claude}, - {"codex", v1alpha3.HarnessSpec{Codex: &v1alpha3.CodexHarness{}}, testBuiltinImages.Codex}, + {"kagent", v1alpha3.HarnessSpec{Kagent: &v1alpha3.KagentHarness{}}, testHarnessImages.GetKagent()}, + {"claude", v1alpha3.HarnessSpec{Claude: &v1alpha3.ClaudeHarness{}}, testHarnessImages.GetClaude()}, + {"codex", v1alpha3.HarnessSpec{Codex: &v1alpha3.CodexHarness{}}, testHarnessImages.GetCodex()}, } { t.Run(variant.name, func(t *testing.T) { harness := &v1alpha3.Harness{ObjectMeta: metav1.ObjectMeta{Name: "runtime", Namespace: "test"}, Spec: *variant.spec.DeepCopy()} @@ -39,19 +40,19 @@ func TestCompileDefaultImageRevision(t *testing.T) { model.Spec.APIKeySecretKey = "key" } secret := &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "auth", Namespace: "test"}, Data: map[string][]byte{"key": []byte("secret")}} - compile := func(images translator.BuiltinImages) *translator.CompileResult { + compile := func(images *apiv1.HarnessImagesConfig) *translator.CompileResult { t.Helper() result, err := compilerWithImages(t, images, model, secret, harness).CompileAgent(t.Context(), agent) require.NoError(t, err) return result } - first := compile(testBuiltinImages) + first := compile(testHarnessImages) require.Equal(t, variant.image, first.Image) before, err := first.Digest() require.NoError(t, err) require.Nil(t, harness.Spec.Workload.Image, "compilation must not mutate source resources") changed := "mirror/runtime@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" - images := translator.BuiltinImages{Kagent: changed, Claude: changed, Codex: changed} + images := &apiv1.HarnessImagesConfig{Kagent: changed, Claude: changed, Codex: changed} second := compile(images) require.Equal(t, changed, second.Image) require.JSONEq(t, string(first.Provenance), string(second.Provenance), "release defaults are not Kubernetes inputs") @@ -60,7 +61,7 @@ func TestCompileDefaultImageRevision(t *testing.T) { require.NotEqual(t, before, after) require.Equal(t, variant.image, first.Image, "already compiled revisions stay immutable") harness.Spec.Workload.Image = new(variant.image) - explicit := compile(translator.BuiltinImages{}) + explicit := compile(nil) require.Equal(t, variant.image, explicit.Image) unrelated := compile(images) explicitID, err := explicit.Digest() diff --git a/go/core/internal/translator/images.go b/go/core/internal/translator/images.go index 1a9473ced1..95dfdf7275 100644 --- a/go/core/internal/translator/images.go +++ b/go/core/internal/translator/images.go @@ -1,27 +1,22 @@ package translator -import "github.com/kagent-dev/kagent/go/core/internal/image" +import ( + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" + "github.com/kagent-dev/kagent/go/core/internal/image" +) -// BuiltinImages supplies release images without performing registry I/O. -// Missing entries only prevent compilation of agents that need that default. -type BuiltinImages struct { - Kagent string - Claude string - Codex string -} - -func (b BuiltinImages) image(harness *HarnessConfiguration) (string, error) { +func harnessImage(harness *HarnessConfiguration, images *apiv1.HarnessImagesConfig) (string, error) { var selected string if override := harness.Spec.Workload.Image; override != nil { selected = *override } else { switch harnessType(harness) { case HarnessTypeKagent: - selected = b.Kagent + selected = images.GetKagent() case HarnessTypeClaude: - selected = b.Claude + selected = images.GetClaude() case HarnessTypeCodex: - selected = b.Codex + selected = images.GetCodex() case HarnessTypeBYO: return "", NewValidationError("BYO harnesses must specify workload.image") } diff --git a/go/core/internal/translator/images_test.go b/go/core/internal/translator/images_test.go index 25d7186408..7c93b2bb16 100644 --- a/go/core/internal/translator/images_test.go +++ b/go/core/internal/translator/images_test.go @@ -6,54 +6,55 @@ import ( "github.com/stretchr/testify/require" + apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" "github.com/kagent-dev/kagent/go/api/v1alpha3" ) func TestHarnessImage(t *testing.T) { const digest = "@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - images := BuiltinImages{Kagent: "registry/kagent" + digest, Claude: "registry/claude" + digest, Codex: "registry/codex" + digest} + images := &apiv1.HarnessImagesConfig{Kagent: "registry/kagent" + digest, Claude: "registry/claude" + digest, Codex: "registry/codex" + digest} for _, tt := range []struct { name string spec v1alpha3.HarnessSpec want string }{ - {"kagent", v1alpha3.HarnessSpec{Kagent: &v1alpha3.KagentHarness{}}, images.Kagent}, - {"claude", v1alpha3.HarnessSpec{Claude: &v1alpha3.ClaudeHarness{}}, images.Claude}, - {"codex", v1alpha3.HarnessSpec{Codex: &v1alpha3.CodexHarness{}}, images.Codex}, + {"kagent", v1alpha3.HarnessSpec{Kagent: &v1alpha3.KagentHarness{}}, images.GetKagent()}, + {"claude", v1alpha3.HarnessSpec{Claude: &v1alpha3.ClaudeHarness{}}, images.GetClaude()}, + {"codex", v1alpha3.HarnessSpec{Codex: &v1alpha3.CodexHarness{}}, images.GetCodex()}, } { t.Run(tt.name, func(t *testing.T) { harness := &HarnessConfiguration{Spec: tt.spec} - got, err := images.image(harness) + got, err := harnessImage(harness, images) require.NoError(t, err) require.Equal(t, tt.want, got) require.Nil(t, harness.Spec.Workload.Image) - _, err = (BuiltinImages{}).image(harness) + _, err = harnessImage(harness, nil) require.ErrorContains(t, err, "no default image configured for "+tt.name) harness.Spec.Workload.Image = new("mirror/override" + digest) - got, err = (BuiltinImages{}).image(harness) + got, err = harnessImage(harness, nil) require.NoError(t, err) require.Equal(t, *harness.Spec.Workload.Image, got) for _, invalid := range []string{"", "registry/image:latest", "registry/image@sha256:" + strings.Repeat("a", 63)} { harness.Spec.Workload.Image = new(invalid) - _, err = images.image(harness) + _, err = harnessImage(harness, images) require.ErrorContains(t, err, "must be pinned by sha256 digest") } }) } t.Run("BYO requires an explicit image", func(t *testing.T) { harness := &HarnessConfiguration{Spec: v1alpha3.HarnessSpec{BYO: &v1alpha3.BYOHarness{}}} - _, err := images.image(harness) + _, err := harnessImage(harness, images) require.ErrorContains(t, err, "BYO harnesses must specify workload.image") harness.Spec.Workload.Image = new("registry/byo" + digest) - got, err := images.image(harness) + got, err := harnessImage(harness, images) require.NoError(t, err) require.Equal(t, *harness.Spec.Workload.Image, got) }) t.Run("only the selected default is needed", func(t *testing.T) { - partial := BuiltinImages{Kagent: images.Kagent, Claude: "invalid"} - _, err := partial.image(&HarnessConfiguration{Spec: v1alpha3.HarnessSpec{Kagent: &v1alpha3.KagentHarness{}}}) + partial := &apiv1.HarnessImagesConfig{Kagent: images.GetKagent(), Claude: "invalid"} + _, err := harnessImage(&HarnessConfiguration{Spec: v1alpha3.HarnessSpec{Kagent: &v1alpha3.KagentHarness{}}}, partial) require.NoError(t, err) - _, err = partial.image(&HarnessConfiguration{Spec: v1alpha3.HarnessSpec{Claude: &v1alpha3.ClaudeHarness{}}}) + _, err = harnessImage(&HarnessConfiguration{Spec: v1alpha3.HarnessSpec{Claude: &v1alpha3.ClaudeHarness{}}}, partial) require.ErrorContains(t, err, "must be pinned by sha256 digest") }) } diff --git a/go/core/pkg/app/app.go b/go/core/pkg/app/app.go index efb3e50007..7878724a40 100644 --- a/go/core/pkg/app/app.go +++ b/go/core/pkg/app/app.go @@ -184,8 +184,7 @@ func Run(ctx context.Context, input *apiv1.ControllerConfig, opts Options) error quiescenceInterval := cfg.GetSessions().GetQuiescenceRecoveryInterval().AsDuration() logger := slog.Default() ctx = logging.IntoContext(ctx, logger) - images, err := builtinImages(cfg.GetHarnessImages(), version.Version) - if err != nil { + if err := validateHarnessImagesRelease(cfg.GetHarnessImages(), version.Version); err != nil { return err } telemetryOptions := telemetry.Options{Config: config.Telemetry(cfg.GetTelemetry()), Defaults: []attribute.KeyValue{ @@ -273,7 +272,7 @@ func Run(ctx context.Context, input *apiv1.ControllerConfig, opts Options) error if err != nil { return fmt.Errorf("create controller manager: %w", err) } - runtime, err := controller.NewRuntime(kubeConfig, watchNamespaces, ctx.Done(), cfg.GetRuntimeDefaults(), images) + runtime, err := controller.NewRuntime(kubeConfig, watchNamespaces, ctx.Done(), cfg.GetRuntimeDefaults(), cfg.GetHarnessImages()) if err != nil { return err } diff --git a/go/core/pkg/app/images.go b/go/core/pkg/app/images.go index bd6f3512d5..930593493e 100644 --- a/go/core/pkg/app/images.go +++ b/go/core/pkg/app/images.go @@ -5,12 +5,11 @@ import ( "strings" apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" - "github.com/kagent-dev/kagent/go/core/internal/translator" ) -func builtinImages(cfg *apiv1.HarnessImagesConfig, release string) (translator.BuiltinImages, error) { +func validateHarnessImagesRelease(cfg *apiv1.HarnessImagesConfig, release string) error { if cfg.GetRelease() != "" && strings.TrimPrefix(cfg.GetRelease(), "v") != strings.TrimPrefix(release, "v") { - return translator.BuiltinImages{}, fmt.Errorf("built-in Harness images release %q does not match controller release %q", cfg.GetRelease(), release) + return fmt.Errorf("built-in Harness images release %q does not match controller release %q", cfg.GetRelease(), release) } - return translator.BuiltinImages{Kagent: cfg.GetKagent(), Claude: cfg.GetClaude(), Codex: cfg.GetCodex()}, nil + return nil } diff --git a/go/core/pkg/app/images_test.go b/go/core/pkg/app/images_test.go index a5172726ef..807382940f 100644 --- a/go/core/pkg/app/images_test.go +++ b/go/core/pkg/app/images_test.go @@ -8,7 +8,7 @@ import ( apiv1 "github.com/kagent-dev/kagent/go/api/gen/kagent/api/v1alpha1" ) -func TestBuiltinImages(t *testing.T) { +func TestValidateHarnessImagesRelease(t *testing.T) { for _, tt := range []struct { name, release, wantErr string input *apiv1.HarnessImagesConfig @@ -19,14 +19,11 @@ func TestBuiltinImages(t *testing.T) { {name: "wrong release", input: &apiv1.HarnessImagesConfig{Release: "1.0.0-alpha8"}, release: "1.0.0-alpha9", wantErr: "does not match controller release"}, } { t.Run(tt.name, func(t *testing.T) { - images, err := builtinImages(tt.input, tt.release) + err := validateHarnessImagesRelease(tt.input, tt.release) if tt.wantErr != "" { require.ErrorContains(t, err, tt.wantErr) } else { require.NoError(t, err) - require.Equal(t, tt.input.GetKagent(), images.Kagent) - require.Equal(t, tt.input.GetClaude(), images.Claude) - require.Equal(t, tt.input.GetCodex(), images.Codex) } }) } From 683efbe5900a1df26f6b5897536c3fa560c54675 Mon Sep 17 00:00:00 2001 From: Eitan Yarmush Date: Wed, 14 Oct 2026 13:45:52 +0000 Subject: [PATCH 3/5] fix(codex): drain stdout before waiting for process exit Signed-off-by: Eitan Yarmush --- go/harness/codex/internal/driver/process.go | 80 ++++++++++--------- .../codex/internal/driver/process_test.go | 58 +++++++++++++- go/harness/codex/internal/driver/rpc.go | 10 ++- 3 files changed, 103 insertions(+), 45 deletions(-) diff --git a/go/harness/codex/internal/driver/process.go b/go/harness/codex/internal/driver/process.go index 07e9354e1f..e128418a71 100644 --- a/go/harness/codex/internal/driver/process.go +++ b/go/harness/codex/internal/driver/process.go @@ -11,6 +11,7 @@ import ( "os/exec" "path/filepath" "strings" + "sync" "time" "github.com/kagent-dev/kagent/go/harness/internal/utils" @@ -47,6 +48,7 @@ type processSession struct { wait <-chan error stderr *utils.BoundedBuffer translator *eventTranslator + stopOnce sync.Once } // pendingTurn owns an App Server process blocked on the correlated server @@ -108,13 +110,18 @@ func (d *ProcessDriver) Run(ctx context.Context, turn runtime.Turn, sink runtime return runtime.Outcome{}, fmt.Errorf("start Codex App Server: %w", err) } wait := make(chan error, 1) - go func() { wait <- command.Wait(); close(wait) }() client := newRPCClient(stdin, stdout, d.config.MaxFrameBytes) + go func() { + // Wait closes StdoutPipe; let the RPC reader consume the final reports first. + <-client.readDone + wait <- command.Wait() + close(wait) + }() session := &processSession{command: command, stdin: stdin, client: client, wait: wait, stderr: stderr} sessionOwnedByPendingTurn := false defer func() { if !sessionOwnedByPendingTurn { - d.stopSession(session) + d.stopSession(session, sink) } }() @@ -200,14 +207,12 @@ func (d *ProcessDriver) consume(ctx context.Context, session *processSession, si case <-ctx.Done(): interrupted := time.Now() err := d.interrupt(session, sink) - drained := session.drainUsage(sink) if err != nil { _ = utils.KillProcessGroup(session.command.Process) } // An interrupt response can precede the final usage report. Let Codex // flush it on stdin EOF before escalating to process-group signals. - d.stopSession(session) - <-drained + d.stopSession(session, sink) translator.flushOpenCall(interrupted, sink) return runtime.Outcome{}, ctx.Err() case waitErr := <-wait: @@ -373,7 +378,7 @@ func (p *pendingTurn) Resume(ctx context.Context, response runtime.InputResponse sessionOwnedByPendingTurn := false defer func() { if !sessionOwnedByPendingTurn { - p.driver.stopSession(p.session) + p.driver.stopSession(p.session, sink) } }() native, err := codexInputResponse(p.request, response) @@ -400,14 +405,12 @@ func (p *pendingTurn) Cancel(_ context.Context, sink runtime.ModelCallSink) erro if responded { _ = p.driver.interrupt(p.session, sink) } - drained := p.session.drainUsage(sink) - p.driver.stopSession(p.session) - <-drained + p.driver.stopSession(p.session, sink) return nil } // interrupt asks Codex to stop the turn. Usage and final errors Codex reports until it answers, -// including buffered ones, still reach sink; drainUsage records what arrives after. +// including buffered ones, still reach sink; stopSession records what arrives after. func (d *ProcessDriver) interrupt(session *processSession, sink runtime.ModelCallSink) error { ctx, cancel := context.WithTimeout(context.Background(), d.config.InterruptGrace) defer cancel() @@ -416,20 +419,10 @@ func (d *ProcessDriver) interrupt(session *processSession, sink runtime.ModelCal return err } -// drainUsage records usage from the frames left until the reader stops. Start it before -// stopping Codex, so a full frame buffer cannot drop or block Codex's last writes. -func (s *processSession) drainUsage(sink runtime.ModelCallSink) <-chan struct{} { - drained := make(chan struct{}) - go func() { - defer close(drained) - for frame := range s.client.frames { - s.recordUsage(frame.message, sink) - } - }() - return drained -} - func (s *processSession) recordUsage(message rpcMessage, sink runtime.ModelCallSink) { + if s.translator == nil { + return // Initialization failed before a turn started. + } switch message.Method { case "thread/tokenUsage/updated": _ = s.translator.usage(message.Params, sink) @@ -487,21 +480,34 @@ func codexInputResponse(request runtime.InputRequest, response runtime.InputResp } } -func (d *ProcessDriver) stopSession(session *processSession) { - _ = session.stdin.Close() - select { - case <-session.wait: - return - case <-time.After(d.config.InterruptGrace): - } +func (d *ProcessDriver) stopSession(session *processSession, sink runtime.ModelCallSink) { + session.stopOnce.Do(func() { + // Drain on every exit path so a full frame buffer cannot block the reader + // and prevent Wait from reaping the process. + drained := make(chan struct{}) + go func() { + defer close(drained) + for frame := range session.client.frames { + session.recordUsage(frame.message, sink) + } + }() + defer func() { <-drained }() - _ = utils.TerminateProcessGroup(session.command.Process) - select { - case <-session.wait: - case <-time.After(d.config.InterruptGrace): - _ = utils.KillProcessGroup(session.command.Process) - <-session.wait - } + _ = session.stdin.Close() + select { + case <-session.wait: + return + case <-time.After(d.config.InterruptGrace): + } + + _ = utils.TerminateProcessGroup(session.command.Process) + select { + case <-session.wait: + case <-time.After(d.config.InterruptGrace): + _ = utils.KillProcessGroup(session.command.Process) + <-session.wait + } + }) } var _ runtime.PendingTurn = (*pendingTurn)(nil) diff --git a/go/harness/codex/internal/driver/process_test.go b/go/harness/codex/internal/driver/process_test.go index 25f97f3fbf..6205d40b93 100644 --- a/go/harness/codex/internal/driver/process_test.go +++ b/go/harness/codex/internal/driver/process_test.go @@ -100,6 +100,11 @@ read turn printf '%s\n' '{"id":3,"result":{"turn":{"id":"turn-1"}}}' printf '%s\n' '{"method":"turn/completed","params":{"threadId":"thread-1","turn":{"id":"turn-1","status":"completed"}}}' while read ignored; do :; done +i=0 +while [ "$i" -lt 128 ]; do + printf '%s\n' '{"method":"thread/name/updated","params":{"threadId":"thread-1","threadName":"done"}}' + i=$((i + 1)) +done printf graceful > "$EXIT_CAPTURE" ` if err := os.WriteFile(executable, []byte(script), 0o700); err != nil { @@ -126,6 +131,41 @@ printf graceful > "$EXIT_CAPTURE" } } +func TestProcessDriverDrainsAfterInitializationFailure(t *testing.T) { + directory := t.TempDir() + executable := filepath.Join(directory, "codex") + exitCapture := filepath.Join(directory, "exit") + script := `#!/bin/sh +read initialize +printf '%s\n' '{"id":1,"error":{"code":-32603,"message":"initialization failed"}}' +while read ignored; do :; done +i=0 +while [ "$i" -lt 128 ]; do + printf '%s\n' '{"method":"thread/tokenUsage/updated","params":{}}' + i=$((i + 1)) +done +printf graceful > "$EXIT_CAPTURE" +` + if err := os.WriteFile(executable, []byte(script), 0o700); err != nil { + t.Fatal(err) + } + driver := NewProcessDriver(ProcessConfig{ + Executable: executable, Workspace: directory, + Environment: append(os.Environ(), "EXIT_CAPTURE="+exitCapture), MaxFrameBytes: 4096, + MaxStderrBytes: 1024, InterruptGrace: time.Second, + }) + if _, err := driver.Run(t.Context(), runtime.Turn{Prompt: "hello"}, &recordingSink{}); err == nil || !strings.Contains(err.Error(), "initialization failed") { + t.Fatalf("Run() error = %v, want initialization failed", err) + } + exit, err := os.ReadFile(exitCapture) + if err != nil { + t.Fatal(err) + } + if string(exit) != "graceful" { + t.Fatalf("app-server exit = %q, want graceful stdin EOF", exit) + } +} + func TestProcessDriverSharedAgentNotifications(t *testing.T) { for _, tc := range []struct { name, fixture string @@ -563,9 +603,14 @@ printf '%s\n' '{"id":3,"result":{"turn":{"id":"turn-1"}}}' read interrupt printf '%s\n' '{"method":"thread/tokenUsage/updated","params":{"threadId":"thread-1","turnId":"turn-1","tokenUsage":{"total":{"inputTokens":10,"outputTokens":1},"last":{"inputTokens":10,"outputTokens":1}}}}' printf '%s\n' '{"id":4,"result":{}}' -# Flush the final usage report only when the driver requests graceful shutdown. +# Flush the final usage reports only when the driver requests graceful shutdown. while read ignored; do :; done -printf '%s\n' '{"method":"thread/tokenUsage/updated","params":{"threadId":"thread-1","turnId":"turn-1","tokenUsage":{"total":{"inputTokens":20,"outputTokens":2},"last":{"inputTokens":10,"outputTokens":1}}}}' +# Exceed the RPC frame buffer so the reader must keep draining after process exit. +i=2 +while [ "$i" -le 128 ]; do + printf '{"method":"thread/tokenUsage/updated","params":{"threadId":"thread-1","turnId":"turn-1","tokenUsage":{"total":{"inputTokens":%s,"outputTokens":%s},"last":{"inputTokens":10,"outputTokens":1}}}}\n' "$((i * 10))" "$i" + i=$((i + 1)) +done ` if err := os.WriteFile(executable, []byte(script), 0o700); err != nil { t.Fatal(err) @@ -592,8 +637,13 @@ printf '%s\n' '{"method":"thread/tokenUsage/updated","params":{"threadId":"threa t.Fatalf("Run() error = %v, want context.Canceled", err) } // Codex reports usage while it answers the interrupt and after it. - if len(sink.models) != 2 { - t.Fatalf("model calls = %d, want the 2 Codex reported", len(sink.models)) + if len(sink.models) != 128 { + t.Fatalf("model calls = %d, want the 128 Codex reported", len(sink.models)) + } + for i, call := range sink.models { + if call.InputTokens != 10 || call.OutputTokens != 1 || call.UsagePartial { + t.Fatalf("model call %d = %+v, want the complete reported usage", i, call) + } } } diff --git a/go/harness/codex/internal/driver/rpc.go b/go/harness/codex/internal/driver/rpc.go index 99e470b2c3..377edffc88 100644 --- a/go/harness/codex/internal/driver/rpc.go +++ b/go/harness/codex/internal/driver/rpc.go @@ -39,18 +39,20 @@ type rpcFrame struct { // rpcClient owns newline-delimited JSON-RPC framing for one App Server // process. App Server notifications share the same stream as call responses. type rpcClient struct { - writer io.WriteCloser - writeMu sync.Mutex - frames chan rpcFrame + writer io.WriteCloser + writeMu sync.Mutex + frames chan rpcFrame + readDone chan struct{} } func newRPCClient(writer io.WriteCloser, reader io.Reader, maxFrameBytes int) *rpcClient { - client := &rpcClient{writer: writer, frames: make(chan rpcFrame, 16)} + client := &rpcClient{writer: writer, frames: make(chan rpcFrame, 16), readDone: make(chan struct{})} go client.read(reader, maxFrameBytes) return client } func (c *rpcClient) read(reader io.Reader, max int) { + defer close(c.readDone) defer close(c.frames) buffered := bufio.NewReaderSize(reader, max+1) for { From 8b40c9328eab8b99e190157d739a98231eac2228 Mon Sep 17 00:00:00 2001 From: Eitan Yarmush Date: Wed, 14 Oct 2026 15:37:14 +0000 Subject: [PATCH 4/5] test: use current image settings in validation regression Signed-off-by: Eitan Yarmush --- go/core/internal/controller/collections_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/core/internal/controller/collections_test.go b/go/core/internal/controller/collections_test.go index 67252419b9..4e752646fe 100644 --- a/go/core/internal/controller/collections_test.go +++ b/go/core/internal/controller/collections_test.go @@ -160,7 +160,7 @@ func TestReconciliationReportsRuntimeValidationAsUnsupported(t *testing.T) { Harnesses: krttest.GetMockCollection[*kagentv1alpha3.Harness](mock), AgentTemplates: krttest.GetMockCollection[*kagentv1alpha3.AgentTemplate](mock), ResolvedModelConfigs: resolvedModels, ConfigMaps: configMaps, Secrets: secrets, RemoteMCPServers: krttest.GetMockCollection[*kagentv1alpha3.RemoteMCPServer](mock), WorkerPools: krttest.GetMockCollection[*atev1alpha1.WorkerPool](mock), - }, krt.NewStaticCollection[AgentRuntimeObservation](nil, nil, opts.WithName("Observations")...), opts, settings, translator.BuiltinImages{}, + }, krt.NewStaticCollection[AgentRuntimeObservation](nil, nil, opts.WithName("Observations")...), opts, settings, nil, ) waitFor(t, func() bool { return states.GetKey("team-a/assistant") != nil }) state := states.GetKey("team-a/assistant") From 4cef9eb1d93a5e8175a3dfcbce13b7383ebe6503 Mon Sep 17 00:00:00 2001 From: Eitan Yarmush Date: Wed, 14 Oct 2026 20:10:05 +0000 Subject: [PATCH 5/5] fix: validate runtime telemetry defaults at startup Signed-off-by: Eitan Yarmush --- go/core/pkg/app/app.go | 3 +++ go/core/pkg/app/app_test.go | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/go/core/pkg/app/app.go b/go/core/pkg/app/app.go index 7878724a40..54cafb9cb2 100644 --- a/go/core/pkg/app/app.go +++ b/go/core/pkg/app/app.go @@ -159,6 +159,9 @@ func Run(ctx context.Context, input *apiv1.ControllerConfig, opts Options) error if err := config.Validate(cfg); err != nil { return err } + if err := config.Telemetry(cfg.GetRuntimeDefaults().GetTelemetry()).Validate(); err != nil { + return fmt.Errorf("runtimeDefaults: %w", err) + } // The read/write login serves every runtime query and verifies migrations // when they are skipped. The owner login only creates the schema and migrates. readWriteConfig, err := databasePoolConfig("database.readWrite", cfg.GetDatabase().GetReadWrite()) diff --git a/go/core/pkg/app/app_test.go b/go/core/pkg/app/app_test.go index 4a820966fc..55abf02aba 100644 --- a/go/core/pkg/app/app_test.go +++ b/go/core/pkg/app/app_test.go @@ -181,6 +181,33 @@ func TestRunRejectsInvalidConfigBeforeIO(t *testing.T) { require.ErrorContains(t, Run(t.Context(), cfg, Options{}), "quiescence_recovery_interval") } +func TestRunRejectsInvalidRuntimeTelemetryBeforeIO(t *testing.T) { + for _, endpoint := range []string{"http://:4317", "https://%20"} { + for _, test := range []struct { + name string + telemetry *apiv1.TelemetryConfig + }{ + {name: "traces", telemetry: &apiv1.TelemetryConfig{Traces: &apiv1.OTLPConfig{Endpoint: endpoint}}}, + {name: "metrics", telemetry: &apiv1.TelemetryConfig{Metrics: &apiv1.OTLPConfig{Endpoint: endpoint}}}, + {name: "logs", telemetry: &apiv1.TelemetryConfig{Logs: &apiv1.OTLPConfig{Endpoint: endpoint}}}, + } { + t.Run(test.name+"/"+endpoint, func(t *testing.T) { + cfg := &apiv1.ControllerConfig{ + Database: &apiv1.DatabaseConfig{ + SkipMigrations: true, + ReadWrite: &apiv1.DatabaseLoginConfig{ + UrlFile: filepath.Join(t.TempDir(), "missing-secret"), Role: "kagent_readwrite", + }, + }, + RuntimeDefaults: &apiv1.RuntimeDefaultsConfig{Telemetry: test.telemetry}, + } + require.EqualError(t, Run(t.Context(), cfg, Options{}), + "runtimeDefaults: telemetry."+test.name+".endpoint must be an HTTP(S) URL") + }) + } + } +} + // With migrations skipped the owner login is never read, so Run gets past its // configuration and fails only when the read/write login cannot connect. func TestRunSkippingMigrationsNeedsNoOwner(t *testing.T) {