@@ -146,20 +146,21 @@ export async function resolveAgentDeliveryPlanWithSessionRoute(
|
146 | 146 | }, |
147 | 147 | ): Promise<AgentDeliveryPlan> { |
148 | 148 | const plan = resolveAgentDeliveryPlan(params); |
149 | | -const plugin = |
150 | | -params.wantsDelivery && plan.resolvedTo && isDeliverableMessageChannel(plan.resolvedChannel) |
151 | | - ? resolveOutboundChannelPlugin({ |
152 | | -channel: plan.resolvedChannel, |
153 | | -cfg: params.cfg, |
154 | | -allowBootstrap: true, |
155 | | -}) |
156 | | - : undefined; |
| 149 | +const { resolvedChannel, resolvedTo } = plan; |
| 150 | +if (!params.wantsDelivery || !resolvedTo || !isDeliverableMessageChannel(resolvedChannel)) { |
| 151 | +return plan; |
| 152 | +} |
| 153 | +const plugin = resolveOutboundChannelPlugin({ |
| 154 | +channel: resolvedChannel, |
| 155 | +cfg: params.cfg, |
| 156 | +allowBootstrap: true, |
| 157 | +}); |
157 | 158 | if (!plugin?.messaging?.resolveOutboundSessionRoute) { |
158 | 159 | return plan; |
159 | 160 | } |
160 | 161 | const normalizedTarget = resolveOutboundTarget({ |
161 | | -channel: plan.resolvedChannel, |
162 | | -to: plan.resolvedTo, |
| 162 | +channel: resolvedChannel, |
| 163 | +to: resolvedTo, |
163 | 164 | cfg: params.cfg, |
164 | 165 | accountId: plan.resolvedAccountId, |
165 | 166 | mode: plan.deliveryTargetMode ?? "explicit", |
@@ -174,8 +175,8 @@ export async function resolveAgentDeliveryPlanWithSessionRoute(
|
174 | 175 | } |
175 | 176 | const resolvedTarget = await resolveChannelTarget({ |
176 | 177 | cfg: params.cfg, |
177 | | -channel: plan.resolvedChannel as ChannelId, |
178 | | -input: plan.resolvedTo, |
| 178 | +channel: resolvedChannel as ChannelId, |
| 179 | +input: resolvedTo, |
179 | 180 | accountId: plan.resolvedAccountId, |
180 | 181 | unknownTargetMode: "normalized", |
181 | 182 | plugin, |
@@ -194,7 +195,7 @@ export async function resolveAgentDeliveryPlanWithSessionRoute(
|
194 | 195 | try { |
195 | 196 | return await resolveOutboundSessionRoute({ |
196 | 197 | cfg: params.cfg, |
197 | | -channel: plan.resolvedChannel as ChannelId, |
| 198 | +channel: resolvedChannel as ChannelId, |
198 | 199 | agentId: params.agentId, |
199 | 200 | accountId: plan.resolvedAccountId, |
200 | 201 | target: sessionRouteTarget, |
|