APL
Human-in-the-Loop Elicitation
Some operations should not proceed on the caller's say-so alone.
On this page
Some operations should not proceed on the caller’s say-so alone. A large payroll change wants a manager’s approval; a destructive action wants the user to confirm; a sensitive read wants a fresh second factor. Elicitation lets a policy pause an operation to ask a human and resume once they respond — without blocking the request path, and with the decision bound to the actual request rather than to an LLM’s paraphrase of it.
Approval requirement
The scenario’s approve_raise may run only after the requester’s manager
approves, and the approval must cover the specific amount being requested. The
manager is not the caller, may take hours to respond, and their answer must be
genuine — a signed decision from the right person, not a value the agent
asserts. PPE must dispatch the ask, hold the operation open across the agent’s
retries, and verify the response before letting the tool run.
Elicitation as an effect
Elicitation is an effect in the authorization.pre_invocation phase. A sugar
verb names an elicitation handler plugin and who to ask:
plugins:
- name: manager-approver
kind: elicitation/ciba
hooks: [elicit]
routes:
- tool: approve_raise
authorization:
pre_invocation:
- "require(authenticated)"
- when: "args.amount > 10000"
do:
- "require_approval(manager-approver, from: claim.manager,
channel: \"ciba\",
scope: \"args.amount <= 25000\",
purpose: \"Approve raise\")"
fromis who to ask — an attribute reference resolved against the request bag (hereclaim.manager, the requester’s manager, who differs from the subject). An attributefromthat doesn’t resolve fails closed rather than dispatching to a bogus identity.scopeis the args binding — an APL boolean expression the runtime checks against the live request when the response comes back.purposeis the audited, human-readable description of what is being asked.
The other verbs (confirm, require_step_up, require_attestation,
request_info, require_review) parse to the same effect with a different
kind; each selects the validation contract the runtime applies to the response.
The model: suspend and resume
An elicitation has three short, synchronous touch-points. The hours-long human gap lives in the channel (e.g. Keycloak CIBA), never in a blocking call:
- Dispatch — first arrival: register the intent, open the channel backchannel, return a correlation id.
- Check — on each agent retry: read status (
pending/resolved/expired) without blocking. - Validate — once resolved: verify the response is genuine, then the
runtime layers the
scope-over-args sufficiency check before honoring the approval.
While pending, the phase suspends rather than denies. The decision stays
Allow, but a pending marker rides alongside it, and the host maps that to
JSON-RPC -32120 (“not complete — retry echoing this id”). The forward rule
is one clause: forward only when the decision is Allow and nothing is
pending. Expiry, channel error, a genuine denial, or a failed validation all
fail closed (default on_error: deny).
The CIBA channel plugin
The bundled elicitation/ciba plugin drives the ask through OpenID Connect CIBA
(Client-Initiated Backchannel Authentication) against Keycloak or any
CIBA-capable OP:
plugins:
- name: manager-approver
kind: elicitation/ciba
hooks: [elicit]
config:
backchannel_endpoint: "https://idp.example.com/realms/corp/protocol/openid-connect/ext/ciba/auth"
token_endpoint: "https://idp.example.com/realms/corp/protocol/openid-connect/token"
client_id: "ppe-gateway"
client_secret_source:
kind: file
path: /etc/ppe-secrets/client-secret
approver_claim: preferred_username
store: { kind: memory }
from becomes the CIBA login_hint, purpose seeds the binding_message, and
timeout maps to requested_expiry. Dispatch returns an auth_req_id that
doubles as the elicitation id the agent echoes on retry.
Elicitation attributes
Dispatch and resolution write elicitation.* attributes that later rules in the
same phase — and the audit log — can read:
| Attribute | Meaning |
|---|---|
elicitation.id | Correlation id the agent echoes on retry. |
elicitation.status | pending / resolved / expired. |
elicitation.outcome | approved / denied, once resolved. |
elicitation.approver | Resolved approver identity, cross-checked against from. |
elicitation.channel | Audit label for how the human was reached (not a routing key). |
Genuineness and argument binding
Two independent checks stand between an approval and the tool call:
- Genuineness is the channel plugin’s job. For CIBA, the approver identity
is extracted from the token the OP returns and cross-checked against the
login_hint. The plugin trusts the token because it comes straight from the OP over a client-authenticated TLS poll — it does not independently verify the JWT signature. That trust therefore rests on the token endpoint being reached over correctly configured TLS with client authentication; deploy accordingly (alwayshttps://, real client credentials) and do not point a CIBA handler at a plaintext or unauthenticated endpoint outside local development. - Sufficiency is the runtime’s job. Keycloak has no RFC 9396 rich
authorization request, so the binding between “what was approved” and “what is
being executed” lives in APL: the
scope:expression is evaluated against the live request args at validation. A human can approve, but if the args drift outsidescope(e.g. the amount was raised after approval), the operation fails closed regardless.
The purpose is recorded verbatim as the source of truth for what was approved
— it is never derived from model output.
The CIBA correlation binds the id to the selected policy route (including its
scope), exact tool name, and authenticated requester subject that opened it. A
different route, tool, or requester cannot poll or redeem the id; CIBA denies
dispatch, check, and validation without a non-empty route or subject.id.
OP rejection reasons report the status without reflecting the
response body, which may contain client credentials. A successful non-peek
validation consumes it atomically, so a
second application fails; an X-Policy-Elicitation-Peek request checks without
consuming and can be followed by one application. If a later step fails after
validation, the id is still spent. Correlations expire on their own.
Correlation store
CIBA keeps pending approvals between requests. Select the correlation store
with the plugin’s store: block:
kind: memoryholds approvals in this process. A restart loses them, and a retry on another replica cannot find them.kind: valkeyshares them across replicas and survives gateway restarts. Claiming an OP poll and redeeming are atomic, so two replicas cannot poll the same single-use ID concurrently or both apply one approval.
store: is required. Choose store: { kind: memory } for process-local
approvals, or configure Valkey to share them across replicas. An omitted
selection fails configuration loading.
global.session_store configures Session Taint only. It does not move CIBA
approvals unless a store: block references it.
The store holds the expected and actual approver, never a token. A user with
write access to CIBA keys can mark an approval as given. Keys use
<key_prefix>:<plugin name>:<digest>, so replicas of the same plugin share
approvals and different plugins use different keys. The prefix prevents key
collisions. Separate Valkey ACL users restrict access to each store’s keys.
Shared server, separate ACL user
For a shared Valkey server, reference the session store’s endpoint and TLS
with connection: session_store, then set separate CIBA credentials and a key
prefix:
global:
session_store:
kind: valkey
endpoint: valkey.internal:6380
tls: true
username: ppe-taint
password: { env: PPE_TAINT_VALKEY_PASSWORD }
plugins:
- name: manager-approver
kind: elicitation/ciba
hooks: [elicit]
capabilities: [perform_http]
config:
backchannel_endpoint: https://kc/realms/corp/protocol/openid-connect/ext/ciba/auth
token_endpoint: https://kc/realms/corp/protocol/openid-connect/token
client_id: praxis-policy-gateway
client_secret_source: { kind: env_var, name: CIBA_CLIENT_SECRET }
store:
kind: valkey
connection: session_store
username: ppe-ciba
password: { file: /run/secrets/ciba-valkey-password }
key_prefix: ciba:v1
A reference requires its own password; username is optional for a Valkey
default user. A password alone does not separate CIBA from Session Taint: when
neither block sets a username, both authenticate as the default user and share
its ACL, so CIBA can read and delete taint keys. Isolation needs a username
that differs from the session store’s. A reference may also set key_prefix, connect_timeout_ms, and
command_timeout_ms. The global endpoint must be a bare host:port with
separate credentials: full URL endpoints cannot be referenced. Use the
standalone form for a different server. A reference fails to load when
global.session_store is absent or is not kind: valkey. Hosts must load the
document with load_config_yaml, the loader that reads global.session_store.
Create each Valkey user with access to its store’s keys and commands. PPE does not create or check ACL users. Run these commands with an administrator account on the shared server:
valkey-cli -h valkey.internal -p 6380 --tls ACL SETUSER ppe-taint reset on \
'>taint-password' '~taint:v1:*' resetchannels +sadd +smembers +expire \
+multi +exec +ping +unwatch '+client|setinfo'
valkey-cli -h valkey.internal -p 6380 --tls ACL SETUSER ppe-ciba reset on \
'>ciba-password' '~ciba:v1:*' resetchannels +hmset +hgetall +hset \
+pexpire +del +exists +hget +hexists +hdel +time +multi +exec \
+evalsha '+script|load' +ping +unwatch '+client|setinfo'
reset starts each user from nothing, so it holds only the commands listed:
| Commands | Why |
|---|---|
sadd, smembers, expire | Session Taint labels and their TTL |
hmset, hgetall, pexpire, del | CIBA correlations and their expiry |
evalsha, script|load | Run cached CIBA scripts and load them after a cache miss |
exists, hset, hget, hexists, hdel, time | Poll claim, redeem, and resolve script commands |
multi, exec | Both stores write inside a transaction |
ping, unwatch | Pool connection checks; without them, each request opens a new connection |
client|setinfo | Client identification; denying it fills the ACL log |
A missing data command fails closed: the session store errors and CIBA denies
with elicitation.store_unavailable. With these users, stolen taint
credentials cannot forge an approver, and stolen CIBA credentials cannot clear
Session Taint labels. Neither user can read the other’s keys, list the
keyspace, or run commands outside its list.
Separate server
Use a standalone block to give CIBA its own Valkey server, endpoint, TLS settings, and credentials:
plugins:
- name: manager-approver
kind: elicitation/ciba
hooks: [elicit]
capabilities: [perform_http]
config:
backchannel_endpoint: https://kc/realms/corp/protocol/openid-connect/ext/ciba/auth
token_endpoint: https://kc/realms/corp/protocol/openid-connect/token
client_id: praxis-policy-gateway
client_secret_source: { kind: env_var, name: CIBA_CLIENT_SECRET }
store:
kind: valkey
endpoint: valkey-ciba.internal:6380
tls: true
username: ppe-ciba
password: { env: CIBA_VALKEY_PASSWORD }
Choose it when approvals need their own failure domain, noeviction policy,
retention, or backups, so a full taint store cannot evict pending approvals.
The standalone form takes the same settings as global.session_store. TLS is
required off localhost, and the default key prefix is ciba:v1.
Unauthenticated local Valkey
For a local server without AUTH, use a standalone CIBA connection with its own
endpoint: localhost:6379. A reference requires CIBA credentials and will
refuse an omitted password at configuration load.
Store failures
If Valkey is unreachable, times out, or returns undecodable data, the step
denies with elicitation.store_unavailable and JSON-RPC -32122 (“approval
state unavailable”) even with on_error: continue. The failure is neither an
unknown id nor an approval. The caller sees a generic reason. The backend
error is logged with alarm = "ciba_store_unavailable", the plugin, and the
operation. If a dispatch reached the OP before a store failure, the log also
includes the auth_req_id because the approver has already been prompted.
The -32122 details echo elicitation_id when dispatch produced one or the
request supplied one. It
identifies the failed flow, but does not guarantee a same-id retry. A failed
read before polling the OP can be retried after the store recovers. If the OP
approved a poll but the write of the resolved approver failed, the write may
or may not have persisted. When it did not, the OP has already spent the
auth_req_id; the approval is lost and a new elicitation is required. A
failed redemption during validate may also have consumed the approval. A
dispatch has no id yet, so retrying it may prompt the approver again.
A poll whose outcome is unknown also ends the flow. The checker holds a claim
on the id while it polls the OP. If that poll fails after it may have reached
the OP, returns an unreadable answer, or outlives its claim, the id is marked
uncertain and is never polled again, since the OP may have spent the
auth_req_id. A request cancelled mid-poll, such as a client disconnect or
replica shutdown, leaves its claim in place. Another check returns pending
(-32120) while the claim is live. If the poll never completes, the next check
after the lease expires marks the id uncertain and returns -32122; later
checks return -32122 until the approval expires. This can happen even when
the cancelled poll was never sent. An agent that receives -32122 repeatedly
for the same id should stop retrying it and start a new elicitation.
The pool connects on first use. An unreachable server, wrong credentials, or
a missing ACL grant may therefore first appear as -32122 on an approval.
Before taking traffic, check connectivity and credentials from the gateway
host using the endpoint, TLS setting, user, and password source configured for
CIBA in the shared-server example:
REDISCLI_AUTH="$(cat /run/secrets/ciba-valkey-password)" \
valkey-cli -h valkey.internal -p 6380 --tls --user ppe-ciba -e PING
Expect PONG. For a standalone store, use its configured endpoint and
password source instead. The ACL test in Testing checks the
data-command grants.
Durability
Single use holds only while Valkey keeps acknowledged writes. A redeemed
approval comes back if the server restarts from an older snapshot, or fails
over to a replica that had not received the delete. For approvals that must
not be replayed, run the CIBA store with appendonly yes and
appendfsync always, and without failover to an asynchronous replica. Use
noeviction so memory pressure drops new writes instead of pending
approvals. A restart that loses data fails closed: pending approvals read as
an unknown id.
Pipeline integration
require_approval(...) and its sibling verbs dispatch to a plugin implementing
the elicit hook, resolved by name off the route’s dispatch plan exactly like
delegate(...). Because elicitation is an explicit, sequenced effect — gated
behind authentication, checked on every retry, and validated before the forward
— a pending or unapproved operation never reaches the tool.
Next
- Session Taint: enforce information-flow controls across requests.
- Backend Restriction: constrain the backends eligible for a request.