Use a key from an agent

The command an agent runs, the reason it gives, what the command gets, and what each exit code means.

An agent uses a key by naming it in front of a command:

laze vault run posthog-read --reason "Count sign-ups from last week for the weekly report" -- python report.py

The command runs with the key's fields as environment variables. Several keys go in one run, and so on one card:

laze vault run posthog-read stripe-readonly --reason "Match sign-ups to the first payments of November" -- python match.py

laze vault list shows an agent the keys it may use, with names and levels and no values.

The reason

With every use the agent writes one plain sentence that says what the command does and why. It is the first thing the person approving reads, and the automatic check compares it with what you asked for. The sentence has 4 words to 200 characters and no command in it. If it does not fit, the run exits with code 2.

What the command gets

Where the agent runsWhat the command holds
A Laze computerA placeholder. The real key is put in on Laze's network, on the way to a site approved for the key
Your own machine, connected to LazeThe value, in that one command's environment. Its output is redacted
A session outside Laze, such as your terminalThe same as a connected machine

The output of the command is checked before the agent reads it, so a value the program prints is hidden. Sites a key is sent to covers the placeholder and the keys that go out as values.

Who the agent works for

A use counts as the person who asked, and the level is decided for that person. A schedule runs as whoever created it. A message from someone else in the thread is not permission, even when it says so.

Subagents and background work that an agent starts in a turn use the same keys, for the same person. Outside a turn, a computer holds nothing usable: placeholders work only while one of the agent's turns is running.

Answers

Exit codeMeaningWhat an agent should do
0The command ranGo on
2The reason is not one plain sentenceWrite one and run again
75Still waiting for a person, or the vault is busyRun the same command again; it joins the same card
77DeniedRead the note and do something else
127The command was not foundFix the command

A card waits a day. The run waits with it; --wait 60 stops earlier with code 75, and the card stays.

Save a key the agent made

An agent that creates a secret, such as a webhook signing key, offers it to its owner. The value goes in on standard input.

openssl rand -hex 32 | laze vault offer webhook-signing --field WEBHOOK_SECRET --reason "Signs the webhook I just set up for the shop"

You get a card with Allow and Deny. When you allow it, Laze saves the key in your keychain at Always ask. When you deny it or do not answer, Laze deletes the value.

Ask for a key

When no key fits, the agent asks for one by name, with the site it is for:

laze vault ask hubspot-login --why "Sign in to export the deals" --host app.hubspot.com

The card reads "Scout needs a key for app.hubspot.com: Sign in to export the deals" and holds a masked field. Paste the value and press Save to my vault. Laze saves it in your personal keychain as hubspot-login at Always ask, with the rule "Only for app.hubspot.com". The value goes from the field to the vault, never to the agent. The agent hears only the name and uses it with laze vault run hubspot-login or laze browser login <tab> --vault hubspot-login. The iPhone app shows the same field on the card.

For a team agent the button is Save and share: the key lands in your keychain, and the agent gets it after you share it with your passkey.

To ask for a key someone already has, laze vault request-key --for "..." posts a card where people pick one of their own. See Team agents and keys.

Sign in to a website

With a saved sign-in, an agent types it into a browser tab you can see, when you tell it to:

laze browser login <tab> --vault <key>

The value goes from the vault to the page, and the agent's model does not read it.

Run on your own machine

laze machine exec <machine> --vault <key> --reason "..." -- <command> runs a command on a machine you connected, with the key in its environment there.

When a computer sleeps

Nothing is lost. Placeholders stay the same for the life of the computer and stop working while it sleeps, keys stay in the vault, and a card that was open stays open. The agent picks up the answer when it wakes.

Also check: Approve a request, Vault CLI, Hosted agents.