/cookbook:human-in-the-loop-agentfrom cookbook
Start a durable agent run from TypeScript, see the exact tool call it wants to make, and approve or reject it before it happens. The agent only sends you a Slack DM.
Ships in cookbook. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
agents scopeBuild "Approve an agent action from a CLI" following https://developers.glean.com/cookbook/human-in-the-loop-agent
Use nonsecret inputs the user already supplied. Ask only for missing information needed by the selected recipe path, resolving dependent choices before continuing. Do not request credential values in conversation; use the recipe's documented secure sign-in or secret-entry path. Required questions for this recipe are:
Follow the selected authentication path. If OAuth is selected, run the recipe's shipped login command with its declared scopes. If the documented token path is selected, skip OAuth login and use that path's declared secure configuration. Keep sign-in and secret entry user-controlled. Do not implement or alter OAuth while setting up the recipe, and do not silently substitute a path when the documented one fails.
Run the step commands in one shell session, starting in the directory where the project should be
created. A cd in one step still applies to later steps, so do not repeat it. If your tool starts
each command in a fresh process, run each later command from the directory the earlier cd entered.
A step marked (new terminal) runs while an earlier step keeps running: start it in a new shell in
the starting directory, and run the steps after it in that shell.
Copy the project
npx -y [email protected] gleanwork/glean-cookbook/recipes/human-in-the-loop-agent human-in-the-loop-agent
Install and run the offline tests Run every later command from this directory in the same shell. The tests run the real SDK against local HTTP handlers; they don't sign in or contact Glean or Slack.
cd human-in-the-loop-agent && npm ci
npm test
Create the agent and paste its instructions
In Glean, open Agents from the left navigation and click Create agent. Auto mode is selected by default, and Builder Assistant opens beside the agent; you don't need it (if it asks you to describe the agent first, paste these instructions into it). Click the name at the top of the builder and rename it Cookbook approval demo. Replace any text under Instructions with the text this command prints.
cat agent-instructions.txt
Add the Slack tool In the Capabilities tab, under Tools, search for Slack Actions and add it. Under Write tools, keep only Send Slack message to user. Leave Allow agent to use write tools without approval unchecked: that checkbox is the approval boundary this recipe demonstrates. A spec file can't set this up for you, because it refers to Slack by a tool provider ID that is different on every Glean instance.
Set the trigger and publish In the Triggers tab, set When should the agent run? to Manually run and What type of input does it need? to Chat message. Click Publish. Until you publish, your edits are only a draft, and API runs use the published agent.
Copy the agent ID
Click Share at the top right of the agent. Under Publishing options, the API section shows the Agent ID with a copy button; use it as <agent-id> below. You don't need Create token there: the next step signs you in instead. The ID is also the 32-character value after /agents/ in the page URL.
Sign in
Complete browser sign-in yourself. glean-auth finds your Glean backend from your email and keeps a refreshable session outside this project, so a run can wait for you. If OAuth isn't available, copy .env.example to .env and set GLEAN_API_TOKEN to a user-scoped token with the agents scope instead. Never paste a token into a chat or a command.
npm run login -- --email "<work-email>"
Run the agent and decide
The command starts one durable run, waits for the agent to pause, and shows the tool, what it does, and its exact arguments. Type a to approve that one call (the DM arrives), r to reject it (nothing is sent), c to cancel the run, or press Enter to leave it waiting. If the run finishes without asking, the Slack tool isn't added, Allow agent to use write tools without approval is checked, or the agent wasn't published.
npm start -- --agent-id "<agent-id>" --email "<work-email>" --show-json
Run the command in this chat and report its concise result rather than reproducing routine install or debug output. Do not invent a browser URL. Then give the first verification action.
Follow the API calls
--show-json prints each API request and response body under the SDK call that sent it, so you can follow run_id and interaction_id from one call to the next. Leave it off to see only the review. The JSON includes the tool arguments, so keep it out of shared logs.
Pick a waiting run back up Closing the CLI or reaching the 120-second wait doesn't cancel the run; the CLI prints the full resume command, with the agent and run IDs. After a decision, a resumed run can take a few minutes to finish; if the wait runs out, resume again. Without a terminal to ask in, resume prints a decision command bound to the pending interaction ID; run it only after a person has reviewed that call.
Check approve, reject, and cancel
Approve one run and confirm exactly one DM arrives. Run the command again and reject; confirm no DM arrives and the agent says the message was not sent. Run it a third time, press Enter, then run the resume command it printed and cancel the run (c); it ends cancelled with nothing pending. Only Slack can show whether a message was sent.
npm start -- --agent-id "<agent-id>" --email "<work-email>" --show-json
Cookbook approval demo agent in Agent Builder when you're done. Nothing here deletes runs, messages, or agents.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub gleanwork/glean-cookbook --plugin cookbook19 skills in this plugin
/batch-retrieve-documentsRetrieve up to 100 indexed documents you can open in Glean, mixing document IDs and URLs. Documents Glean does not return are listed under warnings./browse-cookbookUse when the user asks what Glean cookbook recipes exist, wants to browse or pick a recipe to build, or asks "what can I build with Glean" — lists the available recipes and points to the matching /cookbook:{recipe-id} command./cookbook-conventionsShared setup, authentication, browser handoff, documentation lookup, Web SDK sizing, and visual conventions for Glean cookbook recipes./customer-360One page per account — status, risks, and a drill-in chat — assembled from whatever your instance already knows about that customer. No CRM export, no separate index./customer-meeting-prep-triggerRegister a calendar Trigger through the Platform Triggers API and deliver one signed event to a small receiver that prints a customer-meeting prep request./embed-search-chatPut permission-aware Glean search and chat directly inside an internal app with the Web SDK, so your team gets answers where they already work.