HACKER Q&A
📣 enismustafaj

"AST vs. Code" as Context for AI Agents


What is better to provide to the AI Agent, a parsed version of code in the form of an Abstract Syntaxt Tree or the code itself? Where would it be more beneficial to make changes and why so?


  👤 theGeatZhopa Accepted Answer ✓
Code has commentary parts, which vanish when generating AST. Also, if feeding AST, sometimes the broad context is lost. And, AST might have a compression advantage on looong code, but inflate on short functions (means it would be better to feed the code line) and from my experience, AST use up more tokens then the plain code just caused by "AST representation is longer than the peace of code it represents". So, I stopped trying to teach Claude what I wanted with the AST.