From a85ddf258c1a87665fca7958243d5e0da266489a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 17 Jan 2026 06:54:22 +0000 Subject: [PATCH] fix: expose deliveryContext in sessions_list Co-authored-by: Adam Holt --- CHANGELOG.md | 1 + docs/concepts/session-tool.md | 1 + src/agents/tools/sessions-list-tool.ts | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 318e540a0..032bdcdd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ ### Fixes - Sub-agents: normalize announce delivery origin + queue bucketing by accountId to keep multi-account routing stable. (#1061, #1058) — thanks @adam91holt. - Sessions: include deliveryContext in sessions.list and reuse normalized delivery routing for announce/restart fallbacks. (#1058) +- Sessions: propagate deliveryContext into last-route updates to keep account/channel routing stable. (#1058) - Gateway: honor explicit delivery targets without implicit accountId fallback; preserve lastAccountId for implicit routing. - Gateway: avoid reusing last-to/accountId when the requested channel differs; sync deliveryContext with last route fields. - Repo: fix oxlint config filename and move ignore pattern into config. (#1064) — thanks @connorshea. diff --git a/docs/concepts/session-tool.md b/docs/concepts/session-tool.md index f7bd4511c..c60187638 100644 --- a/docs/concepts/session-tool.md +++ b/docs/concepts/session-tool.md @@ -48,6 +48,7 @@ Row shape (JSON): - `thinkingLevel`, `verboseLevel`, `systemSent`, `abortedLastRun` - `sendPolicy` (session override if set) - `lastChannel`, `lastTo` +- `deliveryContext` (normalized `{ channel, to, accountId }` when available) - `transcriptPath` (best-effort path derived from store dir + sessionId) - `messages?` (only when `messageLimit > 0`) diff --git a/src/agents/tools/sessions-list-tool.ts b/src/agents/tools/sessions-list-tool.ts index ad50fc0b0..ae51a3441 100644 --- a/src/agents/tools/sessions-list-tool.ts +++ b/src/agents/tools/sessions-list-tool.ts @@ -27,6 +27,7 @@ type SessionListRow = { channel: string; label?: string; displayName?: string; + deliveryContext?: { channel?: string; to?: string; accountId?: string }; updatedAt?: number | null; sessionId?: string; model?: string; @@ -201,6 +202,14 @@ export function createSessionsListTool(opts?: { channel: derivedChannel, label: typeof entry.label === "string" ? entry.label : undefined, displayName: typeof entry.displayName === "string" ? entry.displayName : undefined, + deliveryContext: + deliveryChannel || deliveryTo || deliveryAccountId + ? { + channel: deliveryChannel, + to: deliveryTo, + accountId: deliveryAccountId, + } + : undefined, updatedAt: typeof entry.updatedAt === "number" ? entry.updatedAt : undefined, sessionId, model: typeof entry.model === "string" ? entry.model : undefined,