@@ -2243,8 +2243,8 @@ describe("gateway agent handler", () => {
22432243 state : "idle" ,
22442244 lastActivityAt : Date . now ( ) ,
22452245 } ,
2246- spawnedBy : "agent:main:webchat:main " ,
2247- parentSessionKey : "agent:main:webchat:main " ,
2246+ spawnedBy : "agent:main:telegram:123 " ,
2247+ parentSessionKey : "agent:main:telegram:123 " ,
22482248 hubDelegated : {
22492249 ownerSessionKey : "agent:main:webchat:main" ,
22502250 createdAt : Date . now ( ) ,
@@ -2260,6 +2260,8 @@ describe("gateway agent handler", () => {
22602260 message : "你好" ,
22612261 agentId : "main" ,
22622262 sessionKey : "agent:main:main" ,
2263+ replyChannel : "telegram" ,
2264+ to : "123" ,
22632265 deliver : true ,
22642266 bestEffortDeliver : true ,
22652267 idempotencyKey : "test-hub-delegated-metadata-internal" ,
@@ -2279,6 +2281,50 @@ describe("gateway agent handler", () => {
22792281 expect ( callArgs . deliver ) . not . toBe ( true ) ;
22802282 } ) ;
22812283
2284+ it ( "keeps parent-owned thread-bound ACP session delivery visible" , async ( ) => {
2285+ mockMainSessionEntry ( {
2286+ acp : {
2287+ backend : "acpx" ,
2288+ agent : "codex" ,
2289+ runtimeSessionName : "runtime-thread-bound" ,
2290+ mode : "persistent" ,
2291+ state : "idle" ,
2292+ lastActivityAt : Date . now ( ) ,
2293+ } ,
2294+ spawnedBy : "agent:main:telegram:123" ,
2295+ parentSessionKey : "agent:main:telegram:123" ,
2296+ lastChannel : "telegram" ,
2297+ lastTo : "123" ,
2298+ } ) ;
2299+ mocks . agentCommand . mockResolvedValue ( {
2300+ payloads : [ { text : "thread reply" } ] ,
2301+ meta : { durationMs : 100 } ,
2302+ } ) ;
2303+
2304+ await invokeAgent (
2305+ {
2306+ message : "thread-bound resume" ,
2307+ agentId : "main" ,
2308+ sessionKey : "agent:main:main" ,
2309+ deliver : true ,
2310+ bestEffortDeliver : true ,
2311+ idempotencyKey : "test-thread-bound-acp-visible-delivery" ,
2312+ } ,
2313+ {
2314+ reqId : "thread-bound-acp-visible-delivery" ,
2315+ client : backendGatewayClient ( ) ,
2316+ context : makeContext ( ) ,
2317+ } ,
2318+ ) ;
2319+
2320+ const callArgs = await waitForAgentCommandCall < {
2321+ sessionEffects ?: string ;
2322+ deliver ?: boolean ;
2323+ } > ( ) ;
2324+ expect ( callArgs . sessionEffects ) . not . toBe ( "internal" ) ;
2325+ expect ( callArgs . deliver ) . toBe ( true ) ;
2326+ } ) ;
2327+
22822328 it ( "rejects public transcriptMessage overrides" , async ( ) => {
22832329 primeMainAgentRun ( { cfg : mocks . loadConfigReturn } ) ;
22842330 mocks . agentCommand . mockClear ( ) ;
0 commit comments