Back to Blog

Fable 5.2 vs Astra: Can Retries Run a Tool Twice?

Tutorials and Guides2675
Fable 5.2 vs Astra: Can Retries Run a Tool Twice?

A customer-support agent adds a note to a ticket. The ticket system accepts it, but the agent's connection closes before the result reaches the conversation. The application retries, receives another tool call, and adds the note again.

Which model caused the duplicate: Fable or Astra?

That question is incomplete. A model proposes an action, while your application decides whether to execute it. If every new tool-call identifier becomes a fresh business operation, either model route can expose the same weakness.

For developers comparing Fable 5.2 with Astra through an AI API gateway, this is a useful production test. Evaluate how the entire tool workflow behaves after an uncertain outcome. A successful response format does not prove that repeating the workflow is safe.

This article is an engineering comparison framework, not a benchmark claiming one model duplicates actions more often. The incident and identifiers below are illustrative. The code demonstrates a local transactional boundary that you can inspect before connecting a real business system.

The architecture decision: identify the operation outside the model

Keep two identities. The provider's tool-call identifier connects a requested tool with its result inside a conversation. Your application's operation identifier connects an authorized business action with its execution record.

They answer different questions. “Which call should receive this result?” is a protocol question. “Has this approved action already happened?” is a business-state question.

The OpenAI function-calling guide describes returning outputs associated with function calls. Claude's tool-call handling guide describes tool results associated with tool-use identifiers. Preserve those protocol relationships when constructing the next model request.

Do not assume either identifier will remain unchanged when a fresh model request proposes the same action again. Your executor needs a stable operation identity that survives that retry when it represents the same approved intent.

ConcernFable workflowAstra workflowApplication responsibility
Connect a tool resultPreserve the relevant tool-use relationshipPreserve the relevant function-call relationshipUse the selected protocol correctly
Recognize an approved actionDo not infer identity from prose aloneDo not infer identity from prose aloneMaintain a durable operation ID
Repeat after uncertaintyAnother proposal may need reconciliationAnother proposal may need reconciliationCheck execution evidence first
Change modelsBuild the destination's input formatBuild the destination's input formatPreserve business-state records

For capability and model-selection context, start with the existing Fable and Astra comparison. The narrower decision here is where your application stores evidence that an action has happened.

A retry policy should name the thing being retried

Applications often have several retry layers: an HTTP client, an API gateway, a model runner, a tool executor, and a queue worker. Repeating a model request and repeating a ticket update are not equivalent operations.

A model request might only produce another proposal. A ticket update changes a business record. If an outer loop repeats both without checking state, a temporary communication failure can become a duplicate change.

The HTTP semantics specification distinguishes idempotent methods and discusses retry constraints. Do not treat a timeout as proof that a non-idempotent operation failed before reaching the server. It tells you that your client did not obtain a conclusive result.

Make the retry unit explicit in logs and code. Record whether you are resending an inference request, polling a known task, returning a saved tool result, or creating a new business operation. This vocabulary makes incident reviews much more useful than a single counter labeled retries.

When the error occurs before a valid tool proposal exists, use the appropriate integration guide. The forced-tool-choice 400 article and JSON schema compatibility guide cover different failure boundaries.

A local experiment makes the duplicate visible

Suppose the authorized action is to attach one approved note to one ticket. The application creates an operation ID for that approval. If the workflow resumes, it carries the same ID for the same action. A genuinely new note receives a new approved operation ID.

The example below stores the note and its receipt in one SQLite transaction. It does not connect to a model or an external ticket service. Its guarantee is limited to this shared database boundary.

python
import hashlib
import json
import sqlite3

def setup(db):
    db.executescript("""
        CREATE TABLE notes (
            id INTEGER PRIMARY KEY,
            tenant TEXT NOT NULL,
            ticket TEXT NOT NULL,
            body TEXT NOT NULL
        );
        CREATE TABLE receipts (
            tenant TEXT NOT NULL,
            operation_id TEXT NOT NULL,
            payload_hash TEXT NOT NULL,
            note_id INTEGER NOT NULL,
            PRIMARY KEY (tenant, operation_id)
        );
    """)

def add_note_once(db, tenant, operation_id, ticket, body):
    payload = json.dumps(
        {"ticket": ticket, "body": body},
        sort_keys=True, ensure_ascii=False, separators=(",", ":"),
    ).encode("utf-8")
    fingerprint = hashlib.sha256(payload).hexdigest()
    db.execute("BEGIN IMMEDIATE")
    try:
        prior = db.execute(
            "SELECT payload_hash, note_id FROM receipts "
            "WHERE tenant = ? AND operation_id = ?",
            (tenant, operation_id),
        ).fetchone()
        if prior:
            if prior[0] != fingerprint:
                raise ValueError("Operation ID reused with different arguments")
            result = {"note_id": prior[1], "replayed": True}
        else:
            cursor = db.execute(
                "INSERT INTO notes (tenant, ticket, body) VALUES (?, ?, ?)",
                (tenant, ticket, body),
            )
            note_id = cursor.lastrowid
            db.execute(
                "INSERT INTO receipts VALUES (?, ?, ?, ?)",
                (tenant, operation_id, fingerprint, note_id),
            )
            result = {"note_id": note_id, "replayed": False}
        db.commit()
        return result
    except Exception:
        db.rollback()
        raise

if __name__ == "__main__":
    db = sqlite3.connect(":memory:", isolation_level=None)
    setup(db)
    action = ("demo-tenant", "approved-op-17", "TICKET-8", "Review requested.")
    print(add_note_once(db, *action))
    print(add_note_once(db, *action))
    print("notes:", db.execute("SELECT COUNT(*) FROM notes").fetchone()[0])
    db.close()

Two attempts return the same note identifier, and the final count is one. Reusing the operation ID with different arguments raises an error. That check prevents a caller from quietly changing the meaning of an already recorded operation.

The memory database is only for the demonstration. A deployed ledger must be durable and shared by the relevant executors. A separate in-memory ledger in each worker would not coordinate them.

The SQLite transaction reference and Python sqlite3 documentation explain the transaction controls used here. The code requires an idle connection when it begins its transaction. It is not a drop-in wrapper for every application's existing transaction manager.

The operation ID needs an authorization boundary

Do not ask the model to invent a new operation ID on every retry. That produces new identifiers precisely when you need continuity. Conversely, do not deduplicate every identical sentence forever: a user may intentionally add the same text on a later occasion.

The application should create or retrieve the operation ID from a trusted workflow record. Bind it to the relevant tenant, action, target, and approved arguments. Recheck the user's authorization before executing or returning a stored result.

The demonstration trusts its function arguments because it is a local test. It does not implement authentication, tenant membership, approval expiration, or permission revocation. Those checks belong before the database mutation in a real service.

The digest provides a compact comparison of the represented arguments. It is not an approval signature. Python's hashlib reference documents the hashing primitive; your application still defines what belongs in the operation's identity.

Include every business-relevant argument in that definition. Ignoring the target account, destination, or document version can collapse two different actions into one receipt. Including transient transport metadata can create the opposite problem by treating every retry as new.

An external API requires a different recovery boundary

The SQLite example works because both the business change and receipt live in the same transaction. An external ticket service cannot usually participate in that local transaction.

If you call the external service and then save the receipt, a crash between those steps leaves an uncertain result. If you save a completed receipt first, you can report success for a call that never happened. Moving the two statements around does not eliminate the gap.

Use the external service's documented idempotency mechanism when available, carrying a stable application operation key within its documented scope and lifetime. Otherwise, preserve a pending or unknown state and reconcile using evidence from the external system before sending another mutation.

Do not describe that reconciliation as guaranteed exactly-once execution. Its strength depends on the downstream API, lookup capability, retention window, and your recovery process. The model provider's tool-call ID alone does not supply those guarantees.

For asynchronous model work, the background-job polling and cancellation guide covers task lifecycle handling. Cancellation or disconnection also should not be interpreted as rollback of an external action that already completed.

Compare the two routes with the same failure scenarios

Decide what the model should receive when the ledger finds a completed operation. Return a truthful result containing the existing business record identifier and a clear indication that the action was already completed. Then associate that result with the current conversation's tool call using the selected protocol. Replaying an execution receipt does not mean replaying an old provider message without checking its identifiers.

If the operation remains unknown, return an unresolved outcome that the agent can explain or escalate. Do not manufacture a success response to keep the conversation moving. Likewise, do not give the model an unrestricted instruction to repeat the mutation until it receives confirmation. That moves a recovery decision into a loop without adding execution evidence.

Define receipt retention in terms of your workflow. A short-lived chat session can trigger a business process that remains relevant much longer. Deleting its receipt while delayed retries are still possible reopens the duplicate-action risk. Keeping receipts indefinitely also needs a deliberate data-retention policy. Store the minimum business evidence required to identify the operation and reconcile its outcome.

These choices belong in the application design review before selecting a preferred model. They give your Fable and Astra adapters the same operational contract, so differences observed during testing are easier to interpret.

Run a small acceptance exercise before enabling mutations in an agent. Use the same approved operation, tool definition, expected result, and application executor for each supported model route.

Test normal completion, a repeated tool proposal, a lost result after execution, changed arguments under the same operation ID, and a request under another tenant. Use a controlled stub for the external service so that the test cannot send real notifications or alter live records.

Judge model behavior and executor behavior separately. Record whether the model selected the intended tool and arguments. Then record whether the application executed the approved business operation once, returned the saved result, or stopped for reconciliation.

Keep failures in the final report. A malformed proposal is not the same as a duplicate mutation. A route that cannot accept the required protocol is another distinct issue; the Responses tool-call compatibility guide covers that boundary for relevant GPT routes.

Use the gateway trial to verify the complete handoff

With 4SAPI, first confirm that the intended Fable and Astra routes are available to your account and support the required tool protocol. Register for the trial, configure one route, and connect it to a harmless local executor before comparing the second.

Keep the operation ledger outside the model-specific adapter. Switching the model should change how you construct requests and parse proposals, not erase evidence of actions already performed.

The API gateway evaluation guide provides broader integration criteria. For this trial, the decisive result is concrete: both routes can complete the same approved workflow, and an interrupted conversation does not silently create a second business action.

Tags:Claude FableGPT AstraFunction CallingIdempotencyAPI Gateway

Recommended reading

Explore more frontier insights and industry know-how.