@@ -86,6 +86,8 @@ function computeSessionAgentRuntime(params: {
8686 cfg : OpenClawConfig ;
8787 sessionKey : string ;
8888 fallbackAgentId : string ;
89+ /** Mirrors `entry?.acp != null` passed from loaded session rows. */
90+ acpRuntime ?: boolean ;
8991 /** Mirrors `entry?.acp?.backend` passed from the session store entry. */
9092 acpBackend ?: string ;
9193} ) : ReturnType < typeof resolveModelAgentRuntimeMetadata > {
@@ -94,6 +96,7 @@ function computeSessionAgentRuntime(params: {
9496 cfg : params . cfg ,
9597 agentId,
9698 sessionKey : params . sessionKey ,
99+ acpRuntime : params . acpRuntime ,
97100 acpBackend : params . acpBackend ,
98101 } ) ;
99102}
@@ -105,6 +108,7 @@ describe("sessions --json agentRuntime classifier (catalog #18)", () => {
105108 cfg,
106109 sessionKey : ACP_SESSION_KEY ,
107110 fallbackAgentId : "copilot" ,
111+ acpRuntime : true ,
108112 } ) ;
109113
110114 // The bug was: the session key plainly contains `:acp:` and yet the
@@ -158,6 +162,7 @@ describe("sessions --json agentRuntime classifier (catalog #18)", () => {
158162 cfg,
159163 sessionKey : ACP_SESSION_KEY ,
160164 fallbackAgentId : "copilot" ,
165+ acpRuntime : true ,
161166 } ) ;
162167
163168 expect (
@@ -178,26 +183,40 @@ describe("sessions --json agentRuntime classifier (catalog #18)", () => {
178183 cfg,
179184 sessionKey : ACP_SESSION_KEY ,
180185 fallbackAgentId : "copilot" ,
186+ acpRuntime : true ,
181187 acpBackend : "custom-backend" ,
182188 } ) ;
183189
184190 expect ( agentRuntime . id ) . toBe ( "custom-backend" ) ;
185191 expect ( agentRuntime . source ) . toBe ( "session-key" ) ;
186192 } ) ;
187193
188- it ( "backend fallback: ACP session with no entry.acp.backend falls back to 'acpx'" , ( ) => {
189- // When the session entry has no acp.backend (entry.acp is absent or backend
190- // is not set), the overlay must fall back to the canonical "acpx" id so
191- // existing behaviour is preserved.
194+ it ( "backend fallback: ACP session with entry.acp but no backend falls back to 'acpx'" , ( ) => {
195+ // When the session entry has ACP metadata but no acp.backend, the overlay
196+ // must fall back to the canonical "acpx" id.
192197 const cfg = buildConfigWithoutAgentRuntimePolicy ( ) ;
193198 const agentRuntime = computeSessionAgentRuntime ( {
194199 cfg,
195200 sessionKey : ACP_SESSION_KEY ,
196201 fallbackAgentId : "copilot" ,
202+ acpRuntime : true ,
197203 // acpBackend intentionally omitted — mirrors entry with no acp.backend
198204 } ) ;
199205
200206 expect ( agentRuntime . id ) . toBe ( "acpx" ) ;
201207 expect ( agentRuntime . source ) . toBe ( "session-key" ) ;
202208 } ) ;
209+
210+ it ( "GREEN control: ACP-shaped bridge session without entry.acp is NOT overridden" , ( ) => {
211+ const cfg = buildConfigWithoutAgentRuntimePolicy ( ) ;
212+ const agentRuntime = computeSessionAgentRuntime ( {
213+ cfg,
214+ sessionKey : ACP_SESSION_KEY ,
215+ fallbackAgentId : "copilot" ,
216+ acpRuntime : false ,
217+ } ) ;
218+
219+ expect ( agentRuntime . id ) . not . toBe ( "acpx" ) ;
220+ expect ( agentRuntime . source ) . not . toBe ( "session-key" ) ;
221+ } ) ;
203222} ) ;
0 commit comments