1258
const createResult = await this._createChat(provider, chat, createOptions);
1259
const providerData = createResult?.providerData;
1260
>
this._stateManager.addChat(sessionKey, chat.toString(), {
agentService.ts
1261
>
...(forkedTitle !== undefined ? { title: forkedTitle } : options?.title !== undefined ? { title: options.title } : {}),
1262
>
...(forkedTurns !== undefined ? { turns: forkedTurns } : {}),
1263
>
...(providerData !== undefined ? { providerData } : {}),
1264
>
...(sideChatOrigin !== undefined ? { origin: sideChatOrigin } : {}),
1265
>
});
1266
>
1267
>
// Persist the new peer chat into the orchestrator-owned catalog so it is
1268
>
// re-enumerated and re-materialized on the next restore without asking
1269
>
// the agent. Side-chat provenance is persisted alongside providerData.
1270
>
void this._persistPeerChat(session, chat, providerData, sideChatOrigin);
1271
>
1272
>
// When the agent backs this peer chat with its own separately-enumerable
1273
>
// SDK session (e.g. Claude), mark that session so it is filtered out of
1274
>
// the top-level session list instead of leaking as a standalone session.
1275
>
if (createResult?.backingSession) {
1276
this._markPeerChatBacking(createResult.backingSession, chat);
1277
}