DEV Community

Cover image for From Error Logs to Past Fixes with Hindsight Recall
GANGADHARA VEDA SREE
GANGADHARA VEDA SREE

Posted on

From Error Logs to Past Fixes with Hindsight Recall

Implementing recall() in Code
​Below is the core implementation within devops_agent.py responsible for querying the Hindsight API and handling returned semantic matches:

import os
from hindsight_client import Hindsight
client = Hindsight(
    base_url=os.getenv("HINDSIGHT_API_URL"),
    api_key=os.getenv("HINDSIGHT_API_TOKEN")
)
BANK_ID = os.getenv("HINDSIGHT_BANK_ID", "devops-pipeline-agent")

def search_pipeline_memory(error_trace: str, top_k: int = 3):
    \"\"\"Queries Hindsight memory bank for semantically similar past incidents.\"\"\"
    try:
        response = client.recall(
            bank_id=BANK_ID,
            query=error_trace,
            limit=top_k
        ) 
        if not response or not hasattr(response, 'results') or not response.results:
            return None 
        return response.results
    except Exception as e:
        print(f"Error querying Hindsight Recall API: {e}")
        return None
Enter fullscreen mode Exit fullscreen mode

Key Benefits of Semantic Recall
Error Synonym Matching: Matches disparate log formats (Exit Code 137 vs OOMKilled) to the same resolution.
Noise Reduction: Filters out transient timestamp differences and line numbers, focusing purely on structural stack trace signatures.
Sub-second Triage: Reduces manual triage time from 20+ minutes to under a second.
Resources & Links
GitHub Repository: 25wh1a05be/devops-pipeline-agent
Hindsight Documentation: hindsight.vectorize.io
"""

Top comments (1)