Validate agent handoff packets and resume readiness using schema, freshness, and replay checks. Use when tasks pause/resume across sessions, agents, or humans — including when a user wants to continue where they left off, hand off to another agent, resume a previous task, or pick up an interrupted workflow. Includes explicit untrusted-content/prompt-injection guardrails for third-party inputs.
96
Quality
100%
Does it follow best practices?
Impact
96%
1.50xAverage score across 9 eval scenarios
Ensure handoffs are recoverable, not just present.
Valid example:
{
"objective": "Migrate user database to new schema",
"completed": ["audit existing schema", "draft migration script"],
"unresolved": ["confirm rollback strategy with DBA"],
"assumptions": ["downtime window approved for Saturday 02:00–04:00 UTC"],
"next_action": "Review migration script with DBA before Saturday",
"risks": ["data loss if rollback untested"],
"updated_at": "2024-06-10T14:32:00Z",
"resume_token": "sess_abc123_mig_v2"
}Invalid example (missing fields, stale timestamp):
{
"objective": "Migrate user database to new schema",
"completed": [],
"unresolved": [],
"assumptions": [],
"next_action": "",
"risks": [],
"updated_at": "2024-01-01T00:00:00Z",
"resume_token": ""
}Issues: next_action is empty, resume_token is empty, updated_at is stale (>48 h old).
from datetime import datetime, timezone, timedelta
import re
MAX_STALENESS_HOURS = 48
updated_at = datetime.fromisoformat(packet["updated_at"].replace("Z", "+00:00"))
age_hours = (datetime.now(timezone.utc) - updated_at).total_seconds() / 3600
freshness_ok = age_hours <= MAX_STALENESS_HOURSresume_token format/consistency — executable Python:
TOKEN_PATTERN = re.compile(r'^[a-zA-Z0-9_\-]{8,128}$')
token_ok = (
bool(TOKEN_PATTERN.match(packet["resume_token"]))
and packet["resume_token"] not in consumed_tokens
)Example output:
Check Summary:
✅ Schema: all required fields present and non-empty
✅ Freshness: updated 2 h ago (within 48 h limit)
✅ Resume token: sess_abc123_mig_v2 — valid format, not previously consumed
✅ Replay test: objective, blocker, and next action confirmed
Classification: CLEAN
Recovery Steps: None required.
Escalation: No escalation needed. Safe to resume.Check Summary:
✅ Schema: all required fields present and non-empty
❌ Freshness: updated 73 h ago (exceeds 48 h limit)
❌ Resume token: empty — fails format check
❌ Replay test: next_action could not be confirmed
Classification: OPERATIONAL
Recovery Steps:
1. Re-confirm current objective and next action with task owner.
2. Generate a new resume_token before proceeding.
3. Update updated_at to reflect the refreshed handoff state.
Escalation: Notify task owner to re-validate handoff before resuming.