<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Attayab Ashraf</title>
    <description>The latest articles on DEV Community by Muhammad Attayab Ashraf (@attayab31).</description>
    <link>https://dev.to/attayab31</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4245685%2F4f37ba82-4428-4322-bdce-a902549d4a79.png</url>
      <title>DEV Community: Muhammad Attayab Ashraf</title>
      <link>https://dev.to/attayab31</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/attayab31"/>
    <language>en</language>
    <item>
      <title>Why I Stopped Letting LLMs Guess Code Structure — Building DocAgent with AST Parsing &amp; Multi-Agent Verification</title>
      <dc:creator>Muhammad Attayab Ashraf</dc:creator>
      <pubDate>Sun, 15 Nov 2026 09:37:42 +0000</pubDate>
      <link>https://dev.to/attayab31/why-i-stopped-letting-llms-guess-code-structure-building-docagent-with-ast-parsing-multi-agent-25p9</link>
      <guid>https://dev.to/attayab31/why-i-stopped-letting-llms-guess-code-structure-building-docagent-with-ast-parsing-multi-agent-25p9</guid>
      <description>&lt;p&gt;If you dump raw source files into an LLM and ask it to generate documentation, you usually get two things: vague summaries and hallucinated function signatures.&lt;/p&gt;

&lt;p&gt;When I started building DocAgent—an automated documentation pipeline with C and C++ support—I wanted generated docs that an engineering team could actually trust without manually verifying every line.&lt;/p&gt;

&lt;p&gt;Instead of relying on a single giant prompt, I split the problem into deterministic code parsing and a four-role multi-agent workflow.&lt;/p&gt;

&lt;p&gt;The Architecture: Structure First, LLM Second&lt;/p&gt;

&lt;p&gt;LLMs are great at explaining intent, but they are unreliable at tracking exact symbol boundaries across large C/C++ files. To solve this, I used libclang to parse the Abstract Syntax Tree (AST) before any model touches the code.&lt;/p&gt;

&lt;p&gt;Breaking Down the Four Agent Roles&lt;/p&gt;

&lt;p&gt;Rather than asking one agent to do everything, each step has a narrow job:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reader (AST Parser): Uses libclang in Python to extract functions, classes, parameter types, return values, and call relationships deterministically.&lt;/li&gt;
&lt;li&gt;Searcher: Pulls relevant surrounding context so documented functions reflect how they are actually used in the codebase, not just in isolation.&lt;/li&gt;
&lt;li&gt;Writer: Takes the structured AST metadata and retrieved context to generate clear, human-readable explanations.&lt;/li&gt;
&lt;li&gt;Verifier: Compares the generated documentation back against the extracted AST nodes to catch missing parameters, mismatched return types, or unsupported claims before output.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Key Takeaways From Building It&lt;/p&gt;

&lt;p&gt;• Deterministic tools beat clever prompts. Letting libclang handle syntax and type extraction eliminated almost all structural hallucinations before the LLM even ran.&lt;br&gt;
• Verification needs ground truth. A verifier agent only works well when you give it hard facts (like parsed AST signatures) to check against, rather than asking it to "double-check its own work."&lt;br&gt;
• Small, focused pipelines are easier to debug. Separating retrieval, drafting, and validation made it obvious which stage failed whenever an edge case popped up in C++ headers.&lt;/p&gt;

&lt;p&gt;Check Out the Code&lt;/p&gt;

&lt;p&gt;You can explore the implementation and try it out on GitHub:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/Attayab-31/DocAgent-with-C-support-" rel="noopener noreferrer"&gt;https://github.com/Attayab-31/DocAgent-with-C-support-&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're building developer tools or multi-agent workflows in Python, I’d love to hear how you handle verification and ground-truth checks in your pipelines!&lt;/p&gt;

&lt;p&gt;Written by Muhammad Attayab Ashraf — Backend &amp;amp; Applied AI Engineer building Python APIs, RAG pipelines, and LLM systems at DevVerx. View more of my work at &lt;a href="https://attayab.automivex.com" rel="noopener noreferrer"&gt;https://attayab.automivex.com&lt;/a&gt; or connect on GitHub.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>ai</category>
      <category>python</category>
      <category>agents</category>
    </item>
  </channel>
</rss>
