Skip to content
Kavachकवच

Agent Modes

Also known as: audit trail logging compliance observe shadow mode dry run rollout trust governance

● Intermediate5 minBefore this: AgentsSpec 8.5

Each agent runs in a mode, set in its settings: Observe only reports, Suggest asks a person every time, Enforce acts. Trust is earned step by step.

ModeCapability callsLimits and approvals
Observerun normallyonly reported: "would be refused"
Suggesteach one waits for a person to approve itshown with each request
Enforce (the default)run when allowedenforced: a broken limit refuses, an approval waits

One program, a refund agent with amount <= 500, asked for 400 and then 900. It prints its audit log at the end:

use std.fs

type PayError = Declined | Denied(reason: String)

capability Payments {
    fn refund(order: Int, amount: Int) ! PayError
}

type Bank: Payments {
    fn refund(self, order: Int, amount: Int) ! PayError {
    }
}

agent Refunder {
    settings AgentSettings(audit: Audit())
    can Payments.refund

    limit Payments.refund {
        amount <= 500
    }

    on refund(order: Int, amount: Int) ! PayError {
        try Payments.refund(order, amount)
    }
}

fn main() ! Error {
    const bot = Refunder.start(Payments: Bank())
    bot.refund(1, 400) catch e => print("refused: {e}")
    bot.refund(2, 900) catch e => print("refused: {e}")
    for line in try fs.lines("agents/Refunder/audit.log") {
        print(line.split("Z ").last() ?? line)
    }
}
src/main.kav: Kavach code

The same program with mode: AgentMode.Observe in its settings: both refunds run, and the log says which one the rules would have refused:

agent Refunder {
    settings AgentSettings(mode: AgentMode.Observe, audit: Audit())
    …
}

The program ran and printed:

Refunder request#1 Payments.refund(order: 1, amount: 400)  verdict: allowed  result: okRefunder request#2 Payments.refund(order: 2, amount: 900)  verdict: would be refused (limit broken: amount <= 500)  result: ok
the agent: Kavach code, then what running it prints

A company can run a new agent beside the old process in Observe for a week, read what it would have blocked, then switch to Suggest or Enforce: one word in the agent's settings, seen in review. The mode is worked out when the program is built, so an executable keeps the mode it was built with.

One page for each form

Check yourself

QUIZ 1 / 1pick one
In observe mode, a call breaks a limit. What happens?