@@ -39,6 +39,7 @@ import {
3939 resolveProviderEntryApiKeyProfileReferenceMock ,
4040 resolveContextWindowInfoMock ,
4141 resolveContextEngineMock ,
42+ resolveDefaultAgentDirMock ,
4243 resolveEffectiveCompactionModeMock ,
4344 resolveEmbeddedAgentStreamFnMock ,
4445 resolveMemorySearchConfigMock ,
@@ -676,6 +677,40 @@ describe("compactEmbeddedAgentSessionDirect hooks", () => {
676677 ) ;
677678 } ) ;
678679
680+ it ( "does not require an implicit default owner for direct compaction" , async ( ) => {
681+ resolveDefaultAgentDirMock . mockImplementation ( ( ) => {
682+ throw new Error ( "ambiguous default agent" ) ;
683+ } ) ;
684+ resolveSessionAgentIdsMock . mockReturnValue ( {
685+ defaultAgentId : "marie-clawndo" ,
686+ sessionAgentId : "marie-clawndo" ,
687+ } ) ;
688+
689+ const result = await compactEmbeddedAgentSessionDirect (
690+ wrappedCompactionArgs ( {
691+ agentId : "marie-clawndo" ,
692+ config : {
693+ agents : {
694+ ownership : "explicit" ,
695+ list : [ { id : "main" } , { id : "marie-clawndo" } ] ,
696+ } ,
697+ } ,
698+ sessionKey : "agent:marie-clawndo:dashboard:session-1" ,
699+ sessionTarget : {
700+ agentId : "marie-clawndo" ,
701+ sessionId : TEST_SESSION_ID ,
702+ sessionKey : "agent:marie-clawndo:dashboard:session-1" ,
703+ storePath : "/tmp/sessions.json" ,
704+ } ,
705+ } ) ,
706+ ) ;
707+
708+ expect ( result . ok ) . toBe ( true ) ;
709+ expect ( acquireAgentRunPreparedModelRuntimeMock ) . toHaveBeenCalledWith (
710+ expect . objectContaining ( { agentId : "marie-clawndo" } ) ,
711+ ) ;
712+ } ) ;
713+
679714 it ( "forwards gateway subagent binding opt-in during compaction bootstrap" , async ( ) => {
680715 // Coding-tool forwarding is covered elsewhere; this compaction test only
681716 // owns the runtime bootstrap wiring.
@@ -2504,6 +2539,40 @@ describe("compactEmbeddedAgentSession hooks (ownsCompaction engine)", () => {
25042539 } ) ;
25052540 } ) ;
25062541
2542+ it ( "does not require an implicit default owner for queued compaction" , async ( ) => {
2543+ resolveDefaultAgentDirMock . mockImplementation ( ( ) => {
2544+ throw new Error ( "ambiguous default agent" ) ;
2545+ } ) ;
2546+ resolveSessionAgentIdsMock . mockReturnValue ( {
2547+ defaultAgentId : "marie-clawndo" ,
2548+ sessionAgentId : "marie-clawndo" ,
2549+ } ) ;
2550+
2551+ const result = await compactEmbeddedAgentSession (
2552+ wrappedCompactionArgs ( {
2553+ agentId : "marie-clawndo" ,
2554+ config : {
2555+ agents : {
2556+ ownership : "explicit" ,
2557+ list : [ { id : "main" } , { id : "marie-clawndo" } ] ,
2558+ } ,
2559+ } ,
2560+ sessionKey : "agent:marie-clawndo:dashboard:session-1" ,
2561+ sessionTarget : {
2562+ agentId : "marie-clawndo" ,
2563+ sessionId : TEST_SESSION_ID ,
2564+ sessionKey : "agent:marie-clawndo:dashboard:session-1" ,
2565+ storePath : "/tmp/sessions.json" ,
2566+ } ,
2567+ } ) ,
2568+ ) ;
2569+
2570+ expect ( result . ok ) . toBe ( true ) ;
2571+ expect ( acquireAgentRunPreparedModelRuntimeMock ) . toHaveBeenCalledWith (
2572+ expect . objectContaining ( { agentId : "marie-clawndo" } ) ,
2573+ ) ;
2574+ } ) ;
2575+
25072576 it ( "disposes the context engine once when route materialization rejects" , async ( ) => {
25082577 const dispose = vi . fn ( async ( ) => { } ) ;
25092578 const authStorage = { setRuntimeApiKey : vi . fn ( ) } ;
0 commit comments