Revolutionizing Static Code Analysis: A Novel Approach to Codebase Comprehension

The developers behind MetaVision for 1C: AI, a system designed for static analysis of 1C configurations, encountered a significant challenge when training their AI agents on real-world codebases. The conventional RAG (Retrieval-Augmented Generation) methodology, which relies on chunks, embeddings, and vector search, proved ineffective. The agent frequently hallucinated or confidently stated the absence of information that was, in fact, present in the code.

Overcoming RAG Limitations: Three Sources of Truth Replace Chunks

In response to these challenges, the MetaVision for 1C: AI team engineered an innovative architecture for their AI agent, moving beyond the standard chunk-based approach. Instead, they built a local SQLite index that integrates three crucial sources of facts:

  • SQL Index: For structured data and rapid metadata lookup.
  • Full-text FTS5: For efficient searching within the code content.
  • Vector Representations: For semantic search and uncovering hidden connections.

This comprehensive strategy, augmented by a call graph, enables the agent to deeply understand the structure and logic of unfamiliar codebases, significantly minimizing hallucinations and enhancing analysis accuracy.

AI Agent Architecture: Tools, Cycles, and Validation Insights

The developed AI agent is a sophisticated system incorporating 71 specialized tools. The code analysis process is orchestrated through a multi-stage tool-calling cycle, which can extend up to 30 steps. Interestingly, initially implemented validators, intended to verify file correctness, were later removed due to false positives on valid data. This highlights the complexities inherent in iteratively developing systems that interact with intricate codebases.