Skip to main content
Glama

get_trace_decisions

Extract decision events from a trace to inspect proposal, override, approval, or binding steps in a workflow.

Instructions

Extract normalized decision.* events from one trace. Use this when a workflow includes proposal, override, approval, or binding steps.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
trace_idYesThe trace ID to inspect for decision events

Implementation Reference

  • The handler for the 'get_trace_decisions' tool. Calls client.getTrace to fetch a trace, extracts decision events from the trace events using extractDecisionEvents, and returns the decisions as JSON.
    {
      name: "get_trace_decisions",
      description:
        "Extract normalized decision.* events from one trace. " +
        "Use this when a workflow includes proposal, override, approval, or binding steps.",
      inputSchema: {
        type: "object",
        properties: {
          trace_id: { type: "string", description: "The trace ID to inspect for decision events" },
        },
        required: ["trace_id"],
      },
      handler: async (client, args) => {
        const traceId = args.trace_id as string;
        const result = await client.getTrace(traceId);
        const events = Array.isArray(result.events) ? result.events : [];
        const decisions = extractDecisionEvents(events as Array<Record<string, unknown>>, {
          traceId,
        });
        return JSON.stringify({ trace_id: traceId, decisions }, null, 2);
      },
    },
  • Core helper that extracts normalized decision events from a trace event array. Maps events through extractDecisionPayload, filters out nulls, and optionally filters by workflowId, decisionId, or traceId.
    export function extractDecisionEvents(
      events: TraceEvent[],
      filters?: {
        workflowId?: string;
        decisionId?: string;
        traceId?: string;
      },
    ): DecisionPayload[] {
      return events
        .map((event) => extractDecisionPayload(event))
        .filter((payload): payload is DecisionPayload => payload !== null)
        .filter((payload) => !filters?.workflowId || payload.workflow_id === filters.workflowId)
        .filter((payload) => !filters?.decisionId || payload.decision_id === filters.decisionId)
        .filter((payload) => !filters?.traceId || payload.trace_id === filters.traceId);
    }
  • Helper that validates a trace event is a decision event via isDecisionEvent, then normalizes the payload into a DecisionPayload object with all standard decision fields.
    export function extractDecisionPayload(event: TraceEvent): DecisionPayload | null {
      if (!isDecisionEvent(event)) {
        return null;
      }
      const payload = isRecord(event.data) ? event.data : {};
      const normalized = {} as DecisionPayload;
    
      for (const field of DECISION_FIELDS) {
        normalized[field] = payload[field];
      }
    
      normalized.trace_id = normalized.trace_id ?? event.trace_id;
      normalized.event_type = normalized.event_type ?? event.name;
      return normalized;
    }
  • Helper that checks if a trace event is a decision event by verifying event kind is 'event' and the name or data.event_type is in the set of decision event types (proposed, edited, overridden, approved, bound).
    export function isDecisionEvent(event: TraceEvent): boolean {
      if (!isRecord(event) || event.kind !== "event") {
        return false;
      }
      if (typeof event.name === "string" && DECISION_EVENT_TYPES.has(event.name)) {
        return isRecord(event.data);
      }
      return isRecord(event.data) && typeof event.data.event_type === "string" && DECISION_EVENT_TYPES.has(event.data.event_type);
    }
  • Schema definition for decision fields and the DecisionPayload type. Defines the shape of normalized decision data extracted from trace events.
    const DECISION_FIELDS = [
      "decision_id",
      "workflow_id",
      "trace_id",
      "object_type",
      "object_id",
      "actor_type",
      "actor_id",
      "event_type",
      "proposal",
      "final",
      "diff",
      "reason",
      "comment",
      "timestamp",
      "binding_state",
      "outcome",
    ] as const;
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the action (extract) implies a read operation, but does not explicitly confirm no side effects or destructive behavior. For a read tool, this is adequate but minimal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no wasted words. The action is front-loaded, and the usage condition is stated concisely. Perfectly sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given only one parameter and no output schema, the description adequately explains the purpose and usage. It could mention return format (e.g., 'returns normalized decisions objects'), but is effectively complete for the tool's simplicity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with param 'trace_id' described as 'The trace ID to inspect for decision events.' The description adds context about the workflow steps but does not add significant meaning beyond the schema. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Extract normalized decision.* events from one trace' with a specific verb and resource. It differentiates from siblings like get_trace or query_traces by focusing on decision events. It also enumerates the types of workflow steps (proposal, override, approval, binding), giving precise context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description tells when to use the tool: 'when a workflow includes proposal, override, approval, or binding steps.' This provides clear context. However, it does not explicitly name alternative tools or provide when-not-to-use guidance, which would raise the score to 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bmdhodl/agent47'

If you have feedback or need assistance with the MCP directory API, please join our Discord server