Seu agente de código está gerando bugs (sem saber)
Graphify C#: Análise compilador-precisa pra agentes. Seu agente entende código ou só pattern-matches? Quando imprecisão mata confiança.
Equipe OpenClaw · Time de Engenharia & Produto
A Equipe OpenClaw é formada por engenheiros, designers e especialistas em IA dedicados a construir a melhor plataforma de agentes conversacionais para negócios brasileiros. Combinamos expertise…
Seu agente de código está gerando bugs (sem saber)
Você é founder/CEO de SaaS.
Seu SaaS: agente de código (refatoração, geração, análise, debugging, otimização).
Seu agente: Usa regex/AST simples ("encontra todas as referências à função X")
Sua realidade: Agente acha "referencias erradas", sugerem refatoração perigosa.
Seu developer: "Seu agente está quebrado. Não confio mais."
Ontem: Developer lançou Graphify C# (compiler-accurate code analysis pra agentes).
What Graphify revealed (the precision problem):
- Standard approach: Regex + simple AST (pattern matching)
- Reality: Pattern matching falha 40-60% das vezes
- Example 1: Função "GetUser" (encontra 50 referências, mas 20 são false positives)
- Example 2: Refatoração sugerida (quebra código porque não entendeu contexto)
- Example 3: Agente recomenda: "Delete unused parameter" (mas é usado em reflection)
- Solution: Graphify C# (use compiler internals, 100% accuracy)
- Benefit: Agente entende código como compilador entende (zero false positives)
- Validation: 29 points no HN (developers validando que problema é real)
- Implication: Standard code analysis is broken for agents
The accuracy problem (why pattern matching fails)
How simple code analysis breaks agents
=== SCENARIO 1: FIND ALL USAGES (PATTERN MATCHING) ===
Your C# codebase: csharp public class UserService { public User GetUser(int id) { return db.Users.FirstOrDefault(u => u.Id == id); } }
public class CacheService { public User GetUser(int id) { return cache.Get($"user_{id}"); } // SAME NAME }
public class ApiController { public async Task GetUser(int id) { return await service.GetUser(id); } // REAL USAGE }
public class Report { public void GenerateReport() { var text = "GetUser function does XYZ"; // STRING LITERAL (not usage) var methodName = nameof(UserService.GetUser); // REFLECTION (real, but special) var users = new[] { userService.GetUser(1), userService.GetUser(2) }; // REAL USAGE } }
Simple regex search (find "GetUser"): ├─ Results: 6 matches found ├─ Match 1: UserService.GetUser (REAL - definition) ├─ Match 2: CacheService.GetUser (FALSE - different class) ├─ Match 3: GetUser(int id) (REAL - usage in ApiController) ├─ Match 4: GetUser call (REAL - usage 1) ├─ Match 5: "GetUser function" (FALSE - comment/string) ├─ Match 6: nameof(UserService.GetUser) (SPECIAL - reflection) ├─ Match 7: GetUser(2) (REAL - usage 2) ├─ False positives: 2 out of 6 (33% error rate) ├─ False negatives: 0 (but you're confused which is which) ├─ Confidence: 67% (should be 100%)
=== AGENT'S DECISION BASED ON BROKEN DATA ===
Agent command: "Refactor GetUser - rename to FetchUser everywhere it's used"
Agent thinks: ├─ "GetUser is used in 6 places" ├─ "I'll rename all 6 to FetchUser" ├─ "This is safe because I found all usages"
Agent executes: csharp // After rename (BROKEN) public class UserService { public User FetchUser(int id) { return db.Users.FirstOrDefault(u => u.Id == id); } }
public class CacheService { public User GetUser(int id) { return cache.Get($"user_{id}"); } // UNCHANGED (wrong! inconsistent) }
public class ApiController { public async Task FetchUser(int id) { return await service.FetchUser(id); } // RENAMED (correct) }
public class Report { public void GenerateReport() { var text = "FetchUser function does XYZ"; // RENAMED (WRONG! comment shouldn't change) var methodName = nameof(UserService.FetchUser); // RENAMED (correct) var users = new[] { userService.FetchUser(1), userService.FetchUser(2) }; // RENAMED (correct) } }
Result: ├─ Code doesn't compile (CacheService still calls GetUser, but UserService renamed) ├─ Build error: "GetUser doesn't exist in UserService" ├─ Comment now says "FetchUser" (confusing, wasn't meant to change) ├─ Developer sees error, blames agent ├─ Developer loses trust in agent ├─ Developer: "Your agent just broke my code. I'm not using this again."
=== GRAPHIFY C# APPROACH (COMPILER-ACCURATE) ===
Graphify command: "Find all usages of UserService.GetUser"
Graphify uses: ├─ C# compiler internals (Roslyn API) ├─ Full semantic analysis (not just pattern matching) ├─ Type resolution (knows what GetUser belongs to) ├─ Control flow analysis (knows which branch is taken) ├─ Reflection awareness (knows about nameof, MethodInfo, etc)
Graphify results: ├─ Match 1: UserService.GetUser definition (REAL - declaration) ├─ Match 2: ApiController.GetUser call (REAL - usage) ├─ Match 3: Report.GetUser calls (2x) (REAL - usages) ├─ Match 4: nameof(UserService.GetUser) (REAL - reflection, tracked) ├─ False positives: 0 (100% accurate) ├─ False negatives: 0 (found everything) ├─ Confidence: 100% ├─ Other matches: CacheService.GetUser (shown separately, not confused) ├─ String literal "GetUser": Not included (correctly identified as non-code)
Graphify-powered refactor: ├─ Agent renames only UserService.GetUser (and its real usages) ├─ CacheService.GetUser unchanged (correctly separate) ├─ Comment stays "GetUser" (correctly identified as non-code) ├─ Code compiles (no errors) ├─ Test passes (behavior unchanged) ├─ Developer: "Your agent is incredible. Renamed my function perfectly."
=== ACCURACY IMPACT ===
Standard agent (pattern matching): ├─ Accuracy: 60-70% (lots of false positives) ├─ Developer trust: Low ("agent breaks code") ├─ Refactorings: Risky (need manual verification) ├─ Usability: "I don't trust this for real work" ├─ Outcome: Developers stop using agent
Graphify-powered agent (compiler-accurate): ├─ Accuracy: 100% (zero false positives) ├─ Developer trust: High ("agent works perfectly") ├─ Refactorings: Safe (can be auto-applied) ├─ Usability: "This is better than manual work" ├─ Outcome: Developers use agent for everything
The bug generation problem (when false positives become liability)
How inaccuracy causes production bugs
=== SCENARIO 2: GENERATE CODE (WRONG CONTEXT) ===
Your agent (code generation): ├─ Prompt: "Generate a service to cache user queries" ├─ Agent searches: "How is User object used?" ├─ Agent finds: 50 usages (but 20 are false positives from other classes) ├─ Agent sees: "User object has: Id, Name, Email, Password, Avatar, PhoneNumber" ├─ Agent infers: "All these fields must be cached together" ├─ Agent generates: Cache service that stores all fields
Generated code: csharp public class UserCacheService { private Dictionary<int, User> cache = new();
public User GetCachedUser(int id) {
// Returns FULL User object (including Password)
return cache[id];
}
}
Problem: ├─ Generated code caches Password (security issue) ├─ Agent only looked at "usages" (didn't understand security implications) ├─ Agent missed: Password should never be cached ├─ Developer uses generated code without review ├─ Passwords leaked if cache is compromised ├─ Security incident (GDPR fines, customer trust loss) ├─ Root cause: Agent didn't understand code accurately
=== SCENARIO 3: DEPENDENCY ANALYSIS (FALSE REMOVAL) ===
Your agent (dead code removal): ├─ Task: "Remove unused code from codebase" ├─ Agent searches: "Find unused methods" ├─ Agent finds method: "public User GetUserFromCache(int id)" ├─ Agent sees: No direct calls to GetUserFromCache ├─ Agent conclusion: "This method is unused, delete it" ├─ Agent deletes: Method removed
What agent missed: ├─ Method IS used (via reflection in plugin system) ├─ Plugin system calls: GetUserFromCache via name lookup ├─ At runtime: Plugin calls GetUserFromCache (but method doesn't exist) ├─ Runtime error: "Method not found exception" ├─ Production downtime (plugins break) ├─ Customers: "Your app is broken" ├─ Root cause: Agent didn't understand reflection patterns
=== IMPACT ON DEVELOPER TRUST ===
After first bug: ├─ Developer: "I trusted your agent to refactor my code" ├─ Reality: Agent introduced security bug ├─ Developer decision: "Manual review required for ALL agent suggestions" ├─ Outcome: Agent is now 50% slower (manual review overhead) ├─ ROI: Agent becomes liability (not helpful)
After second bug: ├─ Developer: "I'm not using your agent anymore" ├─ Reality: Agent is perceived as unreliable ├─ Developer decision: "Back to manual coding" ├─ Outcome: Agent uninstalled ├─ ROI: Zero (customer churn, negative reviews)
The competitive advantage (why precision is moat)
When code understanding becomes defensible
=== MARKET COMPARISON ===
Agent A (pattern matching): ├─ Accuracy: 60-70% ├─ User feedback: "Breaks my code sometimes" ├─ Developer trust: Low ├─ Daily usage: 10-20% of developers ├─ Net Promoter Score: 20-30 (detractors outweigh promoters) ├─ Churn rate: 40-50% (users leave after bad experience) ├─ Unit economics: Broken (high CAC, high churn)
Agent B (compiler-accurate): ├─ Accuracy: 98-100% ├─ User feedback: "Works perfectly, never breaks code" ├─ Developer trust: High ├─ Daily usage: 80-90% of developers ├─ Net Promoter Score: 70-80 (promoters, word-of-mouth) ├─ Churn rate: 5-10% (users stay, pay more) ├─ Unit economics: Strong (lower CAC, high LTV)
=== WHY PRECISION IS DEFENSIBLE ===
Competitor tries to match: ├─ Can they build "compiler-accurate"? ├─ Yes, but it takes 6-12 months (expensive R&D) ├─ Can they catch up in accuracy? ├─ Yes, but they start at 0%, you already have 100% ├─ Can they copy your tech? ├─ Partially (if open-source), but you have 6-month head start ├─ Can they compete on price? ├─ No, because your accuracy justifies premium pricing
Result: ├─ You have 6-12 month moat (before competitors catch up) ├─ You have accuracy moat (hard to match 100%) ├─ You have trust moat (developers choose you first) ├─ You have pricing power (can charge more for accuracy) ├─ You have expansion moat (developers pay for premium features)
=== REAL WORLD EXAMPLE ===
Copilot vs Cursor: ├─ Copilot: General-purpose (pattern matching) ├─ Cursor: IDE-integrated, understands codebase better (compiler-aware) ├─ Result: Cursor is growing faster (developers prefer accuracy) ├─ Cursor pricing: Higher than Copilot (people pay for accuracy) ├─ Developer sentiment: "Cursor never breaks code, Copilot does" ├─ Market position: Cursor captures the "serious developers" segment
Lesson: ├─ Precision = defensible moat ├─ Trust = pricing power ├─ Accuracy = unit economics improvement
The implementation challenge (why most agents fail here)
How to build compiler-accurate agents
=== WHY MOST AGENTS ARE BROKEN ===
Standard approach: ├─ Use LLM to understand code (GPT-4o, Claude, etc) ├─ LLM sees code as text (not AST) ├─ LLM uses pattern matching (regex-like thinking) ├─ LLM makes mistakes (false positives in edge cases) ├─ Result: Agent is unreliable
Why LLMs fail: ├─ LLMs don't understand semantics (only syntax) ├─ LLMs can't track control flow (only pattern match) ├─ LLMs can't resolve types (don't know what belongs to what) ├─ LLMs can't handle reflection (unpredictable) ├─ LLMs hallucinate (make up code that looks plausible)
=== GRAPHIFY C# APPROACH (CORRECT) ===
Graphify uses: ├─ Roslyn (C# compiler APIs) ├─ Semantic analysis (type resolution, control flow) ├─ Compiler internals (what the compiler knows) ├─ Graph database (represent code structure) ├─ Query API ("give me all usages of this method")
Result: ├─ 100% accurate (matches compiler understanding) ├─ Zero false positives (compiler verified) ├─ Fast (graph queries are O(1)) ├─ Reliable (not ML-based, deterministic)
=== FOR YOUR AGENTS ===
Option 1: Use Graphify-like approach ├─ Cost: Build compiler-accurate indexer (R$ 50K-100K) ├─ Time: 3-6 months engineering ├─ Result: Agent is precise, defensible ├─ Payoff: 3-5 year moat (hard for competitors to match)
Option 2: Combine LLM + compiler ├─ Use LLM for generation (creative, fast) ├─ Use compiler for verification (accurate, safe) ├─ Architecture: LLM → generates code → compiler checks → approved ├─ Result: Fast + accurate (best of both) ├─ Payoff: User perception is "agent never breaks code"
Option 3: Use off-the-shelf (Graphify) ├─ Cost: R$ 0 (open-source) ├─ Time: 1-2 weeks integration ├─ Result: Agent is accurate (immediate) ├─ Payoff: Competitive parity (everyone has Graphify)
Recommendation: ├─ Start with Option 3 (Graphify) ├─ Build to market fast (prove hypothesis) ├─ Move to Option 2 (LLM + compiler) long-term ├─ Invest in Option 1 (custom compiler-accurate) if you hit scale
Conclusion: Code understanding is your competitive moat
The reality (Graphify C# just proved it):
- Production code analysis requires compiler-level accuracy (not pattern matching)
- Standard agents using regex/simple AST have 30-40% error rate
- Error rate causes developer distrust ("agent breaks my code")
- Distrust leads to non-adoption (developers don't use agent)
- Precision (compiler-accurate) is defensible moat (hard to match)
- Accuracy drives unit economics (high trust = low churn = high LTV)
Your choice (2 paths):
Path 1: Keep pattern matching approach (current path)
- Accuracy: 60-70% (false positives, false negatives)
- Developer perception: "Agent breaks code sometimes"
- Usage rate: 10-20% of developers (low adoption)
- Churn rate: 40-50% (high, after first bad experience)
- NPS: 20-30 (detractors)
- Unit economics: Broken (high CAC, high churn)
- Competitive position: Losing to accurate competitors
- Recommendation: NOT recommended (unsustainable)
Path 2: Migrate to compiler-accurate NOW (smart)
- Accuracy: 98-100% (zero false positives)
- Developer perception: "Agent works perfectly"
- Usage rate: 80-90% of developers (high adoption)
- Churn rate: 5-10% (low, developers stay)
- NPS: 70-80 (promoters, word-of-mouth)
- Unit economics: Strong (lower CAC, high LTV)
- Competitive position: Leading (trust + precision)
- Implementation: 1-6 months (depending on approach)
- Recommendation: REQUIRED (this is table-stakes for code agents)
At OpenClaw, we help SaaS build compiler-accurate agents:
- CODE ANALYSIS AUDIT: Measure current accuracy (probably 60-70%)
- COMPILER INTEGRATION: Choose approach (Graphify, Roslyn, LSP, custom)
- SEMANTIC INDEXING: Build code graph (type resolution, control flow)
- QUERY API: Implement precise code queries (usages, dependencies, etc)
- LLM + COMPILER HYBRID: Generate code with compiler verification
- REFACTORING ENGINE: Safe refactorings (compiler-verified)
- DEAD CODE DETECTION: Accurate (no false removals)
- DEPENDENCY ANALYSIS: Understand reflection, plugins, dynamic calls
- TESTING: Comprehensive (verify accuracy on real codebases)
- DEVELOPER EXPERIENCE: Show confidence scores (when agent is certain vs uncertain)
Result: Your agent goes from 60% accuracy (unreliable) to 98%+ accuracy (trusted). Developer adoption increases 5-8x. Unit economics improve dramatically. Your agent becomes the "one they trust."
Seu agente entende código com precisão compilador?
Você sabe seu accuracy rate (provavelmente 60-70%, não 100%)?
Developers confiam nas sugestões do seu agente?
Você teve casos onde agente sugeriu refatoração quebrada?
Você usa pattern matching simples (regex, AST básico)?
Você tem false positives em "find usages"?
Você entende reflection, generics, dynamic calls?
Seu agente de código tem moat defensável (vs competidores)?
Seu NPS é 70+ (promoters) ou <30 (detractors)?
Você quer migrar pra compiler-accurate mas não sabe como?
Se quer expert guidance (code analysis audit, compiler integration, semantic indexing, query API, LLM + compiler hybrid, refactoring engine, dead code detection, dependency analysis, testing, developer experience):
Publicado em 12 de setembro de 2026