Skip to content

An open-source, faster Devin alternative

TypeScript

sdk(agents): session metadata on create + read

Igor Zalutskibcdcb52d4129
diff --git a/sdks/typescript/src/agents/sessions.ts b/sdks/typescript/src/agents/sessions.ts
index 73924b38..ef922d0d 100644
--- a/sdks/typescript/src/agents/sessions.ts
+++ b/sdks/typescript/src/agents/sessions.ts
@@ -17,6 +17,14 @@ export interface CreateSessionParams {
*/
destinations?: Array<{ url: string; level?: Level; types?: string[]; includeRaw?: boolean; enabled?: boolean }>;
limits?: Limits;
+ /**
+ * Opaque application routing state stored on the session — a JSON object (≤ 16 KB).
+ * Returned on `get`/`list` (as `session.snapshot.metadata`) and delivered verbatim in
+ * webhooks, so a callback handler can route to the right record without a lookup. It is
+ * never shown to the model and not indexed/queryable. Distinct from `key`
+ * (get-or-create) and `idempotencyKey` (dedupe).
+ */
+ metadata?: Record<string, unknown>;
/** Makes a keyless create retry-safe (sent as the Idempotency-Key header). */
idempotencyKey?: string;
}
diff --git a/sdks/typescript/src/agents/types.ts b/sdks/typescript/src/agents/types.ts
index f9ac4629..4587ba69 100644
--- a/sdks/typescript/src/agents/types.ts
+++ b/sdks/typescript/src/agents/types.ts
@@ -58,6 +58,8 @@ export interface SessionData {
credentialId?: string;
lastTurn?: LastTurn;
limits?: Limits;
+ /** Opaque app routing state set at create (`null` when unset). See {@link CreateSessionParams.metadata}. */
+ metadata?: Record<string, unknown> | null;
key?: string;
createdAt?: string;
}