From 2bf50108feacbd3dacd5d08d196db126a0a640ab Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Wed, 6 May 2026 17:15:21 -0700 Subject: [PATCH] fix(agent-sdk): wrap session.send body in {prompt: ...} to match RunCreate schema Backend RunCreate expects {prompt: {...}} but the SDK was posting {text, images} directly. Wrap the normalized payload accordingly so session.send returns a real Run instead of 422. --- sdks/typescript-agent-sdk/src/session.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sdks/typescript-agent-sdk/src/session.ts b/sdks/typescript-agent-sdk/src/session.ts index dfbf0a719f3..697f00f0038 100644 --- a/sdks/typescript-agent-sdk/src/session.ts +++ b/sdks/typescript-agent-sdk/src/session.ts @@ -41,13 +41,17 @@ export class SessionHandle { return this._status; } - /** Start a new run with `input`. Throws 409 if a run is already in flight. */ + /** Start a new run with `input`. Throws 409 if a run is already in flight. + * + * Backend ``RunCreate`` schema expects ``{prompt: {...}}`` — wrap the + * normalized text/images payload accordingly so requests don't 422. + */ async send(input: string | SendInput): Promise { - const body = normalizeSendInput(input); + const normalized = normalizeSendInput(input); const info = await requestJson(this._client, { method: "POST", path: `/v2/sessions/${encodeURIComponent(this.id)}/runs`, - body, + body: { prompt: normalized }, }); return new Run(info, this._client); }