AIYINGFrom AI Awareness to Accomplishment
Showing posts with label Builder Lab. Show all posts
Showing posts with label Builder Lab. Show all posts

Saturday, November 28, 2026

Pause an AI Agent for Human Approval With LangGraph

AGENTING · Builder Lab

By Ravindra Dastikop

An agent drafts an email asking a client to move a meeting. The date is wrong. Can the reviewer stop the workflow before it reaches the send step?

LangGraph lets you build that decision into the workflow. In this lab, a preset draft stands in for an agent’s output. The graph pauses, waits for a reviewer’s decision, then either simulates a send or closes the run.

Check access

Availability checked on 28 November 2026. LangGraph 1.2.24 was published on 20 November. You can install it locally from PyPI. This demo uses a preset draft and a simulated send, so the only service you need to reach is PyPI during installation.

LangGraph releases · LangGraph 1.2.24 on PyPI

Build the approval step

In a Python virtual environment, run python -m pip install "langgraph==1.2.24". Save the code as approval_demo.py and run python approval_demo.py.

from typing import Literal, TypedDict

from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import END, START, StateGraph
from langgraph.types import Command, interrupt


class State(TypedDict, total=False):
    draft: str
    outcome: str


def review(state: State) -> Command[Literal["simulate_send", "__end__"]]:
    approved = interrupt({"draft": state["draft"]})
    if approved is True:
        return Command(goto="simulate_send")
    return Command(update={"outcome": "Rejected"}, goto=END)


def simulate_send(state: State) -> dict:
    return {"outcome": f"Simulated send: {state['draft']}"}


builder = StateGraph(State)
builder.add_node("review", review)
builder.add_node("simulate_send", simulate_send)
builder.add_edge(START, "review")
builder.add_edge("simulate_send", END)
graph = builder.compile(checkpointer=InMemorySaver())

config = {"configurable": {"thread_id": "approval-demo"}}
paused = graph.invoke(
    {"draft": "Could we move our meeting to Tuesday at 3 p.m.?"},
    config,
)
print("Review request:", paused["__interrupt__"][0].value)

answer = input("Approve? Type yes or no: ").strip().lower()
result = graph.invoke(Command(resume=(answer == "yes")), config)
print(result["outcome"])

interrupt() pauses execution and gives the reviewer the draft. The second call uses the same thread ID to resume that run. Only an explicit yes reaches the simulated send step.

LangGraph restarts the review node from the beginning on resume, so keep actions such as sending an email out of the code before interrupt(). The in-memory checkpointer is suitable for this exercise while the script is running. Use a persistent checkpointer if a reviewer needs to resume after the process exits.

LangChain documentation — Interrupts

Test approval and rejection

  • Run 1. Type no. The output should say Rejected.
  • Run 2. Restart the script and type yes. The output should start with Simulated send: and include the draft you reviewed.
  • Run 3. Restart the script and press Enter. The output should say Rejected. A blank response should never count as consent.

Try the same design on another workflow. Pick the exact action that needs approval, then decide what the reviewer needs to see before saying yes.

AGENTING · Accomplish with Agent

Build an n8n Calculator Agent: Three Tests for Your First Tool Call

AGENTING · Builder Lab

By Ravindra Dastikop

Ask an AI agent for 18% of 2,450 and it may give you the right answer. How do you tell whether it used the calculator you connected? In this n8n lab, faculty and engineering students check both the answer and the action that produced it.

What you need

Availability checked on 28 November 2026. n8n published stable release 2.49.6 on 25 November. This lab uses the free, self-hosted Community edition and the built-in Calculator tool. You need access to a running n8n installation and a chat model that supports tool calling. If you use a hosted model API, your provider may charge for usage.

n8n releases · Community edition documentation

Build the workflow

  1. Create a workflow and connect Chat Trigger → AI Agent.
  2. Attach a compatible chat model to the AI Agent’s Chat Model connector and configure your model credentials.
  3. Attach Calculator to the AI Agent’s Tool connector. Put the instructions below in the agent’s System Message.
  4. Open the workflow’s test chat. Run each question on its own so earlier messages cannot supply a missing number.

Help students with basic percentages. If a question asks for a numerical result and supplies all required values, call Calculator and use its result. If the student asks for a definition, explain it directly. If a required value is missing, ask for that value before calculating. Use only the values the student supplies.

Run three tests

Ask Expected behaviour
What is 18% of 2,450? Calls Calculator and returns 441.
What does percent mean? Explains “per hundred” without a tool call.
What is 18% of the total? Asks for the total before calling Calculator.

Inspect the tool call

Open the AI Agent’s execution details for each test and look for Calculator activity. For the first question, check whether the tool received the intended calculation and returned 441. For the other two, check that the agent answered or asked a follow-up without calling Calculator.

Give students two marks per test. Award one for the response and one for the action. An answer of 441 with no Calculator call earns one mark. This makes it easy to discuss what you would miss if you graded only the final answer.

n8n documentation — AI Agent · n8n documentation — Calculator

AGENTING · Accomplish with Agent

Accomplish with AI

Powered by Blogger.

Featured post

Use ChatGPT Work to Compare Weekend Classes Before You Enrol

AGENT ING · Personal Agenting By Ravindra Dastikop You want to take a weekend photography class. One provid...

Search This Blog

List of blogs

Search This Blog

About

Translate

Instant Stories

Read in Your Language

Test

share this

ShareThis

Popular Posts