trace_step
Log agent decision steps with confidence scores and reasoning to create audit trails for safety monitoring and analysis.
Instructions
Log a decision step in the current trace session.
Args: name: Step name (e.g. "analyze_signal", "classify_intent"). decision: What the agent decided. confidence: Confidence score (0.0-1.0). input_data: What the agent saw (brief description). reason: Why this decision was made. outcome: "ok" or "error".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| decision | No | ||
| confidence | No | ||
| input_data | No | ||
| reason | No | ||
| outcome | No | ok |
Implementation Reference
- src/agent_safety_mcp/server.py:291-325 (handler)The implementation of the 'trace_step' tool, which logs a decision step to a tracer instance.
def trace_step( name: str, decision: str = "", confidence: float = 0.0, input_data: str = "", reason: str = "", outcome: str = "ok", ) -> dict: """Log a decision step in the current trace session. Args: name: Step name (e.g. "analyze_signal", "classify_intent"). decision: What the agent decided. confidence: Confidence score (0.0-1.0). input_data: What the agent saw (brief description). reason: Why this decision was made. outcome: "ok" or "error". """ tracer = _get_tracer() with tracer.step(name, input=input_data) as step: logs = {} if decision: logs["decision"] = decision if confidence: logs["confidence"] = confidence if reason: logs["reason"] = reason if logs: step.log(**logs) if outcome == "error": step.fail(reason=reason or "unspecified error") return { "recorded": True, "step": name, - src/agent_safety_mcp/server.py:290-290 (registration)The registration of the 'trace_step' tool using the @mcp.tool decorator.
@mcp.tool()