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