fix(protocol): keep agent provider string

This commit is contained in:
Peter Steinberger
2026-01-09 23:09:07 +01:00
parent 3f1415b8fe
commit 2af3853bfa
2 changed files with 21 additions and 6 deletions

View File

@@ -1,6 +1,5 @@
import { type Static, type TSchema, Type } from "@sinclair/typebox";
import { SESSION_LABEL_MAX_LENGTH } from "../../sessions/session-label.js";
import { GATEWAY_AGENT_PROVIDER_VALUES } from "../../utils/message-provider.js";
const NonEmptyString = Type.String({ minLength: 1 });
const SessionLabelString = Type.String({
@@ -8,10 +7,6 @@ const SessionLabelString = Type.String({
maxLength: SESSION_LABEL_MAX_LENGTH,
});
const AgentProviderSchema = Type.Union(
GATEWAY_AGENT_PROVIDER_VALUES.map((provider) => Type.Literal(provider)),
);
export const PresenceEntrySchema = Type.Object(
{
host: Type.Optional(NonEmptyString),
@@ -230,7 +225,7 @@ export const AgentParamsSchema = Type.Object(
sessionKey: Type.Optional(Type.String()),
thinking: Type.Optional(Type.String()),
deliver: Type.Optional(Type.Boolean()),
provider: Type.Optional(AgentProviderSchema),
provider: Type.Optional(Type.String()),
timeout: Type.Optional(Type.Integer({ minimum: 0 })),
lane: Type.Optional(Type.String()),
extraSystemPrompt: Type.Optional(Type.String()),

View File

@@ -70,6 +70,26 @@ export const agentHandlers: GatewayRequestHandlers = {
return;
}
const message = request.message.trim();
const rawProvider =
typeof request.provider === "string" ? request.provider.trim() : "";
if (rawProvider) {
const normalized = normalizeMessageProvider(rawProvider);
if (
normalized &&
normalized !== "last" &&
!isGatewayMessageProvider(normalized)
) {
respond(
false,
undefined,
errorShape(
ErrorCodes.INVALID_REQUEST,
`invalid agent params: unknown provider: ${normalized}`,
),
);
return;
}
}
const requestedSessionKey =
typeof request.sessionKey === "string" && request.sessionKey.trim()