@@ -650,6 +650,113 @@ var _ = Describe("Agent Controller", func() {
650650 Expect (deployment .Spec .Template .Spec .Containers [0 ].Image ).To (Equal (agentImage ))
651651 })
652652
653+ It ("should use default framework from AgentRuntimeConfiguration when agent has no framework" , func () {
654+ config := & runtimev1alpha1.AgentRuntimeConfiguration {
655+ ObjectMeta : metav1.ObjectMeta {
656+ Name : "test-config-default-fw" ,
657+ Namespace : "default" ,
658+ },
659+ Spec : runtimev1alpha1.AgentRuntimeConfigurationSpec {
660+ DefaultFramework : "msaf" ,
661+ },
662+ }
663+ Expect (k8sClient .Create (ctx , config )).To (Succeed ())
664+
665+ agent := & runtimev1alpha1.Agent {
666+ ObjectMeta : metav1.ObjectMeta {
667+ Name : "test-agent-default-fw" ,
668+ Namespace : "default" ,
669+ },
670+ Spec : runtimev1alpha1.AgentSpec {
671+ // No framework specified - should use config's defaultFramework
672+ Protocols : []runtimev1alpha1.AgentProtocol {
673+ {Type : runtimev1alpha1 .A2AProtocol , Port : 8000 , Path : "/" , Name : "a2a" },
674+ },
675+ },
676+ }
677+ Expect (k8sClient .Create (ctx , agent )).To (Succeed ())
678+
679+ _ , err := reconciler .Reconcile (ctx , reconcile.Request {
680+ NamespacedName : types.NamespacedName {Name : "test-agent-default-fw" , Namespace : "default" },
681+ })
682+ Expect (err ).NotTo (HaveOccurred ())
683+
684+ deployment := & appsv1.Deployment {}
685+ Expect (k8sClient .Get (ctx , types.NamespacedName {Name : "test-agent-default-fw" , Namespace : "default" }, deployment )).To (Succeed ())
686+ Expect (deployment .Spec .Template .Spec .Containers ).To (HaveLen (1 ))
687+ // Should use MSAF template image since defaultFramework is msaf
688+ Expect (deployment .Spec .Template .Spec .Containers [0 ].Image ).To (Equal (defaultTemplateImageMsaf ))
689+ // Labels should reflect the effective framework
690+ Expect (deployment .Labels ["framework" ]).To (Equal ("msaf" ))
691+ })
692+
693+ It ("should fall back to google-adk when agent has no framework and config has no defaultFramework" , func () {
694+ agent := & runtimev1alpha1.Agent {
695+ ObjectMeta : metav1.ObjectMeta {
696+ Name : "test-agent-fallback-fw" ,
697+ Namespace : "default" ,
698+ },
699+ Spec : runtimev1alpha1.AgentSpec {
700+ // No framework specified, no config exists
701+ Protocols : []runtimev1alpha1.AgentProtocol {
702+ {Type : runtimev1alpha1 .A2AProtocol , Port : 8000 , Path : "/" , Name : "a2a" },
703+ },
704+ },
705+ }
706+ Expect (k8sClient .Create (ctx , agent )).To (Succeed ())
707+
708+ _ , err := reconciler .Reconcile (ctx , reconcile.Request {
709+ NamespacedName : types.NamespacedName {Name : "test-agent-fallback-fw" , Namespace : "default" },
710+ })
711+ Expect (err ).NotTo (HaveOccurred ())
712+
713+ deployment := & appsv1.Deployment {}
714+ Expect (k8sClient .Get (ctx , types.NamespacedName {Name : "test-agent-fallback-fw" , Namespace : "default" }, deployment )).To (Succeed ())
715+ Expect (deployment .Spec .Template .Spec .Containers ).To (HaveLen (1 ))
716+ // Should fall back to google-adk built-in default
717+ Expect (deployment .Spec .Template .Spec .Containers [0 ].Image ).To (Equal (defaultTemplateImageAdk ))
718+ Expect (deployment .Labels ["framework" ]).To (Equal ("google-adk" ))
719+ })
720+
721+ It ("should use agent's explicit framework even when config has a different default" , func () {
722+ config := & runtimev1alpha1.AgentRuntimeConfiguration {
723+ ObjectMeta : metav1.ObjectMeta {
724+ Name : "test-config-explicit-fw" ,
725+ Namespace : "default" ,
726+ },
727+ Spec : runtimev1alpha1.AgentRuntimeConfigurationSpec {
728+ DefaultFramework : "msaf" ,
729+ },
730+ }
731+ Expect (k8sClient .Create (ctx , config )).To (Succeed ())
732+
733+ agent := & runtimev1alpha1.Agent {
734+ ObjectMeta : metav1.ObjectMeta {
735+ Name : "test-agent-explicit-fw" ,
736+ Namespace : "default" ,
737+ },
738+ Spec : runtimev1alpha1.AgentSpec {
739+ Framework : "google-adk" , // Explicit framework should override config default
740+ Protocols : []runtimev1alpha1.AgentProtocol {
741+ {Type : runtimev1alpha1 .A2AProtocol , Port : 8000 , Path : "/" , Name : "a2a" },
742+ },
743+ },
744+ }
745+ Expect (k8sClient .Create (ctx , agent )).To (Succeed ())
746+
747+ _ , err := reconciler .Reconcile (ctx , reconcile.Request {
748+ NamespacedName : types.NamespacedName {Name : "test-agent-explicit-fw" , Namespace : "default" },
749+ })
750+ Expect (err ).NotTo (HaveOccurred ())
751+
752+ deployment := & appsv1.Deployment {}
753+ Expect (k8sClient .Get (ctx , types.NamespacedName {Name : "test-agent-explicit-fw" , Namespace : "default" }, deployment )).To (Succeed ())
754+ Expect (deployment .Spec .Template .Spec .Containers ).To (HaveLen (1 ))
755+ // Should use google-adk image since agent explicitly specifies it
756+ Expect (deployment .Spec .Template .Spec .Containers [0 ].Image ).To (Equal (defaultTemplateImageAdk ))
757+ Expect (deployment .Labels ["framework" ]).To (Equal ("google-adk" ))
758+ })
759+
653760 It ("should fail reconciliation when multiple AgentRuntimeConfigurations exist" , func () {
654761 config1 := & runtimev1alpha1.AgentRuntimeConfiguration {
655762 ObjectMeta : metav1.ObjectMeta {
0 commit comments