@@ -561,7 +561,7 @@ describe('V2 protocol Observation runtime', function()
561561 assert .is_false (observed :_watches (' messages' ))
562562 end )
563563
564- it (' passes selected model through the V2 submit operation' , function ()
564+ it (' passes selected agent and model through the V2 submit operation' , function ()
565565 local value = connection ()
566566 local sent
567567 install_operations (value , {
@@ -573,13 +573,32 @@ describe('V2 protocol Observation runtime', function()
573573 local observed = value :observe ({ id = ' ses-main' })
574574 local input = { text = ' hello' , context = {}, files = {}, agents = {} }
575575
576- observed :submit (input , { model = ' provider/selected-model' , variant = ' high' }):wait ()
576+ observed :submit (input , { mode = ' plan ' , model = ' provider/selected-model' , variant = ' high' }):wait ()
577577
578+ assert .equals (' plan' , sent .agent )
578579 assert .same ({ providerID = ' provider' , modelID = ' selected-model' }, sent .model )
579580 assert .equals (' high' , sent .variant )
581+ assert .is_nil (input .agent )
580582 assert .is_nil (input .model )
581583 end )
582584
585+ it (' passes selected agent without a selected model through V2 submit' , function ()
586+ local value = connection ()
587+ local sent
588+ install_operations (value , {
589+ submit = function (_ , _ , input )
590+ sent = input
591+ return resolved ({ id = ' msg-local' , delivery = ' queue' })
592+ end ,
593+ })
594+ local observed = value :observe ({ id = ' ses-main' })
595+
596+ observed :submit ({ text = ' hello' , context = {}, files = {}, agents = {} }, { mode = ' plan' }):wait ()
597+
598+ assert .equals (' plan' , sent .agent )
599+ assert .is_nil (sent .model )
600+ end )
601+
583602 it (' correlates only a delivered admission with the following same-session terminal' , function ()
584603 local value = connection ()
585604 local admission = Promise .new ()
@@ -644,6 +663,28 @@ describe('V2 protocol Observation runtime', function()
644663 assert .is_true (streams [1 ].handle .stopped )
645664 end )
646665
666+ it (' does not count non-user inbox deliveries as competing prompt inputs' , function ()
667+ local value = connection ()
668+ local streams = install_operations (value , {
669+ submit = function ()
670+ return resolved ({ id = ' msg-local' , delivery = ' queue' })
671+ end ,
672+ })
673+ local observed = value :observe ({ id = ' ses-main' })
674+ local accepted = observed :submit ({ text = ' hello' }):wait ()
675+ emit (streams [1 ], event (' ses-main' , ' session.inbox.enqueued' , {
676+ inboxID = ' synthetic-1' ,
677+ item = { type = ' synthetic' , payload = { text = ' agent changed' }, delivery = ' queue' },
678+ }, 10 ))
679+ emit (streams [1 ], event (' ses-main' , ' session.inbox.delivered' , { inboxID = ' synthetic-1' }, 11 ))
680+ emit (streams [1 ], event (' ses-main' , ' session.inbox.delivered' , { inboxID = ' msg-local' }, 12 ))
681+ emit (streams [1 ], event (' ses-main' , ' session.execution.started' , {}, 13 ))
682+ emit (streams [1 ], event (' ses-main' , ' session.execution.succeeded' , {}, 14 ))
683+
684+ assert .equals (' succeeded' , accepted .completion :wait ().outcome )
685+ assert .is_nil (observed ._v2_delivered [' synthetic-1' ])
686+ end )
687+
647688 it (' rejects ambiguous delivery even when the HTTP admissions arrive after the terminal' , function ()
648689 local value = connection ()
649690 local http = { Promise .new (), Promise .new () }
0 commit comments