[Meta AI] Agentic Code Reasoning: Moving Beyond Guesswork with Semi-formal Verification
Agentic Code Reasoning
This paper introduces "Agentic Code Reasoning," a capability where LLM agents analyze code semantics and repository-wide dependencies without execution. The authors propose "Semi-formal Reasoning," a structured prompting methodology that mandates explicit premises and execution traces, achieving SOTA results including 93% accuracy in patch verification and 87% in code QA.
TL;DR
Can an AI verify if two code snippets are identical in behavior without ever "running" them? Meta researchers have introduced Semi-formal Reasoning, a framework that forces LLM agents to act like static analyzers. By following structured "certificates" of logic, agents achieved 93% accuracy in patch verification, proving that deep semantic code understanding is possible without a sandbox.
The Problem: The "Hallucination" of Implicit Understanding
Current LLMs are surprisingly good at coding, but they suffer from a "lazy reasoning" trap. When asked to verify a patch or find a bug, they often rely on Chain-of-Thought (CoT). While CoT is powerful, in the context of code, it allows the model to:
- Guess from names: Assuming a function named
format()is the Python built-in when it's actually shadowed by a local module function. - Skip edge cases: Overlooking how a variable might flow through an unread middleware file.
- Premature conclusions: Claiming two patches are equivalent because they "look similar" (surface-level similarity).
Prior work attempted to solve this with Formal Verification (using languages like Lean or Coq), but these are too labor-intensive for a 100,000-line Django repository.
The Core Innovation: Semi-formal Reasoning
The paper proposes a middle ground: Semi-formal Reasoning. Instead of a free-form chat, the agent is given a strict Certificate Template.
How it Works:
- Step 1: Explicit Premises: The agent must state exactly what it sees (e.g., "P1: Patch 1 modifies
dateformat.py"). - Step 2: Execution Tracing: For every test case, the agent must write a manual "trace" of the variable values.
- Step 3: Formal Conclusion: A final judgment derived strictly from the preceding steps.

Figure 1: In the Django example above, standard reasoning misses a shadowed function. Semi-formal analysis forces the agent to trace the definition of format(), revealing an AttributeError that only one patch triggers.
Methodological Breakdown
The structured template varies by task but always centers on Verifiable Evidence:
- Fault Localization: Uses a "Premise -> Claim -> Prediction" chain.
- Code QA: Mandates a Function Trace Table and Data Flow Analysis.
- Patch Equivalence: Requires a Counterexample search (if claiming non-equivalence).
Experimental Results: The Power of Structure
The researchers tested this on three major benchmarks:
1. Patch Equivalence (SWE-bench-Verified)
Traditional similarity tools (like difflib) only hit 73% accuracy. Using Opus-4.5 with Semi-formal reasoning, the accuracy skyrocketed to 93.0%. This is a massive win for RL training—models can now be rewarded for correct logic without the overhead of setting up a complex Docker container for every iteration.
2. Fault Localization (Defects4J)
In the Mockito repository, a notorious "infinite recursion" bug causes a StackOverflowError.
- Standard agents pointed to the crash site (the symptom).
- Semi-formal agents traced the registration pipeline and found the root cause (a variable overwrite 100 lines earlier).

Table: Semantic structure consistently provides a 5-12 percentage point boost over unstructured agents.
Deep Insight: Why Why Structure Beats Scale
The most fascinating finding is that even the most powerful models (like Opus-4.5) still benefit significantly from the template. For RubberDuckBench (Code QA), the structured format reduced the tendency to "guess" based on function names. By forcing the agent to check "Alternative Hypotheses" (e.g., "If I am wrong, what evidence would I see?"), the model corrected its own flawed deductions.
Critical Analysis & Future Outlook
The Cost of Rigor: Semi-formal reasoning is not "free." It requires roughly 2.8x more steps/tokens than standard reasoning. However, compared to the cost of a failed CI/CD run or a security vulnerability, this is a negligible price.
The RL Future: This work opens the door for Execution-free RL. We can now train coding agents at scale by using another "Verifier Agent" that uses semi-formal reasoning to provide high-fidelity rewards, bypassing the need for expensive and slow sandboxed execution environments.
Final Takeaway
Logic, not just language, is the next frontier for AI coding. By treating LLM reasoning as a "certificate" that must be filled out, we can transform stochastic parrots into precise code architects.
Disclaimer: This analysis is based on the paper "Agentic Code Reasoning" by Ugare & Chandra (Meta, 2026).
