Inferensys

Prompt

Agent Task Phase Monitoring Prompt

A practical prompt playbook for monitoring autonomous agent progress through multi-step plans, detecting phase transitions, and flagging when replanning is required.
Developer reviewing multi-agent chat interface on laptop, agent conversation logs visible, casual coding session at WeWork desk.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, ideal user, required context, and boundaries for the Agent Task Phase Monitoring Prompt.

This prompt is designed for a specific architectural role: an external observer that validates an autonomous agent's self-reported progress against its actual behavior trace. The core job-to-be-done is to detect phase drift—situations where an agent's internal state claims it is on step three, but its recent actions and observations suggest it is stuck on step two, has skipped ahead, or has silently entered an error-recovery loop. The ideal user is an AI engineer or platform developer building a multi-agent system who needs a separate, non-planning monitoring step to trigger replanning, human escalation, or state correction. You must provide the declared plan, the agent's recent action-observation history, and the agent's self-reported current phase. Without all three inputs, the prompt cannot perform its comparative function.

Use this prompt when you have already instrumented your agent to log its tool calls, environmental observations, and internal state updates. The prompt acts as a phase auditor, not a planner. It assumes the plan exists and is well-formed. It does not decide what the agent should do next; it only produces a structured assessment of where the agent actually is relative to the plan. This is critical for systems where agents can hallucinate progress, such as when a web navigation agent reports a form submission as complete despite a CAPTCHA blocking the action. The prompt's output—a phase label, completed milestones, blocked status, and a replanning signal—should be consumed by an orchestrator or a supervisor agent, not shown directly to end users.

Do not use this prompt as a replacement for deterministic state machines when the plan is linear and the environment is fully observable. If your agent's task is a simple sequence of API calls with clear success/failure responses, a code-based state tracker is cheaper, faster, and more reliable. This prompt is valuable when the environment is messy: web pages that change structure, API responses that require interpretation, or multi-step reasoning where success is ambiguous. Also avoid using this prompt in latency-sensitive inner loops. Phase monitoring is a periodic audit, not a per-step check. Run it every N steps, on detected anomalies, or when the agent's self-reported confidence drops below a threshold. The prompt's value is in catching systemic drift, not micro-optimizing step-by-step execution.

Before integrating this prompt, ensure you have a ground-truth mechanism to validate its assessments. The prompt can be wrong—it can misclassify a legitimate workaround as off-plan behavior or miss a subtle phase transition. Implement eval harnesses that compare the prompt's phase detection against human-annotated agent traces. Track false positive replanning triggers (which waste compute and annoy users) and false negatives (which allow agents to continue down broken paths). In high-stakes domains like financial transactions or healthcare actions, always route the prompt's replanning signal through a human approval step before the agent's plan is actually modified.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Agent Task Phase Monitoring Prompt works, where it fails, and what you must have in place before deploying it.

01

Good Fit: Autonomous Multi-Step Agents

Use when: Your agent executes a known plan with discrete, observable steps (e.g., code generation, file editing, data pipeline runs). The prompt reliably tracks progress against a ground-truth plan. Guardrail: Provide the full plan as structured input; do not ask the model to infer the plan from scratch.

02

Bad Fit: Open-Ended Creative Exploration

Avoid when: The agent's task has no predefined sequence or success criteria (e.g., brainstorming, free-form research). Phase detection will hallucinate structure where none exists. Guardrail: Use a task-type classifier upstream to bypass phase monitoring for unstructured work.

03

Required Input: Ground-Truth Plan

What to watch: Without an explicit plan with step IDs and expected outcomes, the prompt cannot produce a reliable phase assessment. Guardrail: Always pass a machine-readable plan schema. Validate that every phase label in the output maps to a known plan step.

04

Operational Risk: Stale Phase Assessments

What to watch: The model may report a phase as 'in progress' long after the agent has diverged or stalled. This creates a false sense of progress. Guardrail: Pair this prompt with a watchdog timer. If the phase hasn't changed after N tool calls, force a replanning evaluation.

05

Operational Risk: Plan-Observation Mismatch

What to watch: The agent's actual tool outputs may contradict the predicted next step, but the phase monitor fails to detect the divergence. Guardrail: Feed the last K tool call results directly into the phase monitoring prompt. Require the output to cite specific observations as evidence for the current phase.

06

Bad Fit: High-Frequency Real-Time Control

Avoid when: You need sub-second, per-action state tracking in a tight control loop. An LLM call for every phase check adds unacceptable latency and cost. Guardrail: Use deterministic state machines for high-frequency tracking. Reserve this prompt for periodic, asynchronous progress summaries and anomaly detection.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

Paste this prompt into your monitoring harness to track an agent's progress through a multi-step plan, detect stalls, and trigger replanning.

This template is designed to be invoked at each agent reasoning step or after every tool-call cycle. It compares the agent's current trajectory against the ground-truth execution plan to produce a structured phase assessment. Replace every square-bracket placeholder with live data from your agent's execution context before sending the request to the model.

text
You are an agent task phase monitor. Your job is to compare the agent's current execution state against the original plan and produce a structured phase assessment.

## PLAN
[PLAN]

## COMPLETED MILESTONES
[COMPLETED_MILESTONES]

## AGENT'S LAST ACTION
[LAST_ACTION]

## AGENT'S LAST OBSERVATION
[LAST_OBSERVATION]

## TOOL CALL HISTORY (last 5 calls)
[TOOL_CALL_HISTORY]

## CONSTRAINTS
- Do not hallucinate progress. Only mark a milestone as complete if there is explicit evidence in the observation or tool call history.
- If the agent has repeated the same failing action 3 or more times without progress, flag it as BLOCKED.
- If the agent's last action is unrelated to the current expected phase, flag a possible DIVERGENCE.

## OUTPUT SCHEMA
Return a single JSON object with the following fields:
{
  "current_phase": "string (the name of the current phase from the plan)",
  "phase_status": "IN_PROGRESS | COMPLETED | BLOCKED | NOT_STARTED",
  "completed_milestones": ["string"],
  "next_milestone": "string",
  "is_stalled": true | false,
  "stall_reason": "string or null",
  "is_diverged_from_plan": true | false,
  "divergence_detail": "string or null",
  "replanning_recommended": true | false,
  "replanning_reason": "string or null",
  "assessment_confidence": 0.0-1.0
}

To adapt this template, start by replacing [PLAN] with the full, ordered list of phases and milestones the agent is expected to follow. Populate [COMPLETED_MILESTONES] from your execution log's verified completion records, not from the agent's self-reported claims. The [LAST_ACTION] and [LAST_OBSERVATION] fields should be the raw text of the most recent tool call and its result. If your agent uses a multi-step reasoning loop, invoke this prompt after every observation to catch stalls early. For high-stakes autonomous workflows, route any output where replanning_recommended is true to a human-in-the-loop review queue before the agent takes further action.

IMPLEMENTATION TABLE

Prompt Variables

Each placeholder must be populated before the monitoring call. Validation notes describe what breaks if the variable is malformed.

PlaceholderPurposeExampleValidation Notes

[PLAN_STEPS]

Ordered list of expected steps from the agent's execution plan

["Fetch user profile", "Query billing API", "Calculate proration", "Generate invoice"]

Must be a valid JSON array of strings. Empty array causes null phase detection. Non-array input breaks step completion tracking.

[COMPLETED_MILESTONES]

List of steps the agent has marked as done with evidence

["Fetch user profile: complete", "Query billing API: complete"]

Must be a JSON array of strings matching [PLAN_STEPS] entries. Mismatched step names cause false incomplete status. Null allowed if no steps completed.

[CURRENT_AGENT_ACTION]

The last action the agent attempted or is currently executing

"Calling billing API endpoint GET /v2/subscriptions"

Must be a non-empty string. Empty string causes phase detection to default to 'unknown'. Truncated strings over 500 chars may lose action context.

[ACTION_OUTCOME]

Result of the most recent agent action including error messages if any

"200 OK: returned 3 active subscriptions"

Must be a string. Null allowed if action is still in-flight. Unescaped JSON in string breaks downstream parsing. Include full error body for blocked status detection.

[BLOCKED_REASON]

Description of what is preventing progress, or null if unblocked

"Rate limit exceeded on billing API after 3 retries"

Null must be explicit null, not string 'null'. Non-null values trigger blocked status. Missing field when agent is actually blocked causes false progress reporting.

[REPLANNING_INDICATORS]

Signals that the original plan may need revision

["New user type discovered: enterprise", "Missing permission for invoice generation"]

Must be a JSON array of strings. Empty array means no replanning signals detected. Non-array input breaks replanning recommendation logic.

[PLAN_VERSION]

Identifier for which version of the plan is being executed

"v3"

Must be a string matching the plan versioning scheme. Version mismatch with [PLAN_STEPS] causes stale phase assessment. Required for multi-plan agent systems.

[OBSERVATION_TIMESTAMP]

ISO 8601 timestamp of when this monitoring assessment is generated

"2025-01-15T14:30:00Z"

Must be valid ISO 8601 UTC string. Missing timezone defaults to UTC but causes ambiguity. Future timestamps trigger staleness detection. Past timestamps older than 5 minutes may indicate monitoring lag.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Agent Task Phase Monitoring Prompt into a production agent loop with validation, staleness detection, and replanning triggers.

The Agent Task Phase Monitoring Prompt is designed to run as a supervisory sidecar within an agent execution loop. It should not be the agent's primary reasoning prompt. Instead, call it at defined checkpoints: after each tool call, when the agent pauses, or when a step fails. The prompt consumes the agent's current plan, completed milestones, recent observations, and the last few action-observation pairs. It returns a structured phase assessment that your harness uses to decide whether to continue, replan, or escalate.

Validation is mandatory. Parse the model's JSON output and validate it against the ground-truth plan state your agent runtime already tracks. Check that completed_milestones are a subset of the plan's defined milestones and that the current_phase label exists in your phase taxonomy. If the model claims a milestone is complete but your execution log shows the associated tool call failed, flag a phase hallucination and discard the assessment. For high-stakes workflows, route conflicting assessments to a human review queue with the agent's trace attached.

Staleness detection is the primary failure mode. An agent can drift from its plan without the phase monitor noticing. Implement a divergence check: compare the agent's last N actions against the expected actions for the reported phase. If the agent is executing tool calls unrelated to the current phase for more than two consecutive steps, mark the phase assessment as stale and force a replanning cycle. Log staleness events with the phase monitor's output, the divergent actions, and the timestamp for post-mortem analysis.

Model choice and latency budget. This prompt is a classification-plus-summary task, not a generation task. Use a fast, instruction-tuned model (e.g., GPT-4o-mini, Claude Haiku, or a fine-tuned small model) rather than a large reasoning model. The prompt should run in parallel with the agent's next action when possible, not block the main loop. Set a strict timeout (500ms–2s depending on your latency requirements) and fall back to the last known valid phase if the monitor times out. Cache the plan and phase taxonomy in the system prompt prefix to reduce per-call token costs.

Wiring the output into the agent loop. On receiving a valid phase assessment, your harness should take three actions: (1) update the agent's visible context with the current phase and blocked status, (2) if replanning_needed is true, inject a replanning instruction into the agent's next turn with the blocked_reason as context, and (3) append the assessment to the session audit log. Never silently discard a blocked status. If the phase monitor reports blocked three consecutive times without resolution, escalate to a human operator with the full plan trace and the last three assessments.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, types, and validation rules for the Agent Task Phase Monitor's JSON response. Use this contract to build a parser and validator before integrating the prompt into your agent harness.

Field or ElementType or FormatRequiredValidation Rule

current_phase

string

Must match one of the labels in [PHASE_TAXONOMY]. Reject if value is not in the allowed enum set.

phase_confidence

number

Must be a float between 0.0 and 1.0. Reject if value is outside this range or not a number. Trigger human review if below [CONFIDENCE_THRESHOLD].

completed_milestones

array of strings

Each element must be a string present in the [PLAN_MILESTONES] list. Reject if an element is not a recognized milestone. Allow empty array if no milestones are complete.

blocked_status

boolean

Must be strictly true or false. If true, the blocked_reason field must not be null.

blocked_reason

string or null

If blocked_status is true, this must be a non-empty string. If blocked_status is false, this must be null. Reject on mismatch.

replanning_needed

boolean

Must be strictly true or false. If true, the replanning_rationale field must not be null.

replanning_rationale

string or null

If replanning_needed is true, this must be a non-empty string. If false, this must be null. Reject on mismatch.

stale_assessment_flag

boolean

Must be strictly true or false. The harness should independently set this to true if the agent's last action diverges from the reported current_phase, overriding the model's output.

PRACTICAL GUARDRAILS

Common Failure Modes

Agent task phase monitoring fails silently when the model's assessment of progress diverges from the agent's actual behavior. These are the most common production failure patterns and how to prevent them.

01

Stale Phase Assessment

What to watch: The monitor reports the agent is on step 3 of 5, but the agent's actual tool calls and outputs show it has been stuck retrying step 2 for the last four turns. The phase assessment becomes a lagging indicator that masks real execution drift. Guardrail: Cross-validate phase output against the last N tool-call signatures and their outcomes. If the declared phase and observed behavior diverge for more than 2 consecutive turns, flag the assessment as stale and trigger a replanning check.

02

Overconfident Completion Signal

What to watch: The monitor declares a phase complete because the agent produced output that looks like a deliverable, but required sub-tasks such as validation, file writes, or confirmation steps were never executed. The phase monitor confuses fluent output with task completion. Guardrail: Require explicit evidence of completion from the agent's tool-call log, not just its natural-language claims. Map each milestone to one or more required tool invocations and check that they occurred before accepting a completion signal.

03

Phase Boundary Oscillation

What to watch: The monitor flips between two phases such as 'executing' and 'blocked' on consecutive turns because the underlying signal is noisy or the prompt lacks hysteresis. This causes downstream systems to trigger conflicting workflows. Guardrail: Add a stability requirement: the monitor must observe the same phase for at least 2 consecutive turns before emitting a phase transition event. Use a short rolling window of prior assessments to dampen single-turn noise.

04

Blind to Silent Failures

What to watch: The agent encounters an error such as a tool returning an empty list or a permission denial, but continues executing without surfacing the failure. The phase monitor sees continued activity and reports normal progress. Guardrail: Instrument the monitor to inspect tool-call return codes, error messages, and empty-result patterns. Add a 'blocked' or 'degraded' phase that triggers when the agent's last K tool calls all returned errors or empty results, regardless of the agent's own status reporting.

05

Replanning Reluctance

What to watch: The monitor correctly detects that the agent is stuck, but the prompt biases it toward 'continue current plan' rather than recommending replanning. The agent loops on a failing strategy while the monitor keeps reporting 'in progress.' Guardrail: Include explicit replanning triggers in the output schema such as a boolean replanning_recommended field. Calibrate the prompt with examples where replanning is the correct action even when the agent has not explicitly requested it. Test against scenarios where the plan is provably unachievable with current tools.

06

Context Window Truncation of Plan State

What to watch: In long-running agent sessions, the original plan and early milestones fall out of the context window. The monitor loses track of what was already completed and re-declares finished milestones as pending, causing the agent to repeat work. Guardrail: Maintain a structured plan-state object outside the prompt that persists across turns. Feed the monitor a compact summary of completed milestones and the current plan step rather than relying on full conversation history. Validate that the monitor's reported completed-milestone count never decreases between turns.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for evaluating the Agent Task Phase Monitoring Prompt before production deployment. Use this rubric to measure phase detection accuracy, staleness resistance, and plan alignment.

CriterionPass StandardFailure SignalTest Method

Phase Label Accuracy

Predicted phase matches ground-truth plan step for at least 90% of test traces

Phase label diverges from actual plan progress by more than one step or assigns an undefined phase

Compare predicted phase against annotated plan-step labels in a golden dataset of agent execution traces

Milestone Completion Detection

All completed milestones in the plan are correctly flagged as done; no false completions

A milestone marked complete when its preconditions are unmet, or a finished milestone remains marked incomplete

Assert milestone status against a ground-truth plan state log; check precondition satisfaction per milestone

Blocked Status Accuracy

Blocked flag is true only when a dependency is unmet or an error is unrecoverable; false otherwise

Blocked flag is false when the agent is stuck in a retry loop, or true when the agent is making progress

Inject simulated dependency failures and retry loops; verify blocked flag matches expected state within 2 turns

Replanning Signal Correctness

Replanning recommended only when the current plan is provably infeasible or goals have changed

Replanning triggered on transient errors or recoverable failures; replanning not triggered when all paths are exhausted

Run scenarios with recoverable vs. terminal errors; check replanning output against a pre-defined decision boundary

Staleness Resistance

Phase assessment updates within 1 turn when agent behavior diverges from the last reported phase

Phase assessment remains unchanged for 3+ turns while the agent is executing a different plan step

Monitor phase output across consecutive turns during a plan deviation; measure latency of phase update in turn count

Output Schema Compliance

Output is valid JSON matching the defined schema with all required fields present and correctly typed

Missing required fields, incorrect enum values, or unparseable JSON in the model response

Validate output against the JSON schema; run 100-sample schema conformance test with zero tolerance for parse errors

Confidence Calibration

Reported confidence score correlates with actual accuracy; high-confidence errors are rare

High confidence (>0.9) assigned to incorrect phase labels or blocked statuses in more than 5% of cases

Bin predictions by confidence decile; measure actual accuracy per bin; check that high-confidence bins exceed 95% accuracy

Context Window Efficiency

Prompt produces correct output without exceeding the allocated token budget for phase monitoring

Prompt output is correct but requires more than the budgeted token limit, or output is truncated

Measure token usage per invocation; assert that 99th percentile token count stays within the defined budget

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a simplified plan schema. Replace the full milestone tracking with a single current_step and blocked boolean. Skip the replanning recommendation field and focus on phase label and completion percentage. Run with a small set of annotated plan traces.

code
[AGENT_PLAN_STEPS]
[AGENT_ACTION_LOG]

Return JSON:
{
  "current_phase": "string",
  "phase_index": number,
  "completion_pct": number,
  "blocked": boolean
}

Watch for

  • Phase label drift when agent behavior doesn't match plan vocabulary
  • Overly optimistic completion percentages when steps are partially done
  • Missing blocked detection when agent retries the same action repeatedly
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.