Spaces:
Runtime error
Runtime error
| # 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) |