Inferensys

Prompt

Agent Action Decision Log Prompt

A practical prompt playbook for using the Agent Action Decision Log Prompt in production AI workflows to capture agent reasoning, alternatives considered, and policy constraints at the moment of tool selection.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for generating structured decision records from agent tool selection events.

This prompt is designed for AI operations engineers, SREs, and compliance officers who need to understand why an agent chose a specific tool at a specific moment. It transforms an opaque tool selection event into a structured, auditable decision record. The primary job-to-be-done is debugging multi-step agent failures and proving governance by capturing the agent's stated reasoning, alternatives considered, confidence level, and the policy constraints active during tool selection. This is not a prompt for generating tool calls; it is a post-hoc analysis prompt that takes an existing tool call event and its surrounding context to produce a human-readable and machine-parseable rationale.

Use this prompt when you have a log of a tool call but lack the 'why' behind it. The ideal user has access to the agent's full context window or a summary of its state immediately before the tool was invoked, including the system prompt, tool descriptions, and recent conversation history. You should not use this prompt for real-time tool selection enforcement—it is an observability tool, not a gating mechanism. It is also unsuitable for agents with extremely limited context where the reasoning is self-evident, or for simple, deterministic tool chains where the selection logic is hardcoded in application code rather than decided by the model.

The output is a structured JSON record containing fields like decision_rationale, alternatives_considered, confidence_score, and policy_constraints_checked. This record is designed to be ingested by log aggregation systems, audit databases, or debugging dashboards. Before shipping this prompt to production, you must define evaluation criteria that check for missing rationale fields, generic or circular reasoning (e.g., 'I chose it because it was the right tool'), and hallucinations where the agent references tools or policies not present in the provided context. A human review step is critical for high-risk domains like finance or healthcare, where an incorrect decision record could mask a serious compliance violation.

To get started, gather a sample of agent tool call events and their preceding context. Run the prompt template against these samples and manually inspect the output for faithfulness to the provided context. Pay close attention to the alternatives_considered field—a common failure mode is the agent listing tools that were not actually available or failing to mention a clearly superior alternative. Once you are confident in the output quality, integrate the prompt into your agent's post-tool-call logging pipeline, ensuring that every decision record is validated against your schema before being written to permanent storage.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Agent Action Decision Log Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your operational context before integrating it into an agent harness.

01

Good Fit: Post-Hoc Debugging

Use when: an agent's tool choice caused a production incident and the team needs to reconstruct why that tool was selected. Guardrail: Run the prompt against the exact agent state snapshot from the moment of decision, not a re-created or summarized context.

02

Good Fit: Compliance Evidence

Use when: auditors require a record of why an agent took a specific action, including alternatives considered and policy constraints applied. Guardrail: Store the decision log immutably at invocation time; do not regenerate it later from incomplete traces.

03

Bad Fit: Real-Time Guardrails

Avoid when: you need to block a tool call before it executes. This prompt explains decisions after the fact. Guardrail: Use a pre-execution policy evaluation prompt or a hard-coded permission check before the tool call, not this retrospective log.

04

Bad Fit: High-Frequency Tool Loops

Avoid when: an agent makes dozens of tool calls per second in a tight loop. Generating a full decision log per call will blow latency and cost budgets. Guardrail: Sample or aggregate decision logs for high-frequency calls; log full records only for anomalous or high-risk tool selections.

05

Required Inputs

Risk: Missing fields produce useless logs. Guardrail: Ensure the prompt receives the agent's full reasoning trace, the list of available tools with schemas, the user's intent, any active policy constraints, and the final tool selected. Validate completeness before writing the log record.

06

Operational Risk: Rationalization

Risk: The model may fabricate plausible-sounding reasoning that did not actually drive the tool selection, especially when the real decision was a low-confidence fallback. Guardrail: Cross-reference the decision log against the raw agent trace and flag inconsistencies where the stated rationale contradicts observed behavior.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for generating structured decision records that capture an agent's reasoning at the moment of tool selection.

This template is the core instruction set you will send to a model to produce an Agent Action Decision Log. It is designed to be invoked immediately after an agent selects a tool but before execution, or retrospectively from a trace. The prompt forces the model to articulate its reasoning, enumerate considered alternatives, state its confidence, and reference the specific policy constraints that shaped its decision. Use this template as a starting point: you will need to populate the placeholders with your specific tool catalog, session context, and organizational policies.

text
You are an observability recorder for an AI agent. Your only job is to produce a structured decision log explaining why the agent chose a specific tool. Do not execute any tool. Do not continue the agent's task.

## Inputs
- [AGENT_ROLE_DESCRIPTION]
- [CURRENT_TASK_AND_GOAL]
- [AVAILABLE_TOOLS_WITH_SCHEMAS]
- [TOOL_SELECTED_BY_AGENT]
- [AGENT_PROPOSED_ARGUMENTS]
- [RECENT_AGENT_REASONING_TRACE]
- [APPLICABLE_POLICIES_AND_SCOPE]

## Output Schema
Produce a single JSON object conforming to this structure:
{
  "decision_log": {
    "timestamp": "ISO 8601",
    "session_id": "string",
    "agent_role": "string",
    "task_summary": "One-sentence summary of the agent's current goal.",
    "tool_selected": {
      "name": "string",
      "arguments": {},
      "rationale": "Explain why this tool was chosen over others."
    },
    "alternatives_considered": [
      {
        "tool_name": "string",
        "reason_rejected": "Specific reason, e.g., insufficient scope, higher latency, policy violation."
      }
    ],
    "confidence_assessment": {
      "score": "0.0 to 1.0",
      "factors": ["List of factors increasing or decreasing confidence."]
    },
    "policy_evaluation": {
      "policies_checked": ["Policy names and versions"],
      "constraint_violations": ["Any policy violations detected, or 'none'"],
      "requires_approval": true_or_false
    },
    "risk_notes": "Any noted risks, edge cases, or uncertainty about the tool's outcome."
  }
}

## Constraints
- If fewer than two alternatives were considered, explain why in the rationale.
- If confidence is below [CONFIDENCE_THRESHOLD], flag `requires_approval` as true.
- Reference specific policy names from [APPLICABLE_POLICIES_AND_SCOPE]. Do not invent policies.
- If the agent's reasoning trace is empty or truncated, set confidence to 0.0 and note the missing data.

To adapt this template, replace each square-bracket placeholder with data from your agent runtime. The [AVAILABLE_TOOLS_WITH_SCHEMAS] should be a complete dump of the tool definitions the agent saw at decision time, not a curated subset. The [RECENT_AGENT_REASONING_TRACE] is critical for fidelity; if your agent framework does not produce a reasoning trace, you must either add one or accept that the decision log will have low confidence and limited diagnostic value. For high-risk domains, wire the output of this prompt into a human review queue before the tool is executed, using the requires_approval boolean as a routing signal.

IMPLEMENTATION TABLE

Prompt Variables

Inputs required for the Agent Action Decision Log Prompt to produce reliable, auditable decision records. Each placeholder must be populated before the prompt is sent.

PlaceholderPurposeExampleValidation Notes

[AGENT_ID]

Unique identifier for the agent instance making the decision

agent-7f3a2b-prod-us-east

Must match ^[a-z0-9-]+$ pattern. Reject if empty or 'unknown'.

[SESSION_ID]

Correlates all decisions within a single user or task session

sess-8a1c4e-2025-03-15

UUID v4 format required. Null allowed only for stateless single-turn decisions.

[TASK_CONTEXT]

The user request, goal, or triggering event that initiated the agent's action

Find all P0 bugs assigned to me and create a summary report

Must be non-empty string. Truncate to 2000 chars if longer. Log truncation event.

[AVAILABLE_TOOLS_JSON]

JSON array of tool definitions with name, description, and parameter schemas visible to the agent

[{"name": "search_issues", "description": "Search Jira issues by JQL", "parameters": {...}}]

Must parse as valid JSON array. Each tool object requires 'name' and 'description' fields. Reject if array is empty.

[SELECTED_TOOL]

The name of the tool the agent chose to invoke

search_issues

Must exactly match a 'name' value from [AVAILABLE_TOOLS_JSON]. Case-sensitive comparison required.

[TOOL_ARGUMENTS_JSON]

The arguments the agent passed to the selected tool

{"jql": "project = PROJ AND priority = P0 AND assignee = currentUser()"}

Must parse as valid JSON. Validate argument types against the selected tool's parameter schema from [AVAILABLE_TOOLS_JSON].

[CONFIDENCE_SCORE]

Agent's self-assessed confidence in this tool choice, typically 0.0 to 1.0

0.92

Must be a float between 0.0 and 1.0 inclusive. Flag scores below 0.5 for human review if tool is write-capable.

[POLICY_CONSTRAINTS_JSON]

JSON array of active policy rules that constrained the agent's tool selection

[{"policy": "no-prod-writes", "effect": "deny", "tools_blocked": ["deploy_service"]}]

Must parse as valid JSON array. If empty array, decision log must note 'no policy constraints applied'. Validate each policy object has 'policy' and 'effect' fields.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Agent Action Decision Log prompt into a production agent harness with validation, retries, and audit persistence.

The Agent Action Decision Log prompt is not a standalone artifact—it is a synchronous interceptor that must execute inside the agent's tool-selection loop, after the model has chosen a tool but before the tool is invoked. The harness calls the LLM with this prompt, passing the agent's current state, the proposed tool call, and the list of alternative tools that were available. The output is a structured decision record that must be validated, persisted to the audit log, and optionally used to gate tool execution if the rationale is missing, incoherent, or violates a policy constraint. This prompt is high-stakes: a missing or malformed decision record can create a compliance gap, so the harness must treat a failure to produce a valid record as a blocking error, not a warning.

Integration point: Insert this prompt inside the agent's select_tool or pre_invoke hook. The harness must supply [AGENT_STATE] (current task, conversation history, memory), [PROPOSED_TOOL] (the tool name and arguments the model selected), [AVAILABLE_TOOLS] (the full tool registry with descriptions and capability metadata), [POLICY_CONSTRAINTS] (scope boundaries, rate limits, permission rules), and [CONFIDENCE_THRESHOLD] (the minimum self-reported confidence before escalation). Validation: After the LLM returns the decision record, validate that all required fields are present (rationale, alternatives_considered, confidence_score, policy_check_result, tool_selected, timestamp). If any field is missing or confidence_score is below [CONFIDENCE_THRESHOLD], route to a human approval queue or a fallback retry with a more explicit prompt variant. Retries: Use a single retry with an error message injected into [PREVIOUS_ERROR] if the first attempt fails validation. Do not retry more than once—escalate instead to avoid loop-based hallucinations.

Persistence and audit: Write every validated decision record to an append-only audit store with a unique decision_id, a hash of the agent state that produced it, and the model version used. This record becomes the primary evidence for compliance reviews and incident reconstruction. Model choice: Use a model with strong structured-output support (GPT-4o, Claude 3.5 Sonnet, or equivalent) and enforce JSON mode or structured outputs to prevent format drift. Observability: Emit a trace span for the decision-log generation step with the decision_id, latency, and validation status. If the decision record triggers an escalation, attach the record to the escalation ticket. What to avoid: Do not generate decision records asynchronously or in batch after the tool has already executed—the value is in the pre-execution rationale. Do not skip validation in production; a malformed decision record is worse than no record because it creates a false sense of audit readiness.

IMPLEMENTATION TABLE

Expected Output Contract

Validate every field in the agent action decision log before writing to the audit trail or observability system.

Field or ElementType or FormatRequiredValidation Rule

decision_id

UUID v4 string

Parse as UUID; reject if nil or version mismatch

timestamp

ISO 8601 UTC string

Parse with DateTime; reject if future or >5min clock skew from system time

session_id

string

Non-empty; must match active session context

tool_selected

string

Must exist in [AVAILABLE_TOOLS] registry at decision time

tool_call_id

string

Non-empty; must correlate to downstream tool invocation span

reasoning_summary

string (1-500 chars)

Length check 1-500; reject if empty or only whitespace

alternatives_considered

array of objects

Min 1 entry; each object must contain tool_name and rejection_reason fields

confidence_score

float 0.0-1.0

Range check 0.0-1.0; reject if NaN or null

policy_constraints_applied

array of strings

Each string must match a policy ID in [ACTIVE_POLICIES]; reject if empty when policies exist

user_approval_required

boolean

Must be true if tool_selected is in [HIGH_RISK_TOOLS]; reject if mismatch

input_arguments_hash

SHA-256 hex string

64-char hex; reject if length != 64 or non-hex characters

decision_context_snapshot

string (JSON)

If present, must parse as valid JSON; null allowed

PRACTICAL GUARDRAILS

Common Failure Modes

When agents log their own decisions, the most dangerous failures are the ones that look correct. These are the common ways the Agent Action Decision Log Prompt breaks in production and how to catch them before they reach an audit.

01

Rationale Hallucination

What to watch: The agent fabricates a plausible but false reason for choosing a tool, often by mirroring the tool's description instead of analyzing the actual input. Guardrail: Require the prompt to cite specific evidence from the user's request or prior tool outputs in the rationale field. Validate that the cited evidence exists in the source context.

02

Missing Alternatives Analysis

What to watch: The agent omits the 'alternatives considered' section, especially when confidence is high, creating a log that implies only one path was ever possible. Guardrail: Add a strict output schema constraint that the alternatives_considered array must contain at least one entry, even if it's a brief dismissal with a reason. Fail validation if the array is empty or missing.

03

Confidence-Action Mismatch

What to watch: The agent reports low confidence in its decision but proceeds with a destructive or irreversible tool call anyway, or reports high confidence with no supporting evidence. Guardrail: Implement a post-generation validation rule that flags any log where confidence_score is below a defined threshold (e.g., 0.7) and the tool_name is in a list of high-risk actions. Route these for human review.

04

Policy Constraint Drift

What to watch: The agent correctly logs that a policy constraint was checked but misinterprets the policy's scope, applying a permissive rule to a restricted context. Guardrail: Include the exact text of the relevant policy in the prompt's context. Instruct the agent to quote the specific policy clause in the policy_constraints field. A separate evaluation prompt can then check for semantic alignment between the clause and the decision.

05

Context Window Truncation

What to watch: In long agent loops, earlier context is truncated, causing the decision log to be based on incomplete information without the agent realizing it. Guardrail: Design the prompt to require a context_window_summary field that explicitly states the earliest and latest timestamps of the context it considered. A validator can then check if this range matches the expected session history.

06

Tool Name Ambiguity

What to watch: The agent logs a generic or aliased tool name (e.g., 'search') instead of the fully qualified, versioned function name (e.g., 'vector_search_v2'), making audit trails impossible to trace to a specific implementation. Guardrail: The prompt's output schema must require the exact function_name from the tool definition. Use a post-generation check against a list of allowed tool names to catch any unregistered or ambiguous strings.

IMPLEMENTATION TABLE

Evaluation Rubric

Use these criteria to evaluate the quality of the Agent Action Decision Log before deploying it to production. Each row defines a pass standard, a failure signal, and a concrete test method.

CriterionPass StandardFailure SignalTest Method

Rationale Completeness

The [RATIONALE] field contains a specific, non-generic explanation referencing the user's intent, the tool's documented capability, and the current state.

The [RATIONALE] field is empty, contains only a generic phrase like 'best tool for the job', or hallucinates a tool capability not in the [TOOL_SCHEMA].

Parse the output. Assert [RATIONALE] length > 50 characters. Use an LLM-as-judge with a binary prompt: 'Does this rationale reference a specific tool capability from the provided schema? Answer YES or NO.'

Alternatives Considered

The [ALTERNATIVES_CONSIDERED] array lists at least one other available tool by name and provides a concrete reason for its rejection.

The array is empty, lists the chosen tool as an alternative, or provides a rejection reason that is factually incorrect based on the [TOOL_SCHEMA].

Assert [ALTERNATIVES_CONSIDERED] is an array with length >= 1. For each entry, verify the tool name exists in [TOOL_SCHEMA] and the rejection reason is not a substring of the chosen tool's description.

Confidence Score Validity

The [CONFIDENCE_SCORE] is a float between 0.0 and 1.0 and correlates with the specificity of the rationale. High confidence should not accompany vague reasoning.

The score is outside the 0.0-1.0 range, is an integer, or is > 0.9 while the [RATIONALE] contains hedging language like 'might' or 'possibly'.

Schema check: type is float and 0.0 <= value <= 1.0. Semantic check: if score > 0.9, use a regex to assert the [RATIONALE] does not contain 'might', 'possibly', or 'unclear'.

Policy Constraint Adherence

The [POLICY_CONSTRAINTS_APPLIED] field lists all relevant constraints from [POLICY_CONTEXT] that affected the decision, or is explicitly set to an empty array if none applied.

A constraint present in [POLICY_CONTEXT] that should have blocked the chosen tool is missing from the log, or a non-existent constraint is hallucinated.

Diff the set of constraint IDs in [POLICY_CONTEXT] against those referenced in [POLICY_CONSTRAINTS_APPLIED]. Flag any missing required constraints or any IDs not found in the source policy.

Schema Compliance

The output is valid JSON that strictly matches the [OUTPUT_SCHEMA]. All required fields are present and no extra top-level keys exist.

The output fails JSON parsing, a required field like [TOOL_NAME] or [TIMESTAMP] is missing, or a field has an incorrect type (e.g., string instead of array).

Automated validation: jsonschema.validate(output, expected_schema). The test must pass with zero errors before any other evaluation runs.

Traceability

The [DECISION_TRACE_ID] and [PARENT_SPAN_ID] are present and in valid UUID v4 format, linking this decision to the broader agent trace.

IDs are missing, are empty strings, or are not valid UUIDs, breaking the causal chain in the observability system.

Regex check for UUID v4 format on both fields. Integration test: query the trace database with the [DECISION_TRACE_ID] and assert a parent span with [PARENT_SPAN_ID] exists.

Hallucination Check

The chosen [TOOL_NAME] and its described function in the [RATIONALE] exactly match an entry in the provided [TOOL_SCHEMA].

The [TOOL_NAME] is not in the [TOOL_SCHEMA], or the [RATIONALE] describes an argument or capability that does not exist in the tool's definition.

Exact string match for [TOOL_NAME] against the keys in [TOOL_SCHEMA]. For the rationale, use an NLI model to check if the described capability is entailed by the tool's description in the schema.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single model call and no persistence. Replace the structured output schema with a simpler markdown table or bullet list. Skip cryptographic hashing and chain-of-custody fields. Focus on getting the reasoning, alternatives, and confidence fields working before adding audit infrastructure.

code
Generate a decision log entry explaining why you chose [TOOL_NAME] for [TASK].
Include: reasoning, alternatives considered, confidence (low/medium/high), and any policy constraints that applied.

Watch for

  • Missing rationale fields when the agent skips alternatives
  • Overly verbose reasoning that buries the decision
  • Confidence scores that don't match the reasoning text
  • No distinction between "no alternatives considered" and "alternatives omitted"
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.