Coco
Integrate and operate

Agentic workflows

Govern a multi-step workflow end to end, with facts held outside the agent and least authority at each stage.

Govern a multi-step workflow, with facts held outside the agent and least authority at each stage.

python/examples/agentic_lending/ is a funding broker's agent on coco-framework, working a grant case from intake to submission. It reads the client's business context, checks eligibility against a programme's criteria, requests evidence, prepares the application, and submits it. It has seven tools, every one behind CocoGuard, and six contracts that read the case snapshot through each fact's review status.

Prerequisites: A checkout of coco-sdk, and the SDK and coco-framework, installed as in the Quickstart.


Run the example

From the checkout, run:

python python/examples/agentic_lending/agent.py          # thirteen scripted runs, one per failure pattern
python python/examples/agentic_lending/agent.py --live   # a real model works one case

Each scripted run prints the expected verdict and what Coco decided:

ok  scope_creep: Read the credit file at intake  (expected DENY)
   1. What is the client's credit position?
      funding.read_record            DENY         The record is outside what the current workflow stage authorises the agent to read

The run ends with the chain check. python/tests/test_agentic_lending.py asserts every scenario's verdict and that the chain verifies.

What it demonstrates

  • The orchestrator holds the record: The Orchestrator class is the guard's state provider. It supplies every fact with its status, and the agent never writes it. The agent's own answers go with the call as agent_answers, so the receipt shows what it believed, and no rule reads them.
  • An unreviewed fact is unknown: A cash figure the client stated in conversation fails cash_match_reviewed before any value is compared. The constraints behind it are recorded as skipped, not passed.
  • Remediation needs no person: The denial names the fact and what the orchestrator does about it. The agent requests the bank statement, the orchestrator reviews it, and the same check passes against the updated snapshot.
  • The agent never marks its own work: Writing a fact's review status is denied whatever the fact says. Changing a programme's criteria escalates to the contract's owner, who raises the version.
  • Least authority by stage: The snapshot names the actions and records the current stage allows, so a credit file read at intake is denied before it happens.

Good to know: The hosted dashboard's agentic lending workspace plays the same scenarios against the same rules in the gate's pack format, so a run in either place shows the same verdicts.

Apply it to your workflow

  1. Keep the case state outside the agent, in something your application owns.
  2. Pass it to the guard as a state provider.
  3. Give each fact a review status, and write rules that read the status before the value.
  4. Have the snapshot name what each stage allows, and deny the rest.
  5. Make each denial say what would satisfy it, so the agent can recover without a person.

On this page