KrishiSathi / trace.py
roshan-acharya's picture
feat:add code to spaces
e4ab643
Raw
History Blame Contribute Delete
500 Bytes
# trace.py
import json
from datetime import datetime
TRACE = []
def log_step(step_name: str, data: dict):
"""
Logs every node execution step in the agent.
"""
TRACE.append({
"timestamp": str(datetime.now()),
"step": step_name,
"data": data
})
def get_trace():
return TRACE
def clear_trace():
global TRACE
TRACE = []
def save_trace(file_path="agent_trace.json"):
with open(file_path, "w") as f:
json.dump(TRACE, f, indent=2)