> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sudont.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Agentic ReAct Loop

> How Sudont fires deterministic JSON errors into agentic ReAct loops — letting swarms recalculate routes without human prose in the hot path.

## Overview

Most firewalls do one thing: block. Sudont does something fundamentally different — when a
transaction is fatal, it fires a **deterministic JSON ReAct error** straight back into the
swarm's reasoning loop.

<Note>
  The swarm does not read prose. It reads a stable `rule_id`, a machine-readable `simulated_reality`,
  and an `actionable_feedback` token. The firewall stays out of the agent's reasoning; the agent
  stays out of the firewall's physics.
</Note>

The Judge blocks the trade. The RPC proxy returns a structured JSON-RPC error. The swarm's
agentic ReAct loop consumes the payload, recalculates its route, and resubmits. No human prose
is generated, parsed, or trusted anywhere in the hot path.

***

## The Four Verdicts

Every transaction that passes through the Diamond receives one of four verdicts from the Judge:

| Verdict         | Trigger                                                         | Outcome                                   |
| --------------- | --------------------------------------------------------------- | ----------------------------------------- |
| **ALLOW**       | Canonical intent matches State-Diff, within Constitution bounds | EIP-191 signed approval artifact          |
| **DENY**        | State-Diff violates bounds, or Constitution hard-violated       | Deterministic JSON ReAct error            |
| **INTERROGATE** | Medium-risk signal detected                                     | JSON ReAct error — swarm recalculates     |
| **DIAGNOSE**    | Diagnosis-only request (no forwarding)                          | Full diagnosis envelope; never broadcasts |

<Warning>
  `INTERROGATE` is not a soft block. It is an active signal to the swarm's ReAct loop. The Judge
  does not wait — it immediately emits a deterministic JSON error and the RPC proxy returns it
  inline with the failed call.
</Warning>

***

## The Feedback Loop

<Steps>
  <Step title="Swarm Submits Request" icon="paper-plane">
    The autonomous agent submits a transaction or approval request through the Sudont drop-in RPC proxy.
  </Step>

  <Step title="Diamond Pipeline Evaluates" icon="gem">
    The request passes through Constitution → Cortex/Cage → Judge. The Judge identifies a fatal
    violation or a medium-risk signal and emits a verdict.
  </Step>

  <Step title="Judge Emits JSON ReAct Error" icon="code">
    The payload carries a stable `rule_id`, the `simulated_reality` observed in the sandbox, and an
    `actionable_feedback` token the swarm consumes directly. Examples:

    * `rule_id: "MAX_SLIPPAGE_EXCEEDED"`, `actionable_feedback: "RECALCULATE_ROUTE_OR_SIZE"`
    * `rule_id: "UNLISTED_DESTINATION"`, `actionable_feedback: "PROVIDE_ALLOWLISTED_ADDRESS"`
  </Step>

  <Step title="Swarm Recalculates" icon="rotate">
    The agentic ReAct loop reads the token, adjusts its parameters, and resubmits with a new route
    or size. No prose parsing required.
  </Step>

  <Step title="Verification" icon="check-double">
    The resubmitted transaction re-enters the Diamond. If compliant, it is approved and signed.
    If not, a fresh JSON error is emitted — each block is self-contained and terminal for its own
    attempt.
  </Step>
</Steps>

***

## When the Firewall Fires

The Cortex enriches every transaction with computed flags before the Judge evaluates it. The
Judge queries the Constitution's compiled policy rules to classify risk.

| Signal                                      | Why It's Fatal                                         |
| ------------------------------------------- | ------------------------------------------------------ |
| Unbounded token approval (`MAX_UINT256`)    | Swarm may be granting unbounded access to a spender    |
| Unverified spender address                  | Constitution does not recognise the counterparty       |
| Non-allowlisted contract destination        | Swarm may be interacting with an unknown protocol      |
| Malicious PDA drain in simulated State-Diff | Bare-metal simulation caught a trapdoor the LLM missed |

<Tip>
  These signals are defined in the compiled policy rules alongside the allow/deny logic — not
  hardcoded in code. Adding a new risk heuristic is a **policy change**, not a code change.
</Tip>

***

## JSON ReAct Error Payload

Every block ships a stable JSON-RPC error. The swarm parses exactly one structure — it never
encounters prose, suggestions, or ambiguity.

```json title="Deterministic JSON ReAct Error" theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32010,
    "message": "Sudont policy violation",
    "data": {
      "sudont": {
        "violations": [
          {
            "rule_id": "MAX_SLIPPAGE_EXCEEDED",
            "simulated_reality": "99.9% loss due to malicious PDA drain",
            "actionable_feedback": "RECALCULATE_ROUTE_OR_SIZE"
          }
        ],
        "latency_us": 122
      }
    }
  }
}
```

See [ReAct Error Payload](/react-loop) for the full schema, every `rule_id`, and the full set of
`actionable_feedback` tokens.

***

## What the Firewall Cannot Do

The Judge is deliberately constrained:

<CardGroup cols={2}>
  <Card title="Cannot Generate Prose" icon="ban">
    Sudont never emits natural-language explanations in the hot path. Every block is a stable token.
  </Card>

  <Card title="Cannot Sign" icon="key">
    Only the approval path produces a signed artefact. Blocked transactions never touch the keystore.
  </Card>

  <Card title="Cannot Modify Policy" icon="lock">
    The Constitution's bounds are read-only during evaluation. Policy is immutable mid-flow.
  </Card>

  <Card title="Cannot Loop Indefinitely" icon="circle-stop">
    Each submission is evaluated once. Resubmissions are fresh transactions — no implicit retry.
  </Card>
</CardGroup>

***

<Card title="Drop-in RPC Integration" icon="terminal" href="/quickstart">
  Point your standard Web3 libraries at Sudont and consume the JSON ReAct errors directly in your
  agentic ReAct loop — no custom SDK required.
</Card>
