Process-centric analysis of agentic software systems.
Graphectory transforms agent execution traces into structured graphs that capture the problem-solving patterns of AI software engineering agents. By modeling agent actions as directed graphs with phase classification (localization, patching, validation), this tool enables systematic analysis of how agents approach and solve software engineering tasks.
git git@github.com:Intelligent-CAT-Lab/Graphectory_CS527.git
cd Graphectory_CS527
python -m pip install -e .We recommend using conda or virtual environments to manage dependencies.
python graph_construction/generate_graphs.py \
--agent {sa|oh} \
--model {dsk-v3|dsk-r1|dev|cld-4|gpt-5-mini} \
--trajs <path_to_trajectories> \
--eval_report <path_to_report.json> \
--output_dir <output_directory>SWE-agent with GPT-5-mini: Below is the command to construct graphs for the 500 SWE-agent (backboned with GPT-5-mini) trajectories
python graph_construction/generate_graphs.py \
--agent sa --model gpt-5-mini \
--trajs ./Trajectories/gpt-5-mini-traj \
--eval_report data/SWE-agent/reports/gpt-5-mini.json \
--output_dir data/samplesOutput: {output_dir}/{Agent}/graphs/{model}/{instance_id}/{instance_id}.{json,pdf}
| Argument | Description | Format |
|---|---|---|
--agent |
Agent type | sa (SWE-agent), oh (OpenHands) |
--model |
Model identifier | dsk-v3, dsk-r1, dev, cld-4, gpt-5-mini (extensible) |
--trajs |
Trajectory path | SWE-agent: directory with .traj filesOpenHands: output.jsonl file |
--eval_report |
Evaluation report | JSON with resolved_ids/unresolved_ids keys |
--output_dir |
Base output directory | Organized as {agent}/graphs/{model}/{instance_id}/ |
--workers |
Parallel workers (optional) | Default: 8 |
- Parsing: Agent trajectories → atomic actions (tool calls, commands, subcommands)
- Node Deduplication: Identical actions merged with occurrence tracking
- Phase Classification: Actions categorized using heuristics (mapPhase.py):
- Localization: Information gathering, searching, test generation before patching
- Patch: Creating/editing non-test files
- Validation: Running tests or editing test files after patching
- General: Other actions (planning, environment setup)
- Edge Construction: Execution edges (sequential flow) + hierarchical edges (conceptual dependencies)
- Output: JSON (NetworkX node-link format) + PDF visualization with phase-colored nodes
Graph Metadata: Each graph includes resolution_status, instance_name, and debug_difficulty
You can easily add new models without code modification:
python graph_construction/generate_graphs.py \
--agent sa --model your-custom-model \
--trajs <your_trajectories> \
--eval_report <your_report> \
--output_dir <output>Simply provide a unique model identifier. Outputs will be organized under graphs/your-custom-model/.
To parse custom SWE-agent tools:
- Add the tool's
config.yamlto graph_construction/generate_graphs.py:236-242 - Update
tool_configslist insetup_parser_for_agent()
Example:
tool_configs = [
"data/SWE-agent/tools/edit_anthropic/config.yaml",
"data/SWE-agent/tools/your_custom_tool/config.yaml", # Add here
]To add support for a new agent framework:
-
Implement trajectory loader in buildGraph.py following the pattern:
def build_graph_from_newagent_trajectory(traj_data, parser, instance_id, output_dir, eval_report_path): builder = GraphBuilder() # Parse agent-specific trajectory structure # Convert to builder.add_or_update_node() calls return builder.finalize_and_save(output_dir, instance_id, eval_report_path)
-
Add agent mapping in generate_graphs.py:
- Update
SUPPORTED_AGENTSandAGENT_NAMES - Add conditional branch in
GraphProcessor.process_trajectory()
- Update
Key principle: Different agents have different trajectory formats, but all generate the same unified graph structure (nodes with phases, execution/hierarchical edges, metadata).
Pre-computed analysis results for the full dataset are available under data/{OpenHands|SWE-agent}/analysis, including Graphectory metrics.
python -m graph_analysis.batch_runnerpython -m graph_analysis.batch_runner --data-dir ./my_data --output-dir ./my_outputResults are saved to trajectory_metrics.csv.