@@ -61,6 +61,7 @@ import type {
6161 ConversationTurn ,
6262 InboundMessage ,
6363 InferenceSource ,
64+ PerCallInferenceOptions ,
6465 ReactorDirector ,
6566 ToolCall ,
6667 ToolDefinition ,
@@ -114,6 +115,16 @@ export type SendOptions = {
114115 signal ?: AbortSignal ;
115116 /** Override the default "from" header on the synthetic inbound message. */
116117 from ?: string ;
118+ /**
119+ * Inference options for the model calls this send drives. Applies to this
120+ * send alone; a key the director names outright still wins.
121+ */
122+ inference ?: PerCallInferenceOptions ;
123+ } ;
124+
125+ type QueuedSend = {
126+ message : InboundMessage ;
127+ inference : PerCallInferenceOptions | undefined ;
117128} ;
118129
119130export type SendResult =
@@ -477,7 +488,7 @@ export async function createAgent<EnvReq extends BaseEnv>(
477488 // the language allows; the comment block above is what makes
478489 // the "assigned before any reachable read" invariant explicit.
479490 // eslint-disable-next-line prefer-const -- forward declaration; const cannot express this ordering
480- let sendQueue : SendQueue < InboundMessage , SendResult > ;
491+ let sendQueue : SendQueue < QueuedSend , SendResult > ;
481492
482493 // shutdownComplete resolves from the assembly's onShutdown hook
483494 // (composed after audit flush by the assembly) or, as a fallback, from
@@ -770,11 +781,11 @@ export async function createAgent<EnvReq extends BaseEnv>(
770781 ...( env . compactors !== undefined ? { compactors : env . compactors } : { } ) ,
771782 } ) ;
772783
773- sendQueue = createSendQueue < InboundMessage , SendResult > ( {
784+ sendQueue = createSendQueue < QueuedSend , SendResult > ( {
774785 maxDepth : env . sendQueueMax ?? DEFAULT_SEND_QUEUE_MAX ,
775- start : ( message ) => {
786+ start : ( { message, inference } ) => {
776787 activeCycle = { lastAssistantTurn : undefined } ;
777- reactor . deliver ( message ) ;
788+ reactor . deliver ( message , inference !== undefined ? { inference } : { } ) ;
778789 } ,
779790 } ) ;
780791
@@ -813,7 +824,10 @@ export async function createAgent<EnvReq extends BaseEnv>(
813824 // and per the design must fail loud.
814825 if ( closed ) return Promise . reject ( new AgentClosedError ( ) ) ;
815826 const message = buildInboundMessage ( content , opts ) ;
816- return sendQueue . enqueue ( message , opts ?. signal ) ;
827+ return sendQueue . enqueue (
828+ { message, inference : opts ?. inference } ,
829+ opts ?. signal ,
830+ ) ;
817831 }
818832
819833 function stream ( ) : AsyncIterable < ReactorEmittedEvent > {
0 commit comments