# Retry Oracle — Deterministic Retry and Spend Decisions (`skilled_glee/retry-oracle`) Actor

Failed operation plus attempt, deadline, spend and idempotency context → RETRY, MUTATE or ABORT with reason codes, bounded delays and SHA-256 provenance. No LLM and no operation execution.

- **URL**: https://apify.com/skilled\_glee/retry-oracle.md
- **Developed by:** [Dakota Myers](https://apify.com/skilled_glee) (community)
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.00 / 1,000 useful retry 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/running/actors-in-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

## Retry Oracle

Give me a failed operation category and retry/spend context; receive RETRY, MUTATE, or ABORT with a deterministic reason code, delay, remaining budgets, policy version and input hash.

### Scope and safety

This Actor advises only. It never executes retries, sends payments, changes credentials, or collects request payloads. Submit category labels and numeric context only; never send secrets or personal data. A non-idempotent failure always returns ABORT for reconciliation, even when a mutation is allowed. Unknown failures fail closed. Recommendations do not guarantee upstream success.

`attemptNumber` is the one-based failed attempt; `maxAttempts` is the total allowed count. `deadlineSeconds` is the total duration allowed since the operation began, while `elapsedSeconds` is duration already consumed. All spending fields use the same caller-selected currency. `nextAttemptCost` is an optional cost upper bound; omitting it cannot prove affordability of an unknown future price. Supply it when the next attempt costs money.

Transient failures use deterministic exponential backoff capped at 60 seconds, honoring a longer supplied Retry-After. A delay that reaches the deadline returns ABORT. The caller must enforce budgets at actual execution time and prevent concurrent retry storms; this stateless advisor cannot coordinate independent callers. MUTATE selects one explicitly allowed option and requires reassessment, without executing it.

### Input and output

Submit 1–100 independent contexts in `items`. Fields: operationType, failureCategory, statusCode (optional), attemptNumber, maxAttempts, elapsedSeconds, deadlineSeconds, amountSpent, maxSpend, idempotent, allowedMutations; optional nextAttemptCost and retryAfterSeconds. Extra item fields are rejected. Invalid items are isolated and recorded by index in SUMMARY without echoing their data.

Dataset fields: decision, reasonCode, reason, recommendedDelaySeconds, selectedMutation, remainingAttemptBudget, remainingSpendBudget, policyVersion, inputHash, provenance, itemIndex. Identical valid context yields identical advice and hash. Hashes identify inputs; they are not encryption.

### Billing

One `decision-produced` event only after each valid decision is saved. ABORT is a useful decision and is billable; invalid contexts are not charged. Platform costs are included. No automatic startup or dataset-item charge. Processing stops at the user spending limit.

Current price: USD $0.002 per useful decision saved. Platform costs are included.

# Actor input Schema

## `items` (type: `array`):

One to 100 contexts, without secrets or operation payloads.

## Actor input object example

```json
{
  "items": [
    {
      "operationType": "http_get",
      "failureCategory": "rate_limit",
      "statusCode": 429,
      "attemptNumber": 1,
      "maxAttempts": 4,
      "elapsedSeconds": 2,
      "deadlineSeconds": 120,
      "amountSpent": 0.01,
      "maxSpend": 0.1,
      "idempotent": true,
      "allowedMutations": [],
      "nextAttemptCost": 0.01,
      "retryAfterSeconds": 5
    }
  ]
}
```

# Actor output Schema

## `decisions` (type: `string`):

No description

## `summary` (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 = {
    "items": [
        {
            "operationType": "http_get",
            "failureCategory": "rate_limit",
            "statusCode": 429,
            "attemptNumber": 1,
            "maxAttempts": 4,
            "elapsedSeconds": 2,
            "deadlineSeconds": 120,
            "amountSpent": 0.01,
            "maxSpend": 0.1,
            "idempotent": true,
            "allowedMutations": [],
            "nextAttemptCost": 0.01,
            "retryAfterSeconds": 5
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("skilled_glee/retry-oracle").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 = { "items": [{
            "operationType": "http_get",
            "failureCategory": "rate_limit",
            "statusCode": 429,
            "attemptNumber": 1,
            "maxAttempts": 4,
            "elapsedSeconds": 2,
            "deadlineSeconds": 120,
            "amountSpent": 0.01,
            "maxSpend": 0.1,
            "idempotent": True,
            "allowedMutations": [],
            "nextAttemptCost": 0.01,
            "retryAfterSeconds": 5,
        }] }

# Run the Actor and wait for it to finish
run = client.actor("skilled_glee/retry-oracle").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 '{
  "items": [
    {
      "operationType": "http_get",
      "failureCategory": "rate_limit",
      "statusCode": 429,
      "attemptNumber": 1,
      "maxAttempts": 4,
      "elapsedSeconds": 2,
      "deadlineSeconds": 120,
      "amountSpent": 0.01,
      "maxSpend": 0.1,
      "idempotent": true,
      "allowedMutations": [],
      "nextAttemptCost": 0.01,
      "retryAfterSeconds": 5
    }
  ]
}' |
apify call skilled_glee/retry-oracle --silent --output-dataset

```

## MCP server setup

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

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/S3AmDbcvuoIrlm2ZJ/builds/Lqe5uyPpLTtdwcn9f/openapi.json
