Ask for a change to an approval
Send one Approval back to the agent that asked, with the change you want: the Action keeps waiting until you answer the new request.
Name the Approval and the change, and your agent reads it back before it sends it back. The Action keeps waiting, and the agent returns a new Approval for the changed request, which you answer or refuse.
What you get
- 1the Approval you named, read back to you before anything is answeredApproval
- 1change sent to the agent that asked, on the ApprovalApproval
- 1new Approval for the changed request, waiting on youApproval
Your agent does
You, to your agent
Find a cheaper option, then I will decide.
Send it back with a smaller budget.
Change the request, then show me again.
# 1. Approval.get
RUN= $(uuidgen) # once per request; reuse it only to retry this request
curl https: //api.sb/ leaseline.app/ approvals/ approval_o2PM4EUAdC \
-H "Authorization: Bearer $SB_TOKEN"
# 2. Approval.requestChange
curl -X POST https: //api.sb/ leaseline.app/ approvals/ approval_o2PM4EUAdC/ requestChange \
-H "Authorization: Bearer $SB_TOKEN" \
-H "Idempotency-Key: ask-for-a-change-to-an-approval-leaseline.app-$RUN-2" \
-H "Content-Type: application/ json" \
-d '{"change": "Find a plan under $400 a month."}'
RUN= $(uuidgen) # once per request; reuse it only to retry this request
npx startup-builder do Approval.get --data '{"id": "approval_o2PM4EUAdC"}'
npx startup-builder do Approval.requestChange --data '{"approval": "approval_o2PM4EUAdC", "change": "Find a plan under $400 a month."}' --idempotency-key ask-for-a-change-to-an-approval-leaseline.app-$RUN-2
{
"name": "do",
"arguments": {
"code": "await $.Approval.get({ id: 'approval_o2PM4EUAdC' })\nreturn await $.Approval.requestChange({ approval: 'approval_o2PM4EUAdC', change: 'Find a plan under $400 a month.' })",
"idempotencyKey": "ask-for-a-change-to-an-approval-leaseline.app-<run>"
}
}
import { $ } from 'startup-builder'
const run = crypto.randomUUID() // once per request; reuse it only to retry this request
await $.Approval.get({ id: 'approval_o2PM4EUAdC' })
await $.Approval.requestChange({ approval: 'approval_o2PM4EUAdC', change: 'Find a plan under $400 a month.' }, { idempotencyKey: `ask-for-a-change-to-an-approval-leaseline.app-${run}-2` })
Change it
- Approve the new one.
- Refuse it instead.
- Show me what is still waiting.
Under the hood
- Systems
- Work queue
- Nouns
- Approval, Action
- Events
Approval.changeRequested