Browse Source

fix(agent): substitute namespace in runtime environment

The lambdagent template references $(metadata.namespace), but the Agent controller did not expose that placeholder in component variables. Pods therefore received an invalid agent ID containing the literal placeholder, and Remote Service rejected runs with HTTP 422.

- Add metadata.namespace to Agent component template variables
- Preserve existing agent name and UID substitution behavior
KongLingTT 1 month ago
parent
commit
408017c549
1 changed files with 4 additions and 3 deletions
  1. 4 3
      internal/controller/agent_controller.go

+ 4 - 3
internal/controller/agent_controller.go

@@ -148,9 +148,10 @@ func (r *AgentReconciler) reconcileComponent(ctx context.Context, agent *v1alpha
 		comp.Spec.Category = "Agent"
 		comp.Spec.Template = &tmpl
 		comp.Spec.Variables = map[string]string{
-			"systemPrompt": agent.Spec.SystemPrompt,
-			"agentName":    agent.Name,
-			"agentUid":     string(agent.UID),
+			"systemPrompt":       agent.Spec.SystemPrompt,
+			"agentName":          agent.Name,
+			"agentUid":           string(agent.UID),
+			"metadata.namespace": agent.Namespace,
 		}
 		comp.Spec.Dependencies = dependencies
 		if agent.Spec.StackRef != nil {