( sessionId: string, history: ChatHistoryItem[] = [], )
| 518 | * preserve chat history across restarts for the same storage/agent id. |
| 519 | */ |
| 520 | export function loadOrCreateSessionById( |
| 521 | sessionId: string, |
| 522 | history: ChatHistoryItem[] = [], |
| 523 | ): Session { |
| 524 | const existing = loadSessionById(sessionId); |
| 525 | if (existing) { |
| 526 | SessionManager.getInstance().setSession(existing); |
| 527 | return existing; |
| 528 | } |
| 529 | |
| 530 | return createSession(history, sessionId); |
| 531 | } |
| 532 | |
| 533 | /** |
| 534 | * Update the current session's history |
no test coverage detected