SnagTrace | Deterministic AI Agent Fault Detection Library

SnagTrace is an open-source Python library that helps developers identify common failures in AI agent execution traces using deterministic analysis. Instead of relying on another language model to judge whether an agent failed, it detects structural issues such as execution loops, invalid tool arguments, and cost budget overruns, then reports the exact step where the problem occurred. The library is designed to integrate with modern agent frameworks such as LangChain and LangGraph while remaining lightweight, reproducible, and easy to extend. Overview Debugging AI agents can be difficult because a single execution may involve hundreds of tool calls, multiple agents, and long execution traces. While existing observability platforms provide tracing and replay, developers often still need to manually inspect traces to locate the source of a failure. SnagTrace focuses on failure types that can be detected reliably without an LLM. By analyzing execution traces with deterministic rules, it produces consistent results and helps reduce the time required to investigate common agent failures. Features Key Capabilities Loop Detection Detects repeated tool invocations and recursive execution patterns using configurable sliding-window analysis. Tool Argument Validation Identifies invalid tool inputs, schema mismatches, truncated arguments, and parsing failures before they propagate through an agent workflow. Cost Budget Monitoring Tracks cumulative execution cost and reports the precise step where a configured budget threshold is exceeded. Technologies Design SnagTrace follows a deterministic approach to agent debugging. Each detector analyzes execution traces independently without calling an external language model. This makes diagnoses reproducible, inexpensive to run, and suitable for automation in development and CI workflows. The detector system is modular, allowing additional rule-based detectors to be added without changing the core architecture. Performance The library is designed for efficient analysis of large execution traces while keeping detectors stateless and easy to test. For long-running agents, traces can be analyzed periodically or after execution completes to avoid unnecessary overhead. My Role This project was designed and developed independently. My work included: Outcome SnagTrace provides a lightweight way to detect common AI agent failures without introducing additional LLM-based analysis. It is intended for developers who want deterministic, reproducible diagnostics that can be integrated into local development workflows or automated pipelines.

Deep Research Agent – Autonomous AI Research Assistant

ai agent

Abstract As Large Language Models (LLMs) evolve from simple text generators to reasoning engines, the focus of AI development has shifted toward agentic workflows—systems capable of autonomous planning, tool use, and self-correction. To explore the efficacy of modern orchestration frameworks, I engineered the Deep Research Agent: a fully autonomous system designed to perform iterative, multi-step research tasks. This project demonstrates a production-ready implementation of a cyclic graph architecture (LangGraph) utilizing the Groq API for high-throughput inference. The resulting system achieves professional-grade research synthesis with a marginal operating cost of $0.005 per query, proving that high-performance autonomous agents can be built cost-effectively using open-weight models. 1. System Overview: The Deep Research Agent The Deep Research Agent is not merely a wrapper for an LLM; it is a stateful application that mimics the workflow of a human analyst. Unlike zero-shot querying, this system employs an iterative “thought-loop” to refine information quality before generating a final response. Core Capabilities: 2. Technical Stack & Design Choices The architecture was chosen to maximize architectural flexibility while minimizing inference latency and operational costs. 3. Architectural Analysis: Cyclic Graph vs. Linear Chains A key engineering decision in this project was the implementation of a Cyclic Graph architecture over a traditional Linear Chain. 4. Engineering Implementation & Challenges The development process highlighted several critical aspects of building production-grade agents. A. State Management Implementation Effective state management is the backbone of any agentic system. I implemented a TypedDict structure with reducer operators to maintain context across iterations. This ensures that research findings are accumulated rather than overwritten during loops. Python B. Resilience and Error Handling To ensure robustness suitable for automated tasks, I implemented exponential backoff strategies for all external API calls. This prevents cascade failures during momentary latency spikes from search or LLM providers. Python C. Resource Optimization (Cost Analysis) A primary objective was to demonstrate the economic feasibility of running autonomous agents at scale. By optimizing the system prompt and pruning search results (limiting context window usage), the system achieves a 95% cost reduction compared to proprietary model APIs (e.g., GPT-4). Metric Standard API approach Deep Research Agent (Optimized) Cost Per Query ~$0.10 **~$0.005** Latency Variable < 3s (Inference) Architecture Black Box Open / Customizable 5. Conclusion & Future Scope This project validates that professional-grade AI agents do not require prohibitive budgets or closed ecosystems. By leveraging LangGraph for sophisticated orchestration and Groq for high-speed inference, I have engineered a system that is both autonomous and economically scalable. Future Research Directions: Repository: github.com/kazisalon/Deep-Research-Agent

Real-Time Object Detection on Raspberry Pi: LiteRT, OpenCV, and Telegram

object detection

The goal of this project was to build a lightweight edge AI system that could detect people in real time and send alerts without relying on cloud-based inference. I wanted the entire detection pipeline to run locally on a Raspberry Pi so that it could respond quickly, reduce network usage, and continue working even with limited internet connectivity. The application starts by capturing frames from a USB camera using OpenCV and the V4L2 backend. Each frame is resized and prepared for inference before being passed to a quantized MobileNet SSD model running with Google’s LiteRT runtime. Using a quantized model keeps inference efficient enough to run on Raspberry Pi hardware while maintaining reasonable detection accuracy. After inference, the model outputs multiple candidate detections. Since object detection models often generate overlapping bounding boxes for the same object, I applied Non-Maximum Suppression (NMS) to remove duplicate detections and keep only the highest-confidence result for each person. To avoid sending blurry or underexposed images, the application briefly waits for the camera’s auto-exposure to stabilize whenever a new person enters the frame. It also clears buffered frames from the camera before capturing the final snapshot, ensuring the notification contains the most recent image instead of an older buffered frame. The annotated image is encoded directly in memory and sent to Telegram using the Bot API. This avoids unnecessary disk writes and reduces I/O overhead on the Raspberry Pi. To make the system suitable for continuous operation, I implemented retry handling for temporary network failures and deployed the application as a systemd service. This allows the gateway to start automatically after boot and recover from unexpected interruptions without manual intervention. Where This Project Can Be Used Although this project was built as a learning exercise in edge AI and computer vision, the same architecture can be applied to a variety of real-world scenarios. Home and Office Monitoring The system can monitor entrances, hallways, or restricted areas and send instant notifications whenever a person is detected. Smart Classrooms Schools can use the gateway to monitor classroom activity, laboratories, or computer rooms without continuously streaming video to a remote server. Retail Stores The project can be adapted to monitor customer movement, detect occupancy, or trigger alerts when someone enters specific areas. Construction Sites and Warehouses A local edge device can detect workers entering restricted zones and notify supervisors without requiring cloud processing. Remote Locations Because inference runs entirely on the Raspberry Pi, the system is well suited for environments with unreliable or limited internet connectivity. Only alert messages need to be transmitted, significantly reducing bandwidth requirements. AI and Edge Computing Research The project also serves as a practical example of deploying lightweight computer vision models on embedded hardware. Developers can extend it by adding custom object detection models, face recognition, multiple cameras, or integration with IoT devices and automation platforms. What I Learned Building this project reinforced that deploying an AI model is only part of the solution. Real-world systems also need to account for camera behavior, duplicate detections, network interruptions, and long-running reliability. Addressing these practical challenges made the system far more usable than simply running an object detection model on a live video stream. This project also provided hands-on experience with edge AI deployment, computer vision optimization, Linux service management, and integrating AI applications with external APIs for real-time notifications.

Multi-Class Brain Tumor Detection Using Deep Learning

Brain tumor detection

Brain tumors are abnormal growths of cells in the brain that can be life-threatening. Early and accurate detection is crucial for effective treatment. Deep learning, specifically convolutional neural networks (CNNs), has revolutionized medical imaging by providing automated and accurate diagnoses. This project focuses on detecting different types of brain tumors using a deep learning model trained on MRI images. Dataset The dataset used in this project consists of MRI scans categorized into three tumor types and one non-tumor class: The dataset is divided into: Data Preprocessing Model Architecture The deep learning model is built using VGG16, a pre-trained CNN model, with modifications for multi-class classification. The architecture includes: Training Process Results and Analysis Conclusion This project successfully demonstrates the potential of deep learning for medical diagnosis, particularly in multi-class brain tumor detection. The VGG16-based model effectively classifies MRI images into four categories with high accuracy. Future Enhancements: References:

Plant Disease Detection Using CNN

Plant Disease Detection

With the advancement of technology, agriculture has seen significant improvements, especially with the integration of machine learning techniques. One of the pressing challenges faced by farmers is the early detection of plant diseases. This project focuses on building a Convolutional Neural Network (CNN) to classify plant diseases from images, specifically targeting diseases in corn, potato, and tomato plants. Dataset The dataset used in this project consists of images of plant leaves affected by three common diseases: The images were stored on Google Drive and loaded into the Colab environment for preprocessing and training. Data Preprocessing The preprocessing steps involved: Model Architecture The CNN model was built using Keras with the following structure: The model was compiled using the Adam optimizer with a learning rate of 0.0001 and categorical crossentropy as the loss function. Model Training The model was trained for 50 epochs with a batch size of 128. Training and validation accuracy were monitored throughout the process. The model achieved a satisfactory accuracy, as indicated by the plotted training history. Model Evaluation After training, the model was tested on unseen data to evaluate its performance. The results showed a high accuracy rate, indicating the model’s effectiveness in identifying plant diseases. Results and Analysis The classification report and confusion matrix revealed that the model performed well across all three classes. Additionally, the ROC AUC score demonstrated the robustness of the model. Conclusion This project successfully developed a CNN model to classify plant diseases with high accuracy. Early detection can help farmers take preventive measures, minimizing crop loss and ensuring better yield. Further improvements could involve using a more diverse dataset and fine-tuning hyperparameters for enhanced accuracy.