@@ -163,9 +163,16 @@ export async function resolveAgentDeliveryPlanWithSessionRoute(
|
163 | 163 | accountId: plan.resolvedAccountId, |
164 | 164 | mode: plan.deliveryTargetMode ?? "explicit", |
165 | 165 | }); |
166 | | -if (!normalizedTarget.ok) { |
| 166 | +// Reserved-literal errors are not fatal for explicit delivery: the async |
| 167 | +// session-route resolver (resolveChannelTarget → resolveMessagingTarget) |
| 168 | +// does directory-first lookup before rejecting reserved literals, so a |
| 169 | +// configured directory entry named like a reserved word still resolves. |
| 170 | +const isReservedLiteralError = |
| 171 | +!normalizedTarget.ok && normalizedTarget.error.message.includes("Reserved target"); |
| 172 | +if (!normalizedTarget.ok && !isReservedLiteralError) { |
167 | 173 | return { ...plan, targetResolutionError: normalizedTarget.error }; |
168 | 174 | } |
| 175 | +const sessionRouteTarget = normalizedTarget.ok ? normalizedTarget.to : (plan.resolvedTo ?? ""); |
169 | 176 | const explicitThreadId = |
170 | 177 | params.explicitThreadId != null && params.explicitThreadId !== "" |
171 | 178 | ? params.explicitThreadId |
@@ -177,7 +184,7 @@ export async function resolveAgentDeliveryPlanWithSessionRoute(
|
177 | 184 | channel: plan.resolvedChannel as ChannelId, |
178 | 185 | agentId: params.agentId, |
179 | 186 | accountId: plan.resolvedAccountId, |
180 | | -target: normalizedTarget.to, |
| 187 | +target: sessionRouteTarget, |
181 | 188 | currentSessionKey: params.currentSessionKey, |
182 | 189 | threadId: plan.deliveryTargetMode === "explicit" ? explicitThreadId : plan.resolvedThreadId, |
183 | 190 | }); |
|