<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kavyakalai on Medium]]></title>
        <description><![CDATA[Stories by Kavyakalai on Medium]]></description>
        <link>https://medium.com/@kavyakalai77?source=rss-d4f4b587281b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*lOcdnsSLMkevTia4</url>
            <title>Stories by Kavyakalai on Medium</title>
            <link>https://medium.com/@kavyakalai77?source=rss-d4f4b587281b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 23:56:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kavyakalai77/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[An Incident Response Agent Should Remember What Actually Fixed the Problem]]></title>
            <link>https://medium.com/@kavyakalai77/an-incident-response-agent-should-remember-what-actually-fixed-the-problem-81247b9f6398?source=rss-d4f4b587281b------2</link>
            <guid isPermaLink="false">https://medium.com/p/81247b9f6398</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[sd]]></category>
            <category><![CDATA[dev]]></category>
            <category><![CDATA[mls]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Kavyakalai]]></dc:creator>
            <pubDate>Mon, 09 Nov 2026 17:40:10 GMT</pubDate>
            <atom:updated>2026-11-09T17:40:10.495Z</atom:updated>
            <content:encoded><![CDATA[<p>Most incident-response tools can help explain an error. The harder</p><p>problem is making the next investigation better because we already</p><p>solved a similar incident once.</p><p>That distinction shaped the system I built: an incident response agent</p><p>that analyses application and server logs, retrieves relevant historical</p><p>incidents from Hindsight, and keeps long-term memory limited to root</p><p>causes and resolutions that an engineer has actually verified.</p><p>I did not want a chatbot that simply remembers everything said during an</p><p>investigation. I wanted an engineering system that could distinguish a</p><p>plausible diagnosis from a confirmed one — -and use that difference to</p><p>improve future recommendations.</p><p><strong>## The problem with treating every incident as a new incident</strong></p><p>When a service starts returning errors, an engineer usually has to</p><p>reconstruct the situation from logs, dashboards, deployment history,</p><p>alerts, and whatever notes were left by the person who handled the last</p><p>occurrence.</p><p>The logs may show a database timeout, a saturated connection pool, or a</p><p>failed dependency. They rarely explain by themselves whether the</p><p>underlying cause was a connection leak, a capacity limit, a network</p><p>issue, or a recent change.</p><p>An LLM can help organize those clues. It can extract evidence, suggest</p><p>possible causes, and propose checks. But a model’s plausible explanation</p><p>is not the same as an engineer-confirmed root cause. If we store every</p><p>generated answer as fact, we risk teaching the system to repeat its own</p><p>guesses.</p><p>I designed the incident workflow around that boundary:</p><p>1. Analyse the current logs and identify possible causes.</p><p>2. Search long-term memory for relevant, previously verified incidents.</p><p>3. Use those memories as context — -not as unquestionable answers.</p><p>4. Present evidence and safe investigation steps to an engineer.</p><p>5. Retain the actual root cause and resolution only after the engineer</p><p>verifies them.</p><p>The important design decision is not that the system has memory. It is</p><p>that the system has a rule for deciding what deserves to become memory.</p><p><strong>## How the pieces fit together</strong></p><p>The backend is a Python service built with FastAPI. The frontend sends</p><p>logs and a service name to the incident-analysis endpoint. The backend</p><p>coordinates two external capabilities:</p><p>- <strong>**Groq**</strong> runs the language-model analysis. It receives the current</p><p>logs and any relevant historical context, then returns structured</p><p>findings.</p><p>- <strong>**Hindsight Cloud**</strong> provides long-term incident memory. The backend</p><p>uses it to retain verified incidents and recall memories that may be</p><p>relevant to a new investigation.</p><p>The code keeps those responsibilities in separate service modules:</p><p>``` text</p><p>backend/</p><p>app/</p><p>main.py</p><p>config.py</p><p>routes/</p><p>incident.py</p><p>schemas/</p><p>incident.py</p><p>services/</p><p>groq_service.py</p><p>hindsight_service.py</p><p>incident_service.py</p><p>tests/</p><p>requirements.txt</p><p>```</p><p>`main.py` creates the FastAPI application, configures CORS, and</p><p>registers the incident routes. The route layer validates requests and</p><p>translates service errors into HTTP responses. The schema module defines</p><p>the API contract. The service layer contains the actual coordination</p><p>logic.</p><p>That separation matters. The route should not know how a Hindsight</p><p>memory is retained, and the Groq client should not be responsible for</p><p>deciding whether an incident has been verified. Each component has one</p><p>job, which makes the workflow easier to test and reason about.</p><p>The API exposes three operations:</p><p>- `POST /api/incidents/analyze` accepts logs and returns an analysis.</p><p>- `POST /api/incidents/{incident_id}/verify` accepts an</p><p>engineer-confirmed root cause and resolution.</p><p>- `GET /api/incidents/{incident_id}` returns the incident record and</p><p>its verification status.</p><p>The analysis response separates possible causes, evidence, recommended</p><p>checks, and historical matches. That is deliberate. A diagnosis is a</p><p>hypothesis; a log line is evidence; a recommended check is an action for</p><p>an engineer to consider. Combining all three into one paragraph would</p><p>make it harder for a person to tell what the system knows from what it</p><p>is suggesting.</p><p><strong>## The central design decision: memory should contain verified outcomes</strong></p><p>The most important part of the system is the boundary between analysis</p><p>and retention.</p><p>During an investigation, the model may suggest that a database</p><p>connection pool is exhausted. That may be a good hypothesis, especially</p><p>if the logs show high pool utilization and timeouts while acquiring a</p><p>connection. But it is still a hypothesis until someone checks the system</p><p>and confirms the cause.</p><p>The verification endpoint therefore asks for three things: the incident</p><p>identifier, the actual root cause, and the resolution. The request also</p><p>carries an explicit `verified` flag. The schema rejects empty root-cause</p><p>or resolution fields and rejects a verification request unless that flag</p><p>is true.</p><p>The service applies the same rule before calling Hindsight:</p><p>``` python</p><p>def store_verified_incident(</p><p>self,</p><p>incident_id: str,</p><p>logs: str,</p><p>root_cause: str,</p><p>resolution: str,</p><p>service_name: str,</p><p>severity: str = “unknown”,</p><p>verified: bool = False</p><p>):</p><p>if not verified:</p><p>raise ValueError(“Only verified incidents can be stored”)</p><p>```</p><p>This check is intentionally simple. The model does not get to decide</p><p>that its own answer is true. The engineer supplies the confirmed</p><p>outcome, and the backend enforces the retention rule.</p><p>When an incident passes verification, the service builds a</p><p>human-readable memory containing the incident ID, service, severity,</p><p>original logs, verified root cause, successful resolution, and</p><p>verification status. It then calls Hindsight’s `retain` operation:</p><p>``` python</p><p>result = self.client.retain(</p><p>bank_id=self.bank_id,</p><p>content=content,</p><p>context=(</p><p>“Engineer-verified production incident “</p><p>“and its confirmed resolution.”</p><p>),</p><p>metadata={</p><p>“incident_id”: str(incident_id),</p><p>“service_name”: str(service_name),</p><p>“severity”: str(severity),</p><p>“verified”: “true”</p><p>}</p><p>)</p><p>```</p><p>The content carries the incident narrative; the metadata makes important</p><p>attributes explicit. That gives the memory system both descriptive</p><p>context and useful identifiers.</p><p>This is where Hindsight is different from ordinary chat history in the</p><p>design. A conversation transcript records what people and models said.</p><p>Incident memory is intended to preserve operational knowledge that can</p><p>be useful later: what failed, what the engineer established as the</p><p>cause, and what resolved it. The system does not need to replay an</p><p>entire previous conversation to benefit from that knowledge.</p><p>For background on the distinction, I found it useful to read about</p><p>[agent memory and how it differs from ordinary conversational</p><p>context](https://vectorize.io/what-is-agent-memory). Hindsight’s [GitHub</p><p>repository](https://github.com/vectorize-io/hindsight) and</p><p>[documentation](https://hindsight.vectorize.io/) describe the memory</p><p>system and its API.</p><p><strong>## Recall is useful only when relevance is respected</strong></p><p>Retention is only half of the problem. The system also needs to retrieve</p><p>memories when a new incident arrives.</p><p>The Hindsight service constructs a recall query from the affected</p><p>service and current logs. It asks for historical incidents with similar</p><p>error messages, exception types, stack traces, failed components, and</p><p>database or network symptoms:</p><p>``` python</p><p>result = self.client.recall(</p><p>bank_id=self.bank_id,</p><p>query=query,</p><p>max_tokens=max_tokens,</p><p>budget=budget</p><p>)</p><p>```</p><p>The service converts the returned memories into a consistent internal</p><p>representation. The incident service then parses the stored incident</p><p>format to extract fields such as the historical incident ID, service,</p><p>verified root cause, and resolution.</p><p>The orchestration is straightforward:</p><p>``` python</p><p>recall_result = self.hindsight_service.recall_similar_incidents(</p><p>logs=logs,</p><p>service_name=service</p><p>)</p><p>raw_memories = recall_result.get(“incidents”, [])</p><p>historical_context, historical_matches = (</p><p>self._parse_historical_memories(raw_memories)</p><p>)</p><p>groq_result = self.groq_service.analyze_logs(</p><p>logs=logs,</p><p>service=service,</p><p>historical_context=historical_context</p><p>)</p><p>```</p><p>The order is important: memory retrieval happens before the model</p><p>produces its final analysis. Groq receives both the current evidence and</p><p>the recalled historical context. That lets the model consider whether an</p><p>earlier verified incident is relevant while still analysing the new</p><p>logs.</p><p>I do not want the system to blindly copy an old resolution. Two</p><p>incidents can contain the same timeout message and have different</p><p>causes. A previous incident should influence the investigation, not end</p><p>it.</p><p>That is also why the response keeps `historical_matches` separate from</p><p>`possible_causes`. A recalled incident is historical context. It is not</p><p>proof that the current incident has the same root cause.</p><p>Retrieval quality deserves particular attention. A memory system can</p><p>return something technically similar but operationally unrelated. For</p><p>example, a database timeout and a Java heap exhaustion error may both</p><p>appear during a period of service degradation, but a previous</p><p>database-pool fix should not be recommended for a memory-pressure</p><p>incident. Relevance checks need to consider the service, component,</p><p>error family, and actual symptoms — -not just the fact that both records</p><p>contain the word `error`.</p><p><strong>## The model’s output must be useful to an engineer</strong></p><p>The Groq service asks the model to return a JSON object with four</p><p>fields: severity, possible causes, evidence, and recommended checks.</p><p>Pydantic validates the returned structure before it becomes an API</p><p>response.</p><p>The prompt also sets explicit limits on what the model should claim:</p><p>- Possible causes are suggestions, never confirmed facts.</p><p>- Evidence must be based on the supplied logs.</p><p>- The model must not claim that a possible cause has been verified.</p><p>- Recommendations should be safe diagnostic checks, not automated</p><p>repairs.</p><p>This is a practical choice. An incident-response assistant should help</p><p>an engineer decide what to inspect next. It should not make production</p><p>changes simply because a language model generated a confident-sounding</p><p>instruction.</p><p>The system also handles dependency failures separately. If Groq cannot</p><p>complete an analysis, the API returns an analysis-service error. If</p><p>Hindsight recall is unavailable, the incident service can continue with</p><p>a fresh log analysis and no historical matches. Memory improves the</p><p>investigation, but a temporary memory-service outage should not make</p><p>basic log analysis impossible.</p><p>That graceful-degradation path is useful, but it must remain visible to</p><p>operators. An empty list of historical matches can mean either that no</p><p>relevant memory exists or that memory retrieval was unavailable. Those</p><p>are different operational states and should be distinguishable in</p><p>production telemetry and API responses.</p><p><strong>## A concrete incident, then a better-informed recurrence</strong></p><p>Consider a payment service that starts producing database connection</p><p>timeouts. Its logs show connection-pool utilization approaching</p><p>saturation, followed by failures while acquiring a connection and HTTP</p><p>503 responses.</p><p>On the first occurrence, the agent has no relevant verified memory. It</p><p>analyses the logs and may suggest checking pool utilization, active</p><p>database queries, connection lifecycle handling, and recent changes to</p><p>the payment service. Those are investigation leads, not a final</p><p>diagnosis.</p><p>An engineer investigates and confirms that a session handler is leaking</p><p>connections. The engineer records the actual root cause and the</p><p>resolution — -for example, correcting the session lifecycle and adjusting</p><p>the connection-pool configuration. Only then does the backend retain the</p><p>incident in Hindsight.</p><p>Later, similar payment-service logs arrive. Hindsight can recall the</p><p>earlier incident because the new logs share relevant symptoms. The</p><p>backend passes that historical context to Groq. The resulting analysis</p><p>can now mention the previously confirmed connection leak as a useful</p><p>lead and recommend checking whether the same session-handling path is</p><p>involved.</p><p>The second investigation is not automatically solved. The environment</p><p>may have changed, and the current failure may have a different cause.</p><p>But the engineer no longer has to start with no institutional context.</p><p>The system can surface a verified precedent and make the next</p><p>investigation more focused.</p><p>That is the behavior I care about: not a model claiming to learn from</p><p>every interaction, but an investigation workflow that can reuse</p><p>confirmed operational knowledge.</p><p><strong>## What I learned building this</strong></p><p><strong>### 1. Decide what counts as knowledge before adding memory</strong></p><p>It is tempting to store every prompt, response, and tool result. That</p><p>creates a large history, not necessarily a useful one. Defining a</p><p>retention rule first makes the memory system more trustworthy. In this</p><p>project, the rule is that long-term incident memory should contain</p><p>engineer-verified causes and resolutions.</p><p><strong>### 2. Keep hypotheses, evidence, and outcomes separate</strong></p><p>A possible cause is not evidence. A recommended check is not a</p><p>resolution. A historical match is not confirmation. Representing these</p><p>as separate fields makes the API easier for the frontend to display and</p><p>makes the system’s uncertainty harder to hide.</p><p><strong>### 3. Retrieval quality is part of the product</strong></p><p>A memory system is not useful merely because it returns something. It</p><p>must return something relevant. Similarity should be evaluated against</p><p>the actual service and failure symptoms, and recalled resolutions should</p><p>remain suggestions until an engineer verifies that they apply.</p><p><strong>### 4. External services need clear failure boundaries</strong></p><p>Groq and Hindsight are separate dependencies with different</p><p>responsibilities. Their errors should be handled independently. If</p><p>memory is temporarily unavailable, the system should still be able to</p><p>analyse logs; if model analysis fails, the API should report that</p><p>failure clearly rather than returning invented findings.</p><p><strong>### 5. Never let a confident model response become operational truth</strong></p><p>The most important safety rule is also the simplest: the agent</p><p>recommends; the engineer verifies. The system does not automatically</p><p>execute repairs, and the model cannot promote its own hypothesis into a</p><p>verified incident.</p><p><strong>## The measure of a useful incident agent</strong></p><p>I think the value of an incident-response agent should be measured by</p><p>more than whether it can summarize a stack trace or produce a plausible</p><p>root cause. The more meaningful question is whether a verified</p><p>resolution from a previous incident can make a later investigation more</p><p>useful — -without encouraging engineers to trust stale or irrelevant</p><p>advice.</p><p>That requires discipline around memory: retain the right information,</p><p>retrieve it in the right context, expose why it is relevant, and keep a</p><p>human responsible for confirming the current cause.</p><p>Hindsight gives the system a persistent place to retain and recall</p><p>incident knowledge. Groq helps interpret the current logs in light of</p><p>that knowledge. FastAPI connects those capabilities through an explicit</p><p>incident lifecycle. The result is an agent designed not just to answer</p><p>the current question, but to make the next investigation start from a</p><p>better-informed position.</p><p>The goal is not to replace incident responders. It is to stop making</p><p>them rediscover the same confirmed lessons every time a familiar failure</p><p>returns.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81247b9f6398" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>