()
| 111 | # Session state + memory stores |
| 112 | # ───────────────────────────────────────────────────────────── |
| 113 | def init_session(): |
| 114 | Config.validate() |
| 115 | |
| 116 | # Initialise memory stores once |
| 117 | if "chat_store" not in st.session_state: |
| 118 | st.session_state.chat_store = ChatStore(Config.MEMORY_DIR) |
| 119 | if "incident_store" not in st.session_state: |
| 120 | st.session_state.incident_store = IncidentStore(Config.MEMORY_DIR) |
| 121 | |
| 122 | # Load persisted conversation (survives page refreshes) |
| 123 | if "messages" not in st.session_state: |
| 124 | st.session_state.messages = st.session_state.chat_store.load() |
| 125 | |
| 126 | # Build the agent with past-incident context |
| 127 | if "agent" not in st.session_state: |
| 128 | incident_store = st.session_state.incident_store |
| 129 | recent = incident_store.get_recent(5) |
| 130 | context = incident_store.format_for_prompt(recent) |
| 131 | st.session_state.agent = LogAnalyzerAgent(incident_context=context) |
| 132 | |
| 133 | |
| 134 | # ───────────────────────────────────────────────────────────── |
no test coverage detected