At 09:00, Leah, a finance analyst, asks a background agent to reconcile October invoices and payments for the North branch. It should match records by invoice reference and draft a report of unmatched entries. At 09:02, the agent requests payment records. A minute later, a finance administrator revokes access for this job. The connector response is already on its way. Does it reach the model? Can a retry make another read? Can Leah still open the report?
Treat permission to run the job, permission to continue it and permission to read its output as decisions the application can enforce. This is an illustrative design for a read-only workflow with an internal report. The same job would need separate authorization to update a payment or send the report outside the workspace.
Give the job a grant of its own
When Leah submits the request, the backend checks her eligibility to run a reconciliation for the specified workspace and branch. It creates job J-184 and a server-side grant for that job. The grant records Leah as the delegating user, the worker identity allowed to act, the workspace and North branch, the October reporting period, the permitted invoice and payment reads, and an absolute expiry. Set the deadline from the workflow’s time budget. A retry can use the remaining time on an active grant. Any extension requires fresh authorization.
Put the job ID on the queue. When a worker picks it up, it authenticates as a service and loads the stored job and grant. The model can propose an operation. The worker sends that proposal to a tool gateway under its own authenticated identity. Keep Leah’s session, connector credentials and grant record in server-side components. A job ID identifies the task. The gateway still needs proof that this worker is assigned to it.
Recheck access at the tool boundary
For each call, the gateway verifies the worker assignment, the open job and the grant’s current state and expiry. It checks Leah’s current finance access and compares the requested operation and records against the grant. Derive the branch and reporting period from the job. Apply those filters in the connector request where supported. Before returning data, verify that the connector belongs to the workspace and every returned record falls within the authorized branch and period. If the connector cannot establish that scope, withhold the records. The model needs invoice references, amounts, currencies and payment statuses for this report. Keep unrelated fields out of the model input.
| Request | Decision for job J-184 | Evidence to record |
|---|---|---|
| Read October invoices for North | Allow while the grant is active and Leah’s finance access remains valid. | Grant version, operation, authorized scope and outcome. |
| Read payments for South or a different period | Deny. | Requested scope and scope-mismatch decision. |
| Change a payment or send a report externally | Deny. | Requested operation and missing permission. |
| Retry an October payment read after revocation or expiry | Deny and stop retries for that grant. | Attempt ID and terminal reason. |
For a product that controls every route to a connector, an internal gateway and a durable grant are a practical starting point. Give the connector its own narrowly permissioned credential and restrict its use to the gateway. Where a separate API supports delegated OAuth tokens, give each token the audience and privileges for that API and a lifetime bounded by the remaining grant. The resource server needs to enforce its own audience and resource checks. OAuth token exchange alone defines no automatic link that revokes every derived token when an input token is revoked. Check the provider’s behavior and document where your application can enforce the task grant directly.
Decide what revoke can still stop
At 09:03, the finance administrator revokes the grant for J-184. Persist the new grant state and signal the worker to stop. Checks that observe the change deny further tool use and prevent a queued or redelivered attempt from resuming the job. If a policy cache is in the path, its freshness contributes to the time before revocation is enforced. For this job, check grant state directly at the critical boundaries and hold work when the authority source is unavailable.
The 09:02 read already reached the connector. It might still finish, even if the worker requests cancellation. When the response arrives at 09:04, the gateway reads the grant again before passing the records to the worker. With the grant revoked, it drops the payload and records the denied handoff. If records reached the model before the revoke, the application cannot take them back from that call. It can still stop further tool use and withhold the draft.
Make revocation an acceptance test
Use synthetic invoice and payment records for two branches. Pause a connector response after dispatch, revoke the job, then release the response. Check that the payload never reaches the model, a redelivered job performs no new connector read and the interface shows the revocation. Repeat with expiry while queued, with removal of Leah’s finance role, and with an unavailable authorization service. For the release race, run both orderings and assert that a revoked draft stays private when revoke wins and that a subsequent role change blocks the next view when release wins.
Before rollout, have the product team agree which access changes should stop a job and what the user should see. Give the backend owner responsibility for grant checks and results, and the connector owner responsibility for cancellation behavior, scoped credentials and remaining in-flight work. Record where each decision happens and test the interval between revoke and the last possible admitted call from that boundary.
If you’re adding this to a product your team already operates, start with one queued workflow and trace it from the requester to the final report. The guide to integrating an agent into an existing SaaS covers the broader rollout, and the AI agent development page describes the integration work. If your team needs an engineer to own this boundary across the queue, connector and product, get in touch.