๐ง AI Agent Debugging ToolsJune 24, 2026โ
Tests passing
Agent Decision Tracer
This tool allows developers to trace the step-by-step decision-making process of AI agents, capturing intermediate states, decisions, and the associated reasoning at each step. It helps debug complex agent behaviors by visualizing their execution path in a clear and structured format.
What It Does
- Load decision logs from a JSON file or stdin.
- Validate the structure of decision logs.
- Generate a visual execution graph in
.dotor.pngformat. - Optionally save structured trace logs as JSON.
Installation
Install the required Python package:
pip install graphvizUsage
Input JSON file (input.json):
[
{"step": 1, "decision": "start", "reasoning": "initialization"},
{"step": 2, "decision": "move", "reasoning": "next step", "previous_step": 1}
]Command:
python agent_decision_tracer.py --input input.json --output output_graph.png --log trace_logs.jsonOutput:
output_graph.png: A visual representation of the execution graph.trace_logs.json: The structured trace logs.
Source Code
import argparse
import json
import sys
from graphviz import Digraph
def parse_arguments():
parser = argparse.ArgumentParser(description="Agent Decision Tracer: Trace AI agent decisions and visualize execution paths.")
parser.add_argument('--input', type=str, help="Path to the JSON file containing decision logs. Use '-' for stdin.", required=True)
parser.add_argument('--output', type=str, help="Path to save the output graph (.dot or .png).", required=True)
parser.add_argument('--log', type=str, help="Path to save the structured trace logs as JSON.", required=False)
return parser.parse_args()
def load_decision_logs(input_path):
if input_path == "-":
try:
return json.load(sys.stdin)
except json.JSONDecodeError as e:
raise ValueError("Invalid JSON input from stdin.") from e
else:
try:
with open(input_path, 'r') as f:
return json.load(f)
except FileNotFoundError:
raise FileNotFoundError(f"Input file '{input_path}' not found.")
except json.JSONDecodeError as e:
raise ValueError(f"Invalid JSON in file '{input_path}'.") from e
def validate_decision_logs(logs):
if not isinstance(logs, list):
raise ValueError("Decision logs must be a list of events.")
for event in logs:
if not isinstance(event, dict) or 'step' not in event or 'decision' not in event or 'reasoning' not in event:
raise ValueError("Each event must be a dictionary with 'step', 'decision', and 'reasoning' keys.")
def generate_execution_graph(logs, output_path):
graph = Digraph(format=output_path.split('.')[-1])
for event in logs:
step = event['step']
decision = event['decision']
reasoning = event['reasoning']
graph.node(str(step), f"Step {step}\nDecision: {decision}\nReasoning: {reasoning}")
if 'previous_step' in event:
graph.edge(str(event['previous_step']), str(step))
graph.render(output_path.rsplit('.', 1)[0], cleanup=True)
def save_trace_logs(logs, log_path):
if log_path:
with open(log_path, 'w') as f:
json.dump(logs, f, indent=4)
def main():
args = parse_arguments()
try:
decision_logs = load_decision_logs(args.input)
validate_decision_logs(decision_logs)
generate_execution_graph(decision_logs, args.output)
if args.log:
save_trace_logs(decision_logs, args.log)
print(f"Execution graph saved to {args.output}")
if args.log:
print(f"Trace logs saved to {args.log}")
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
main()Community
Downloads
ยทยทยท
Rate this tool
No ratings yet โ be the first!
Details
- Tool Name
- agent_decision_tracer
- Category
- AI Agent Debugging Tools
- Generated
- June 24, 2026
- Tests
- Passing โ
- Fix Loops
- 4
Quick Install
Clone just this tool:
git clone --depth 1 --filter=blob:none --sparse \ https://github.com/ptulin/autoaiforge.git cd autoaiforge git sparse-checkout set generated_tools/2026-06-24/agent_decision_tracer cd generated_tools/2026-06-24/agent_decision_tracer pip install -r requirements.txt 2>/dev/null || true python agent_decision_tracer.py