<@U0A9RLDPQU8> this message is relevant to your ph...
# proj-agent
r
@modern-fireman-99755 this message is relevant to your phased PR plan for the AST refactor issue #2721, posted here because others likely have opinions: In the parse-once-query-thrice architecture (your 2c plan), each detector class needs direct AST access. I think the ideal implementation would be: parse() returns a ParseResult dataclass exposing root_node as a public, read-only field alongside the convenience iterators (iter_simple_commands, iter_pipelines, etc.). Detector classes can then live outside shell_parser.py without needing private accessors. If root_node is public, an AST-to-CSV exporter (externally maintained, not in the SDK) can feed parsed ASTs into a graph-theoretic analyzer for structural analysis of agent action traces. I've been building out the graph-theory side of this for a while (navi-fractal). Long agentic sessions may produce graphs with measurable structure that distinguishes benign from anomalous behavior. So, with your thumbs up, I'm asking for read-only root_node on ParseResult. No export, no analyzer, no new behavior, no new dep. A future graph-theoretic analyzer would be a separate opt-in PR or stay external, purely the maintainers' call when that time comes. Edit: theory grounding from recent research here: https://arxiv.org/pdf/2603.22868
w
Long agentic sessions may produce graphs with measurable structure that distinguishes benign from anomalous behavior.
Interesting -- have you seen this in practice? Any sense of how long the sessions might need to be to produce a detectable signal?
r
Not in practice specifically, and it will depend highly on how well the graph types are structured so we don't get edge explosion. I have done graph-theoretic analysis on the entropy distribution on LLM output tokens via parameterized hashes and demonstrated interesting separation, but not yet specifically on action traces. I'd want to lock topology first since edge explosion makes the question ill-defined. Different metrics also have different appetites -- centrality at ~20 nodes, WL hashes at ~50, power-law tail fits at ~100-500, fractal dimension at ~10^3+. So "long" cashes out differently per metric. If you've got intuition about real OpenHands session-length distributions, that would really help.
w
I don't have a sense off the top of my head but it shouldn't be hard to find out. That arxiv paper you linked, is that a decent starting point for a graph rep of a trajectory? Section 4.3? As soon as I've got some free cycles I want to experiment with this perspective.
r
Yes, and: the graph is defined in Section 4.1.3 (nodes = tool calls, edges = per-argument source pointers with derivation type ∈ {verbatim, derived, generated}). Section 4.3 derives 17 hand-crafted features and 11 rule-based detectors from it but computes no graph-theoretic invariants (centrality, entropy, motifs, WL, self-similarity), so layering topology metrics on the same G_τ representation would work better experimentally. If the topology doesn't separate anything, the null result would be the first published characterization of the gap. And the AST-to-CSV export capability would give us an observation window into a system that currently has none at the structural level.
Based on the research I've scouted, the industry is moving away from linear logs and into graph-theoretic & hybrid analysis. I can share one or two more papers when you get the cycles :).
w
Oh yes, would love some refs! Need some "light reading" for the weekend
🐕 2