@@ -215,6 +215,7 @@ const makeRunnerState = (compaction?: SessionRunnerModel.Resolved["compaction"])
215215 systemRemoved : false ,
216216 systemUnavailable : false ,
217217 systemLoadHook : Effect . void ,
218+ activationHook : Effect . void ,
218219 skillBaselines : new Map < Agent . ID , string > ( ) ,
219220 authorizations : new Array < Tool . Context > ( ) ,
220221 executions : new Array < string > ( ) ,
@@ -422,7 +423,7 @@ const layer = Layer.unwrap(
422423 Permission . node . replace ( permission ) ,
423424 Config . node . replace ( config ) ,
424425 PluginSupervisor . node . replace ( Layer . empty ) ,
425- Plugin . node . replace ( Layer . mock ( Plugin . Service , { awaitActivation : Effect . void } ) ) ,
426+ Plugin . node . replace ( Layer . mock ( Plugin . Service , { awaitActivation : Effect . suspend ( ( ) => state . activationHook ) } ) ) ,
426427 SessionModelTransport . node . replace ( modelTransport ) ,
427428 ]
428429 const runnerLayer = AppNodeBuilder . build ( SessionRunnerLLM . node , [
@@ -2664,6 +2665,26 @@ describe("SessionRunnerLLM", () => {
26642665 }
26652666 }
26662667
2668+ scenario ( "waits for plugin activation before each step and tool call" , function * ( s ) {
2669+ const waits : Array < [ number , number ] > = [ ]
2670+ s . activationHook = Effect . sync ( ( ) => {
2671+ waits . push ( [ s . requests . length , s . executions . length ] )
2672+ } )
2673+ yield * s . llm . push (
2674+ TestLLM . tool ( "call-activation" , "echo" , { text : "echo" } ) ,
2675+ TestLLM . text ( "Done" , "text-after-activation" ) ,
2676+ )
2677+ yield * s . runPrompt ( "Question" )
2678+
2679+ // Model requests and tool executions seen at each wait: drain entry, step 1, the tool call, step 2.
2680+ expect ( waits ) . toEqual ( [
2681+ [ 0 , 0 ] ,
2682+ [ 0 , 0 ] ,
2683+ [ 1 , 0 ] ,
2684+ [ 1 , 1 ] ,
2685+ ] )
2686+ } )
2687+
26672688 scenario ( "restarts compaction drafts after transient failures and unsuccessful finishes" , function * ( s ) {
26682689 yield * s . llm . push ( TestLLM . text ( "Earlier answer" , "text-manual-failure-history" ) )
26692690 yield * s . runPrompt ( "Earlier question" )
0 commit comments