Approval Service

The approval service turns calls held for confirmation into an inbox of approval requests with a policy: who may approve, how many distinct approvers a call needs, whether the requester may approve their own call, when the request escalates, and when it expires. It runs over any ApprovalStore, so requests are as durable as the store — in memory, SQLite, PostgreSQL, Redis, MongoDB, Neo4j, or Firestore.

CapabilityBehaviour
InboxLists the requests an approver may decide now — by name, by group, or through a live delegation — oldest first, paged by cursor; InboxQuery::with_session narrows it to the decisions one session — application, user and session ID — waits on
QuorumA request resolves once quorum distinct approvers approve; a delegate's approval counts for the delegator
SlotsA request with slots resolves only once distinct approvers fill every slot, one each — an editor and a publisher who are two people — whatever order they decide in
DirectoryAn ApproverDirectory on the service states each approver's and delegator's membership of the groups it governs; callers' claims to those groups are ignored
Self-approvalRefused by default for the requester, the acting agent, and anyone acting through their delegation
ActionsApprove, edit (approve with substituted arguments), reject, respond (answer the model instead of running the call)
ConcurrencyEvery change is a compare-and-swap on the request's version; of two approvers deciding one version, one wins and the other receives 409 approval.version_conflict
Expirytick denies requests past expires_at, once
Escalationtick fires each escalation step once its delay has passed, adding its approvers and notifying
DelegationA subject lets another decide in their place within a time window and an application or tool scope
NotificationApprovalNotifier hears submission, escalation, decisions, resolution, expiry, and cancellation; adk-server ships a signed webhook notifier
Resolution hooksAn ApprovalResolution runs once the deciding answer is recorded and before the outcome reaches the call or wakes its run
ResumeA resolution is written to the store under the call's fingerprint, wakes the durable run waiting for it, and is otherwise taken by the next run, which resumes the held call
BindingThe fingerprint names the acting agent and the tool's origin, so a resolution authorizes only the agent that held the call, on the tool it was held for; a held call that resumes against another MCP server or a redefined tool is answered as not run

How a Held Call Becomes a Request

  1. The governed path holds a call that needs confirmation and records it in the run's ApprovalStore.
  2. With RunConfig::approval_service set, it also offers the call to the service's ApprovalRouter, which returns the ApprovalPolicy (or None to leave the call in the store only). The request ID is derived from the session, the call's fingerprint, and the time it was first held, and a call held again while its request is pending gets that request back, so one held call never has two open requests.
  3. Approvers decide through ApprovalService::decide or the server endpoints.
  4. The decision that resolves the request is written to the store: an approval (with any edited arguments) or a denial carrying the reason. The request's run_id is woken with DurableRunStore::wake when the service has a run store (StoreApprovalService::with_run_store), and so is every run of the session parked on the call (a RunCheckpointRef::AwaitingApproval naming its fingerprint), such as a later run that held the call again while the request was still open. adk-server's DurableWorker sets RunConfig::durable_run_id to the claimed run's ID, so a run it parks on a held call is the run its approval wakes.
  5. The next run resumes the held call under its original call ID, and the governed path takes the decision. An edited call passes the ToolPolicy and the agent's tool screen again before it executes; a policy denial of the edit refuses the call. A run without a decision for the call does not ask its confirmation handler about it again: the call keeps waiting and the run goes on to the model (spec 3.3 §7.3). LlmAgent, CodeActAgent and the realtime runners follow this rule; CodeActAgent answers the new message in a turn that cannot suspend and keeps the waiting call's checkpoint, unless that turn decided an identical call, which answers the waiting one. CodeActAgent checks the waiting call under the arguments it was held with, after plugin and screen rewrites, and a run that resumes it on a decision gives the message the run brought to the model.
  6. A call decided any other way — by the confirmation handler, a call-ID decision, a fingerprint approval, or Harness::decide — has its open request withdrawn (ApprovalService::withdraw: closed as cancelled, with no outcome written and no run woken) and its pending entry cleared, so the request cannot authorize a later call with the same fingerprint. A request an approver resolved at the same moment is waited for until its outcome is in the store, and that outcome is absorbed, as is an outcome already applied or recorded while the confirmation handler was asked; a request that does not settle within ten seconds fails the call with approval.outcome_unsettled. Harness::decide refuses a rule it cannot remember before it touches the request, withdraws the request before it records the person's decision, and refuses the decision when an approver, an expiry or another decision settled the call first. Of two Harness::decide calls for one call at once in one process — two surfaces answering together — the second is refused with harness.decision.invalid; the store's decision write is not conditional, so processes that share a store and decide one call at the same moment are not told apart.
use std::sync::Arc;
use std::time::Duration;

use adk_core::{
    ApprovalCall, ApprovalPolicy, ApprovalRisk, ApprovalRoute, ApproverSelector, RunConfig,
    StoreApprovalService,
};
use adk_session::SqliteApprovalStore;

async fn configure() -> adk_core::Result<RunConfig> {
    let store = SqliteApprovalStore::new("sqlite://approvals.db?mode=rwc").await?;
    store.migrate().await?;

    // Large transfers need two people from finance and escalate to the CFO office.
    let router = |call: &ApprovalCall| {
        let amount = call.request.args["amount"].as_f64().unwrap_or(0.0);
        let finance = ApprovalPolicy::new([ApproverSelector::group("finance")])
            .expires_after(Duration::from_secs(4 * 3600));
        Some(if amount > 10_000.0 {
            ApprovalRoute::new(
                finance
                    .with_quorum(2)
                    .escalate_after(Duration::from_secs(1800), [ApproverSelector::group("cfo-office")]),
            )
            .with_risk(ApprovalRisk::High)
        } else {
            ApprovalRoute::new(finance)
        })
    };
    let service = StoreApprovalService::new(Arc::new(store)).with_router(router);
    Ok(RunConfig::builder().approval_service(Arc::new(service)).build())
}

RunConfigBuilder::approval_service also installs the service's store as the run's approval_store, so decisions reach the governed path.

Without a router, a held call stays in the store only. A host that decides calls in an inbox gives such a service a router of its own with ApprovalService::route_unrouted, and adds a notifier to a built service with ApprovalService::add_notifier: the agent kernel routes every unrouted call to the operator group and publishes held and decided on its bus. A router the service was built with keeps deciding, including to leave a call in the store only. Both methods answer whether the service took what it was given; their defaults take nothing, so a wrapper forwards them.

ApprovalService::add_resolution adds an ApprovalResolution, which runs for each request a decision resolves, after the decision is recorded and before the outcome is written for the call and its run is woken. A host puts there what the resumed call must already see: adk-surface's LocalSource grants the standing rule of "Always allow" from it, so the turn the approved call resumes is checked against the rule (Surfaces). A hook reports its own failures, and the outcome applies whatever it does. The default takes none, and a wrapper forwards it.

Policy

FieldDefaultMeaning
approvers—ApproverSelector::Subject(SubjectRef) or ApproverSelector::Group(name)
slotsnoneSelectors distinct approvers must fill, one approver each; a selector listed twice needs two people. Whoever a slot selects may approve
quorum1Distinct approvals needed; ApprovalPolicy::for_slots sets it to the number of slots
forbid_self_approvaltrueRefuse the requester and the acting agent; allow_self_approval() clears it
escalationnoneSteps {after, to}, ordered by after
on_expiryDenyWhat expiry does
expires_afternoneRequest lifetime when the request carries no expires_at

The requester is the acting context's on_behalf_of subject, or the session's user when the call carries no acting context. Group membership is asserted by the caller deciding (ApprovalDecision::approver_groups); adk-server takes it from the authenticated request.

Slots

A policy with slots needs one distinct approver per slot. Approvals beyond the quorum do not resolve the request while a slot is open, and the service matches approvers to slots over all counted approvals, so a person who could fill either of two slots never blocks the other. ApprovalRequest::open_slots lists the slots still waiting.

use adk_core::{ApprovalPolicy, ApproverSelector};

/// An editor and a publisher, two distinct people, neither the requester.
fn release_policy() -> ApprovalPolicy {
    ApprovalPolicy::for_slots([
        ApproverSelector::group("role:editor"),
        ApproverSelector::group("role:publisher"),
    ])
}

Approver Directory

StoreApprovalService::with_directory makes an ApproverDirectory the authority on membership of the groups it governs (ApproverDirectory::governs, every group by default): the service asks it for the groups of the approver and of any delegator, for every decision and every inbox, and records the answer in approver_groups and authority_groups. A claim to a governed group does not count, so a surface cannot claim a role for the person deciding; groups it does not govern, such as an operator scope, are kept as asserted. adk_kernel::charter::CharterDirectory answers from the site charter in force.

use std::sync::Arc;

use adk_core::principal::SubjectRef;
use adk_core::{ApprovalRequest, ApproverDirectory, InMemoryApprovalStore, StoreApprovalService};
use async_trait::async_trait;

struct Staff;

#[async_trait]
impl ApproverDirectory for Staff {
    async fn groups(
        &self,
        subject: &SubjectRef,
        _request: &ApprovalRequest,
    ) -> adk_core::Result<Vec<String>> {
        Ok(match subject.id.as_str() {
            "ana@example.com" => vec!["finance".to_string()],
            _ => Vec::new(),
        })
    }
}

fn service() -> StoreApprovalService {
    StoreApprovalService::new(Arc::new(InMemoryApprovalStore::new()))
        .with_directory(Arc::new(Staff))
}

Decisions

ActionRequiresEffect
Approve—Counts toward the quorum
Editedited_argsApproves the substituted arguments; approvals of earlier arguments stop counting
Rejectoptional reasonResolves at once; the call is refused with the reason
Respondresponse textResolves at once; the call does not run and the model receives the response
Error codeHTTPWhen
approval.version_conflict409The request changed since the version read; re-read and decide again
approval.already_resolved409The request is no longer pending
approval.expired409The request is past its expiry
approval.already_decided409The approver's authority already counts toward the quorum
approval.not_an_approver403Not eligible directly or by delegation
approval.delegation_inactive403The only matching delegation is outside its window
approval.self_approval403Self-approval is forbidden
approval.action_not_allowed400The request does not allow the action, or an edit or response lacks its content

Decisions a Reviewer Made

A run with a ToolReviewer (Model Reviewer) decides some held calls before they reach the inbox. When it approves or denies one, the governed path files it with ApprovalService::record_review: the service routes the call as it would a held call and stores a request already resolved — Approved or Rejected, one decision by the reviewer (SubjectRef::service("model:<model id>")) carrying its rationale, and outcome_applied set, because the run applied the verdict itself. Nothing is written to the store and no run is woken. Notifiers hear Decided and Resolved, so the kernel publishes decided naming the reviewer, and the service's audit trail records the decision with source reviewer. A call the reviewer escalates is submitted as a pending request like any other held call, with the reviewer's note in its summary. The trait's default files nothing; a wrapper forwards it to the service it wraps.

Expiry and Escalation

ApprovalService::tick(now) expires overdue requests and fires due escalation steps. The service reads now from its Clock everywhere else, so tests drive it with ManualClock. Run it periodically — adk_server::approvals::spawn_approval_ticker does — on any number of replicas: each expiry and each escalation step is a compare-and-swap, so it happens once.

tick also applies resolutions whose application an earlier failure interrupted, after APPROVAL_REAPPLY_GRACE, and only while the call is still pending in the store, so a decision is never written twice.

Delegation

use adk_core::principal::SubjectRef;
use adk_core::{ApprovalDelegation, ApprovalService, DelegationScope, DelegationWindow};
use chrono::{Duration, Utc};

async fn cover(service: &dyn ApprovalService) -> adk_core::Result<()> {
    let now = Utc::now();
    let delegation = ApprovalDelegation::new(
        SubjectRef::human("ana@example.com"),
        SubjectRef::human("bo@example.com"),
        DelegationWindow::new(now, now + Duration::days(7)),
    )
    .with_from_groups(["finance"])
    .with_scope(DelegationScope { app_name: Some("payments".into()), tool_names: vec![] });
    service.delegate(delegation).await?;
    Ok(())
}

A decision through a delegation records via_delegation and counts for the delegator. Outside the window the delegate is refused with approval.delegation_inactive.

Server Endpoints

Enable the approvals feature of adk-server and mount the service:

use std::sync::Arc;
use std::time::Duration;

use adk_core::{ApprovalService, StoreApprovalService};
use adk_server::ServerBuilder;
use adk_server::approvals::spawn_approval_ticker;

// `config` is a ServerConfig with a RequestContextExtractor; `store` an Arc<dyn ApprovalStore>.
let service: Arc<dyn ApprovalService> = Arc::new(StoreApprovalService::new(store));
let app = ServerBuilder::new(config)
    .with_approval_service(service.clone())
    .build();
let ticker = spawn_approval_ticker(service, Duration::from_secs(30));
RouteEffect
GET /api/approvalsThe caller's inbox (state, group, app, user, session, cursor, limit); session needs app and names a session of user, the caller by default, and never widens the inbox
GET /api/approvals/{id}One request the caller may decide or asked for
POST /api/approvals/{id}/decide{"expectedVersion", "action", "editedArgs", "reason", "via"}
POST /api/approvals/{id}/cancel{"reason"}; the requester or an approver
POST /api/approvals/delegationsDelegates the caller's authority: {"to", "notBefore", "notAfter", "scope"}
DELETE /api/approvals/delegations/{id}?toKind=&toId=Revokes a delegation the caller granted or holds

Every route requires an authenticated caller and answers 401 otherwise. The caller is human(user_id) in the groups named by its scopes; ApprovalEndpoints::with_identity changes the mapping. Responses omit the call's fingerprint, which carries the unredacted arguments; approvers see argsRedacted, the acting agent, and the tool's origin (its publisher and declaration digest) on the request. showsCallArgs says whether argsRedacted are the call's own arguments (ApprovalRequest::shows_call_args): an edit replaces the call's arguments with editedArgs whole, so a client edits only a request that shows them, never a redacted view (spec 3.3 §7.2).

Webhook Notifications

WebhookApprovalNotifier posts each ApprovalNotification as JSON in the Standard Webhooks format: webhook-id (the notification ID, {request id}:{version}, stable across retries), webhook-timestamp, and webhook-signature (v1, and the base64 HMAC-SHA256 of {id}.{timestamp}.{body}). It signs and sends through the shared adk_core::webhook_delivery::WebhookDelivery: retries with exponential backoff and jitter in the background, dead-lettering after the last attempt, and an egress policy that allows HTTPS to public addresses only (with_delivery changes it). See Wake-ups and Webhooks.

use std::sync::Arc;

use adk_core::StoreApprovalService;
use adk_server::approvals::WebhookApprovalNotifier;

// The secret is base64, optionally prefixed with `whsec_`.
let notifier = WebhookApprovalNotifier::new("https://hooks.example.com/approvals", &webhook_secret)?;
let service = StoreApprovalService::new(store).with_notifier(Arc::new(notifier));

Notification is best effort: a delivery that fails every attempt is dead-lettered and the decision stands, because the store holds the request's state.

Backends

The store methods behind the service — create_request, get_request, replace_request, list_requests, put_delegation, delegations_to, delete_delegation, and take_approval — are implemented by every backend and checked by the approval_store_conformance_tests! and approval_service_conformance_tests! suites. See Durable Stores for the primitive each backend uses.

Approval Service - ADK-Rust 문서 | ADK-Rust