approval workflow - kongusen/loom-agent GitHub Wiki
Use this pattern when the agent prepares or checks an action, but a human or external system must approve the final step.
- structured multi-step flow
- continuity across requests
- explicit approval boundary
- tool and safety configuration that reflects workflow stages
from loom import Agent, Model, RunContext, Runtime, SessionConfig
agent = Agent(
model=Model.anthropic("claude-sonnet-4"),
instructions=(
"Prepare operational changes, summarize risk, "
"and wait for explicit approval before irreversible actions."
),
runtime=Runtime.supervised(criteria=["irreversible actions require explicit approval"]),
)
session = agent.session(SessionConfig(id="deploy-request-42"))
draft = await session.run("Prepare a production deployment plan for version 2.3.0")
review = await session.run(
"Summarize risks and list the required approval step",
context=RunContext(inputs={"draft_plan": draft.output}),
)
approved = await session.run(
"Produce the final approved action summary",
context=RunContext(
inputs={
"draft_plan": draft.output,
"review_summary": review.output,
"approval_state": "approved",
"approved_by": "release-owner",
}
),
)Treat approval as explicit runtime input, not an implicit assumption.
That keeps the workflow auditable:
- preparation happens in earlier runs
- approval state is passed explicitly
- the application can decide whether to unlock downstream capabilities
- keep approval state in
RunContext.inputs - create one session per approval object or request
- use
Runtime.supervised(...)for review-heavy flows - attach knowledge if approval depends on policy documents