Prompt Details
Model
Chat - (gpt-5.6)
Token size
3,282
Example input
[Describe the AI agent workflow, nodes, triggers, branches and execution sequence]: An AI sales agent receives a new B2B lead, enriches the company, scores the lead, drafts a personalized outreach message, checks compliance, sends the message, and records the activity in the CRM.
[Describe AI agents, models, prompts, memory, reasoning steps and model alternatives]: Primary model: advanced reasoning model for lead analysis and personalization. Fallback model: lightweight model for message rewriting. Lead score combines firmographic data, engagement signals, and qualification rules.
[List known or suspected failures such as API errors, timeouts, invalid outputs, missing data or tool failures]: Enrichment provider returns partial company data Email verification returns an uncertain result Lead score conflicts with qualification rules Personalization contains unsupported claims Email provider accepts request but delivery status is unknown CRM update fails after email is sent
[Describe available human reviewers, approval rules, support process and escalation constraints]: Sales operations can review ambiguous leads and approve sensitive enterprise outreach. Review queue is available during business hours.
[Retry limits, latency targets, token/API budget, rate limits, security requirements and other constraints]: Maximum 2 enrichment attempts Maximum 1 email-send attempt Email sending requires an idempotency key No outreach when email validity is uncertain Maximum automated fallback depth: 2 Enterprise leads require additional verification
Example output
PHASE 1 β WORKFLOW FAILURE-SURFACE RECONSTRUCTION
Workflow
Customer request
β Extract order/refund information
β Retrieve order
β Retrieve refund policy
β AI eligibility decision
β Calculate refund amount
β Validate amount
β Human approval if required
β Submit refund
β Verify refund status
β Send confirmation
Failure surfaces
Stage Expected Behavior Failure Downstream Impact Recovery
Input Valid order/request Missing order ID Cannot identify transaction Request information
Agent Correct intent extraction Wrong intent Wrong workflow branch Re-evaluate
Order API Current order Timeout Missing transaction state Retry
Policy DB Current policy Unavailable Eligibility uncertain Retry/alternate source
Model Correct decision Invalid output Unsafe refund Validate/re-run
Amount Correct calculation Wrong amount Financial loss Reject/repair
Approval Authorized decision Approval timeout Workflow blocked Queue
Refund API Refund submitted 5xx/timeout Unknown financial state Verify before retry
Email API Confirmation sent Failure Customer not notified Retry separately
Final state Refund verified Unknown status Duplicate refund risk Stop and reconcile
---
π¨ PHASE 2 β FAILURE TAXONOMY
Confirmed test failures
Order lookup timeout β Transient
Payment API 5xx β Likely transient
Payment timeout after submission β Unknown state
Invalid refund amount β Validation/business-risk failure
Missing order ID β Input failure
Duplicate refund request β Business/idempotency failure
Important distinction
A payment timeout must not automatically be treated as "refund failed."
The system must first determine:
Did the payment provider receive and process the refund?
That state check prevents accidental double refunds.
---
π PHASE 3 β RETRYABILITY ANALYSIS
Failure Classification Retry Rule
Order timeout π’ Retryable Yes Max 2 + backoff
Order 5xx π’ Retryable Yes Max 2
Order 401 π΄ Non-retryable No Authentication escalation
Refund API 5xx before submission π‘ Conditional Yes Verify request state
Refund timeout after submission π‘ Conditional Not immediately Check refund status first
Invalid refund amount π΄ Non-retryable No Validate/recalculate
Missing order ID π΄ Non-retryable No Ask customer
Duplicate request π΄ Non-retryable No Check existing refund
Email timeout π’ Retryable Yes Separate from refund state
Retry policy
Transient read
Attempt 1
β
Exponential backoff
β
Attempt 2
β
Failure
β
Alternate source / queue / escalate
Critical rule
The refund submission uses:
Idempotency Key = customer request ID + order ID + refund intent
Therefore, the same logical refund cannot accidentally become multiple refunds.
---
π PHASE 4 β ALTERNATE TOOL STRATEGY
Primary: Order Database
Failure:
Timeout / temporary 5xx
Fallback:
Order-service read replica/cache
Conditions:
Data must be recent enough
Order status must be marked as authoritative/read-safe
Refund history must be available
Staleness must be checked
If cached data is stale:
Do not authorize refund automatically.
Escalate or queue.
Payment gateway
Do not blindly switch to another payment provider.
A second gateway cannot necessarily determine the state of the first refund.
Correct fallback:
Payment gateway status endpoint β internal reconciliation record β human review
rather than:
Gateway A failure β Gateway B refund
---
π€ PHASE 5 β ALTERNATE MODEL STRATEGY
Primary model
Used for:
Intent detection
Eligibility reasoning
Refund explanation
Fallback model
Used only when:
Primary model times out
Structured output repeatedly fails
Primary model service is unavailable
Model fallback flow
Primary Model
β
Schema validation
β
Invalid?
β
Retry structured generation once
β
Still invalid?
β
Fallback Model
β
Schema validation
β
Policy validation
β
Continue / Human
Important safeguard
The fallback model cannot independently authorize a high-value refund.
For refunds above $500:
Model decision
β Policy validation
β Human approval
β Refund
---
π₯ PHASE 6 β MISSING & INVALID DATA RECOVERY
Missing order ID
Order ID missing
β
Search conversation for identifiable order reference
β
If exactly one match β continue
β
If multiple matches β ask customer
β
No match β human/support queue
Invalid refund amount
Suppose model outputs:
refund_amount = $850
but order total is $500.
System response:
Schema validation
β
Business-rule validation
β
$850 > refundable amount
β
Reject model output
β
Recalculate from trusted order data
β
If still ambiguous β human
The system must never accept the model's amount simply because it is syntactically valid.
---
π§ PHASE 7 β LOW-CONFIDENCE DECISION STRATEGY
Confidence cannot rely only on model self-reporting.
Use evidence-based signals:
Order found
Payment status verified
Refund history verified
Policy matched
Amount mathematically valid
No previous refund
Customer request unambiguous
Decision policy
High confidence
All required evidence agrees.
β Automatic processing if under $500.
Medium confidence
One non-critical uncertainty.
β Secondary validation.
Low confidence
Conflicting order/payment/policy evidence.
β Human review.
---
π PHASE 8 β SAFETY & SIDE-EFFECT ANALYSIS
The refund API is the highest-risk operation.
Before refund
Require:
Valid order
Valid payment
Refund eligibility
Correct amount
No duplicate refund
Idempotency key
Approval if >$500
After refund submission
Never assume success from HTTP timeout.
Perform:
Submit
β
Unknown response?
β
Query refund status
β
Confirmed refunded β continue
β
Confirmed failed β eligible for retry
β
Unknown β queue/reconcile
Email failure
Email failure should not trigger another refund.
Refund state and notification state must be independent.
---
π³ PHASE 9 β FALLBACK DECISION TREE
FAILURE
β
Classify failure
β
Is it transient?
ββ NO β Validate alternate recovery
ββ YES
β
Is retry safe?
ββ NO β Verify state / escalate
ββ YES
β
Retry budget available?
ββ YES β Retry with backoff
ββ NO β Alternate path
β
Alternate tool/model?
ββ YES β Validate output
ββ NO
β
Missing data?
ββ YES β Request data
ββ NO
β
High-impact action?
ββ YES β Human / safe stop
ββ NO β Queue or graceful degradation
---
π PHASE 10 β RECOVERY WORKFLOW DESIGN
Scenario A: Order API Timeout
Timeout
β
Preserve workflow state
β
Retry #1
β
Backoff
β
Retry #2
β
Still unavailable?
β
Read replica/cache
β
Validate freshness
β
Continue OR queue
Termination: Maximum 2 retries + one alternate read source.
---
Scenario B: Refund API Timeout
Refund timeout
β
DO NOT retry immediately
β
Check idempotency key
β
Query refund status
β
Refund exists?
ββ YES β Mark successful
ββ NO β Retry once
ββ UNKNOWN β Queue reconciliation
This is the most important recovery path in the test.
---
Scenario C: Invalid Model Amount
Invalid amount
β
Reject output
β
Recalculate from trusted data
β
Policy validation
β
Valid?
ββ YES β Continue
ββ NO β Human review
---
π§ PHASE 11 β STATE & CONTEXT RECOVERY
Persist:
request_id
order_id
customer_id
workflow_id
current_step
model_decision
refund_amount
policy_version
retry_count
idempotency_key
payment_status
refund_status
failure_type
failure_timestamp
human_review_status
State machine
RECEIVED
β
VALIDATED
β
ELIGIBILITY_CHECKED
β
APPROVAL_PENDING
β
REFUND_SUBMITTED
β
REFUND_VERIFIED
β
CUSTOMER_NOTIFIED
Failure states:
RETRY_PENDING
RECONCILIATION_PENDING
HUMAN_REVIEW
QUEUED
FAILED_SAFE
This prevents the workflow from restarting from the beginning and accidentally creating another refund.
---
π€ PHASE 12 β HUMAN ESCALATION ARCHITECTURE
Escalate when:
Refund > $500
Payment state is unknown
Conflicting order information
Refund history conflicts
Policy cannot be determined
Idempotency state is uncertain
Multiple automated recovery attempts fail
Reviewer receives
Customer request
Order details
Payment status
Refund history
Requested amount
Calculated amount
Policy rule
Model decision
Failure reason
Retry history
API responses
Recommended action
Human outcomes
1. Approve
2. Reject
3. Request additional information
4. Send to finance reconciliation
Approval timeout
Do not automatically approve.
Move to:
Approval Pending β Queue
---
π PHASE 13 β FAILURE RISK MATRIX
Failure Probability Impact Recoverability Severity Recovery
Order timeout Medium Medium High Medium Retry
Order 5xx Low-Medium Medium High Medium Retry
Payment 5xx Medium High Medium High Verify + controlled retry
Payment timeout after submission Medium Critical Medium Critical Reconcile
Invalid model amount Medium Critical High Critical Reject + recalculate
Missing order ID Medium Low High Low Request data
Duplicate refund Low Critical Medium Critical Idempotency + reconciliation
Email failure Medium Low High Low Retry notification
Approval timeout Medium Medium High Medium Queue
Priority order
1. Payment/refund unknown state
2. Duplicate refund prevention
3. Invalid refund amount
4. Payment API failures
5. Order retrieval
6. Human approval
7. Customer notification
---
π§ͺ PHASE 14 β RECOVERY TESTING SCENARIOS
Test 1: API Timeout
Initial condition: Valid order.
Failure injected: Order API times out.
Expected fallback: Retry twice with exponential backoff.
Expected state: RETRY_PENDING β successful order retrieval.
Pass criteria: No duplicate workflow execution.
Recovery failure: Use validated read replica/cache or queue.
---
Test 2: Payment 5xx
Initial condition: Refund eligible.
Failure injected: Payment API returns HTTP 500 before confirmation.
Expected fallback: Check refund status/idempotency state.
Pass criteria: System does not create duplicate refund.
Recovery failure: Queue reconciliation.
---
Test 3: Payment Timeout After Submission
Initial condition: Refund request accepted by gateway but response is lost.
Failure injected: Client receives timeout.
Expected fallback: Query refund status.
Expected output: Refund marked successful if provider confirms it.
Pass criteria: No second refund is submitted.
---
Test 4: Invalid Structured Output
Failure injected:
refund_amount: "five hundred dollars"
instead of numeric amount.
Expected fallback:
Schema validation β structured regeneration β fallback model if necessary.
Pass criteria: No refund occurs until amount is validated.
---
Test 5: Missing Data
Failure injected: No order ID.
Expected fallback: Extract from conversation.
If unresolved: Ask customer.
Pass criteria: No refund API call is made.
---
Test 6: Conflicting Data
Failure injected:
Order DB says $400 refundable.
Payment record says $250.
Expected fallback:
Stop automatic refund β reconciliation/human review.
Pass criteria: No financial side effect occurs.
---
Test 7: Duplicate Execution
Failure injected: Same request is delivered twice.
Expected fallback: Detect request/idempotency key.
Expected result: Only one refund.
Pass criteria: Exactly one financial transaction.
---
Test 8: Human Escalation
Failure injected: Refund amount = $700.
Expected fallback: Human approval.
Pass criteria: Refund cannot execute before approval.
---
Test 9: Multiple Consecutive Failures
Order API timeout
β
Retry #1 fails
β
Retry #2 fails
β
Replica unavailable
Expected result:
Queue request.
Pass criteria: No infinite retry loop.
---
π οΈ PHASE 15 β RESILIENCE OPTIMIZATION
Recommended controls
1. Retry budget
Separate budgets by operation.
Read operation: 2 retries
Model generation: 1 retry
Refund submission: 1 controlled retry
Email: 2 retries
2. Circuit breaker
If payment gateway repeatedly returns 5xx:
Normal
β
Failures exceed threshold
β
Circuit OPEN
β
Stop new automatic refund submissions
β
Periodic health check
β
Recovery
3. Dead-letter queue
Requests that cannot safely recover should enter:
REFUND_RECONCILIATION_QUEUE
rather than repeatedly executing.
4. Fallback loop prevention
Never allow:
Tool A
β Tool B
β Tool A
β Tool B
Set a maximum fallback depth.
5. Observability
Log:
Correlation ID
Failure category
Retry count
Tool selected
Model selected
Recovery path
Final outcome
Human decision
Latency
Cost
---
π PHASE 16 β FINAL FALLBACK STRATEGY BLUEPRINT
1. π― Executive Recovery Summary
The safest architecture is state-aware recovery, not generic retry logic.
The most important rule is:
Never retry a financial side effect until its previous execution state has been determined.
---
2. π§ Workflow Failure Map
Customer
β
Input Validation
β
Order Retrieval
β
Policy Retrieval
β
AI Decision
β
Amount Validation
β
Human Approval if required
β
Refund API
β
Refund Verification
β
Email
---
3. π¨ Failure Taxonomy
Primary categories:
Transient infrastructure failure
Authentication/authorization failure
Rate limiting
Data failure
Model failure
Validation failure
Business-rule failure
Unknown side-effect state
Human approval failure
---
4. π Retry Decision Matrix
Retry: transient, idempotent, bounded.
Do not retry: invalid business data, authorization failure, conflicting records.
Conditional retry: financial side effects where execution state has been verified.
---
5. π Alternate Tool Strategy
Use an alternate read source when safe.
Do not substitute another payment gateway for an unknown state from the original gateway.
---
6. π€ Alternate Model Strategy
Primary
β Schema validation
β One controlled regeneration
β Fallback model
β Policy validation
β Continue / Human
---
7. π₯ Missing/Invalid Data Recovery
Never fabricate.
Missing
β Retrieve
β Ask user
β Alternate trusted source
β Human
β Stop
---
8. π§ Low-Confidence Policy
Strong evidence
β Automate
Partial evidence
β Secondary validation
Conflicting/weak evidence
β Human or safe stop
---
9. π Side-Effect Safety Rules
Every refund requires:
Idempotency
Eligibility validation
Amount validation
Duplicate detection
Post-action verification
Human approval above threshold
---
10. π³ Fallback Decision Tree
Failure
β
Classify
β
Check state
β
Check retry safety
β
Retry if safe
β
Alternate source/model if appropriate
β
Validate
β
Human if high impact or ambiguous
β
Queue if temporarily unrecoverable
β
Safe stop if unsafe
---
11. π Recovery Workflow Blueprint
FAILURE
β
CLASSIFY
β
PRESERVE STATE
β
CHECK SIDE-EFFECT STATE
β
SELECT RECOVERY
β
EXECUTE
β
VERIFY
β
CONTINUE
OR
RETRY
OR
ESCALATE
OR
QUEUE
OR
STOP
---
12. π§ State & Context Recovery Plan
The workflow must persist:
Request ID + order ID + current state + retry count + idempotency key + tool results + failure reason + approval state + refund state.
---
13. π€ Human Escalation Policy
Human review is mandatory for:
Refunds > $500
Conflicting financial records
Unknown refund state
Failed reconciliation
Policy ambiguity
Repeated recovery failure
---
14. π Failure Risk Matrix
Critical risks:
1. Duplicate refund
2. Unknown refund state
3. Incorrect refund amount
4. Conflicting payment/order data
These receive the strongest safeguards.
---
15. π§ͺ Recovery Testing
Minimum production-readiness test suite:
Timeout
5xx
Rate limit
Invalid schema
Missing data
Conflicting data
Duplicate execution
Unknown side-effect state
Human escalation
Multiple consecutive failures
---
16. π Final Resilience Roadmap
Priority 1 β Financial Safety
Implement idempotency, duplicate detection, post-refund verification, and reconciliation.
Priority 2 β Recovery Control
Implement bounded retries, exponential backoff, circuit breakers, and dead-letter queues.
Priority 3 β AI Reliability
Implement schema validation, deterministic business-rule validation, and controlled model fallback.
Priority 4 β Human Operations
Create evidence-rich escalation packets and bounded approval workflows.
Priority 5 β Observability
Track every failure, recovery decision, retry, fallback, escalation, and final outcome.
Final architecture:
FAILURE
β
CLASSIFY
β
VALIDATE STATE
β
SAFE RETRY?
ββ YES β BOUNDED RETRY β VERIFY
ββ NO
β
ALTERNATE RECOVERY?
β
VALIDATE
β
HIGH-IMPACT / AMBIGUOUS?
ββ YES β HUMAN / QUEUE
ββ NO β CONTINUE
β
VERIFY FINAL STATE
β
AUDIT + COMPLETE
Overall resilience verdict: HIGH, provided the payment/refund path implements idempotency, state reconciliation, bounded retries, and mandatory verification.
By purchasing this prompt, you agree to our terms of service
GPT-5.6
This prompt designs intelligent fallback rules, recovery paths, escalation policies, and testing scen
π¨ Map every critical agent failure point
π Decide retry vs alternate tool vs alternate model
π§ Define low-confidence recovery rules
π€ Design human-escalation paths
π³ Build a clear fallback decision tree
π§ͺ Generate failure & recovery test scenarios
π‘οΈ Improve workflow reliability and resilience
Stop treating every AI failure the sameβdesign the right recovery strategy for every failure. π
...more
Added 2 days ago
