Skip to main content

Ask for more consent with step-up

Goal: start a task with the narrowest consent it needs. When an agent then reaches for something the person didn't approve, ask that person, instead of failing the task or having asked for everything up front.

1. Turn it on​

On the control plane:

AGENTIC_AUTH_CONSENT_GRANULARITY_ENABLED=true # sessions may consent to a subset
AGENTIC_AUTH_STEP_UP_ENABLED=true # a recoverable refusal carries a challenge

Both are off by default. With them off, no step-up route exists and no decision changes.

session = await client.consent(
scope="bank-assistant", user_sub="user:alice", data_classes=["account.read"],
)

The pinned policy may declare more classes, such as kb.internal. This session covers only the ones listed.

3. Catch the refusal, and the challenge it carries​

from agentic_auth.sdk import PolicyDenied

try:
grant = await client.authorize(ctx, target="agent://support-agent", data_class="kb.internal")
except PolicyDenied as denied:
if denied.challenge: # only a recoverable refusal carries one
show_to_the_person(denied.challenge) # data_class, target, reason, challenge_id

Only SCOPE_NOT_CONSENTED can be stepped up, and only for a class the agent's manifest actually declares. A refusal for anything else (OUT_OF_SCOPE, HOP_BUDGET_EXCEEDED, EDGE_NOT_IN_DAG, TAINTED_INTO_PRIVILEGED) never carries a challenge. No prompt can widen a manifest or launder injected content, so none is offered. A challenge expires after five minutes (AGENTIC_AUTH_STEP_UP_CHALLENGE_TTL_SECONDS).

4. The person approves, with their own credential​

approval = await client.approve(denied.challenge, credential=id_token_of_the_person)
approval["approved"] # True

The credential is the person's, not the agent's. When the control plane has an identity provider configured (AGENTIC_AUTH_PRINCIPAL_IDP_*), it's an ID token from that provider, and the approver is recorded as its subject. The session's own grant is refused here on purpose: an agent that could approve its own widening would make the whole flow decorative.

Without an identity provider, the admin bearer stands in, and the approver is recorded as admin. In that case you have no independent human channel, so say so in your own documentation.

To decline, pass approved=False. The original refusal then stands.

5. Resume the hop that was blocked​

grant = await client.resume(ctx, denied)

Retry with the same context. A refusal spends nothing, so the delegation record is the original one and the hop budget continues where it was, without resetting. The widening is recorded in the audit log as its own row, linked to the refusal that raised it. Later hops in the same session that need the same class don't ask again.