# EffectProof Guard — Retry, Check or Stop (`travelmonitorlab/effectproof-guard`) Actor

Prevent duplicate agent actions after timeouts with evidence-bound RETRY, CHECK or STOP decisions.

- **URL**: https://apify.com/travelmonitorlab/effectproof-guard.md
- **Developed by:** [Travel Monitor Lab](https://apify.com/travelmonitorlab) (community)
- **Categories:** Developer tools, AI
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$10.00 / 1,000 recovery decisions

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## EffectProof Guard — Retry, Check or Stop

EffectProof Guard helps an AI agent avoid repeating a payment, booking, email or other tool action when the API response is lost.

Give it two objects: the tool's scoped recovery evidence and the result actually observed. It returns one decision:

- `RETRY`: one same-payload replay is justified by scoped evidence.
- `CHECK`: reconcile the original operation before any replay.
- `STOP`: do not repeat the action automatically.

The Actor never invokes the target tool. It is a deterministic decision function, not an agent, proxy, payment service or global exactly-once system.

### Quick example

A payment request timed out after dispatch. Same-key deduplication is only declared, but a status query was verified in the payment sandbox.

Input:

```json
{
  "tool": {
    "name": "charge-card",
    "capabilities": {
      "outcomeQuery": {"status": "verified", "scope": "payment-sandbox-v1"},
      "sameKeyDeduplication": {"status": "declared"}
    }
  },
  "result": {
    "outcome": "timeout",
    "dispatched": true,
    "operationKey": "order-42",
    "observedStatus": "unknown",
    "lateCommitPossible": true
  }
}
```

Output decision: `CHECK`, reason code `CHECK_OUTCOME_FIRST`. The next action is to query the original payment before any retry.

### When is RETRY allowed?

Only in these cases:

1. Transport evidence establishes `not_dispatched`.
2. Read-only behavior is `verified` with a named scope.
3. Same-key deduplication is `verified` with a named scope and the original operation key is supplied. The same payload is mandatory.

A declaration such as `idempotent: true`, an observed success, or an unscoped `verified` label is not enough. A `not_found` result never unlocks automatic replay in this MVP, even when `lateCommitPossible` is set to false: settlement itself must first be established through a trusted recovery flow.

### Why can CHECK be the safe answer?

After dispatch, a timeout leaves two possibilities: the action happened, or it did not. A verified outcome query can resolve that ambiguity without causing a second effect. If the query says `not_found` but a late commit remains possible, EffectProof still refuses to treat absence as proven.

### Output fields

Each dataset item and the `DECISION` key-value record contains:

- `decision`: `RETRY`, `CHECK` or `STOP`;
- `reasonCode`: stable machine-readable explanation;
- `reason` and `nextAction`: short operational guidance;
- `retry`: null, or the same-payload and original-key constraints with one automatic attempt;
- `evidence`: SHA-256 of the canonical input, capability proof statuses and the claim boundary.

Malformed input returns `STOP` with `INVALID_INPUT`; it does not crash the run or produce a permissive fallback.

### Local use

```bash
python3 src/main.py --input examples/timeout-check.json --output demo-output
python3 src/main.py --input examples/dedup-retry.json --output demo-output
python3 src/main.py --input examples/unknown-stop.json --output demo-output
python3 -m unittest discover -s tests -v
```

### API, MCP and agent use

Use this tool when an AI agent or automation has sent a tool/API action and the response was lost, timed out, or otherwise left the result ambiguous. Supply only the evidence you actually have; do not upgrade a vendor's idempotency claim to `verified` without a scoped test.

The Actor runs as a standard batch Actor through the Apify API and can be called by MCP clients through Apify's Actor tools. It has limited permissions, no standby server and no third-party credentials. With pay-per-event pricing and limited permissions, it is designed for Apify's x402/AGI payment flow.

### Pricing and dry runs

- `recovery-decision`: 0.01 USD per valid, non-dry-run decision.
- `dryRun: true`: the same deterministic decision, without the recovery-decision event charge.
- Invalid inputs return `STOP / INVALID_INPUT` without the recovery-decision event charge.
- Apify platform usage may apply separately according to the caller's plan. Apify retains its marketplace commission.

### Claim boundary

This MVP does not contact live tools, validate third-party evidence, observe production state or guarantee exactly-once execution. Its output is advisory and is only as strong as the scoped evidence supplied. The caller remains responsible for enforcing the original operation key and identical payload.

### Publication status

Published as the simple EffectProof Guard Actor. The advanced recovery-contract compiler remains a separate research prototype and is not included in this Actor.

# Actor input Schema

## `dryRun` (type: `boolean`):

Compute the same decision without charging the recovery-decision event. Enabled in the prefilled QA example.

## `tool` (type: `object`):

The invoked tool and the scoped evidence about its recovery capabilities. Declarations alone never authorize a retry.

## `result` (type: `object`):

What the caller actually observed. A timeout after dispatch is not proof of failure.

## Actor input object example

```json
{
  "dryRun": true
}
```

# Actor output Schema

## `decision` (type: `string`):

No description

## `dataset` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "dryRun": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("travelmonitorlab/effectproof-guard").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "dryRun": True }

# Run the Actor and wait for it to finish
run = client.actor("travelmonitorlab/effectproof-guard").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "dryRun": true
}' |
apify call travelmonitorlab/effectproof-guard --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,travelmonitorlab/effectproof-guard"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/mBArWiazSOWbW7I5M/builds/jUtgVrfdfgsBQojU3/openapi.json
