Skip to content

Migrating from HumanLayer's deprecated approvals SDK to DueReason

HumanLayer's require_approval and human_as_tool approvals SDK is deprecated by its own README. Move the same check to DueReason's withApproval().

Updated · 8 min read

In short

  • HumanLayer rebuilt itself as a coding-agent workspace; the repo that shipped its require_approval decorator and human_as_tool is now a frozen legacy branch whose own README calls the code "pretty much all deprecated".
  • The decorator's job - block a function until a person decides, then let the agent continue or see why it was refused - maps directly onto @duereason/sdk's withApproval(), which wraps the same kind of function.
  • The two differ in what happens after someone clicks approve: DueReason verifies a signed, single-use grant against the exact payload before your code runs, so a changed amount or target is refused rather than trusted.
  • Moving over is mostly a reshuffle: give the thing you already gate an action key, a title and a reason, describe the payload you will execute, and set how long a call should wait.

If you built on HumanLayer's @hl.require_approval() decorator or human_as_tool, you may already know they are no longer maintained. HumanLayer's own public repository says so directly: its README reads "the code here is pretty much all deprecated - you can try the rebuild of humanlayer at humanlayer.com". The company moved on to a coding-agent workspace product; the approvals SDK, its Slack and email contact channels, and its old docs pages were left behind on a legacy-final tag. If that is what brought you here, this walks through moving the same human-in-the-loop check to @duereason/sdk's withApproval().

What the old decorator did

HumanLayer's approach was a Python decorator around a function your agent could call as a tool. From its own PyPI listing:

```python from humanlayer import HumanLayer hl = HumanLayer()

@hl.require_approval() def send_email(to: str, subject: str, body: str): """Send an email to the customer""" ... ```

Calling send_email paused for a person to approve or reject it over whichever contact channel the client was configured with (Slack or email, by default), and only ran the function body once they said yes. There was no separate verification step: the decorator asked, waited, and called the function - the approval and the execution were the same trust boundary.

The same shape in DueReason

withApproval() wraps a function the same way, but splits "someone agreed" from "the exact thing they agreed to is what runs" into two checks instead of one:

```js import { createClient, withApproval } from "@duereason/sdk";

const duereason = createClient({ apiKey: process.env.DUEREASON_API_KEY });

// Called with { to, subject, body }, by your code or by an agent. export const sendEmail = withApproval( duereason, { action: "customer-email", organization: "acme", title: (input) => "Email to " + input.to + ": " + input.subject, reason: "Drafted for a customer reply; approve to send as written.", payload: (input) => ({ to: input.to, subject: input.subject, body: input.body }), agent: { name: "support-agent" }, timeoutMs: 15 * 60 * 1000, }, // Runs only once approved, with the payload the grant was verified against. (input, { payload }) => mailer.send(payload), ); ```

Line for line: the decorated function becomes the third argument, fn; what used to be implicit (which channel gets asked, what they see) becomes explicit fields - action names the kind of decision so it routes to the right approvers, title and reason are what they read before deciding, and payload is exactly what fn is executed with. organization and timeoutMs replace the client-level configuration HumanLayer read from its contact channel setup.

What changes, not just what moves

  • A grant, not just a yes. Once approved, DueReason issues a signed, single-use token bound to a hash of payload(input). withApproval() verifies it before fn runs and throws GrantVerificationError if the payload changed in the meantime - the old decorator had no equivalent check between "approved" and "executing".
  • Typed rejections your agent can read. A rejection, expiry, cancellation or timeout all throw NotApprovedError with a status your agent's error handling can branch on, and a message written to tell a model not to retry the same request for a different answer.
  • Execution is reported, once. withApproval() reports the outcome back to DueReason as succeeded or failed after fn runs, so the grant cannot be replayed into a second send, payment or deploy.
  • Approvers see more than a channel ping. Title, reason, the payload and who is asking all show up in the console with similar past decisions alongside the request, rather than only in whatever message the contact channel rendered.

Moving a decorated function over

  1. Pick an action key for what the function does (customer-email, payment, deployment) - actions are what workflows and approver groups attach to in DueReason's console, in place of a contact channel.
  2. Turn the function's parameters into a payload: a plain function of the input that returns exactly what will be executed, matching the shape fn needs.
  3. Write title and reason as strings or functions of the input - the reason is what approvers decide on, so keep it specific instead of a generic "approval needed".
  4. Choose a timeoutMs for how long one call should wait; the request expires at the same time if nobody answers (60 seconds to 7 days).
  5. Replace the decorated function body with the third argument to withApproval() - it receives (input, { payload, grant }), so execute payload, the values the grant was verified against, not the raw input.
  6. Catch NotApprovedError and GrantVerificationError where you previously handled a rejection, and ExecutionNotRecordedError for the case where fn succeeded but reporting it failed - do not run it again when you see that one.

guard() is the same wrapper for a single call whose payload you already have in hand, when you would rather not build a reusable tool - useful for a one-off migration such as a release script's deploy step.

What has no direct equivalent

DueReason has no human_as_tool-style helper for letting an agent ask an open-ended question outside an approval flow; every request is for a defined action with a payload schema, which is also what makes the resulting grant something an executor can verify offline. If your agent used human_as_tool purely to ask a free-text question rather than to gate an action, that is a different problem from what withApproval() solves, and keeping a lightweight messaging integration for it alongside DueReason for anything consequential is a reasonable split.

Questions

Is HumanLayer's approvals SDK really gone, or just unmaintained?
Its own public repository's README (on the legacy-final tag, where require_approval and human_as_tool last lived) says the code there is pretty much all deprecated and points to a rebuilt product at humanlayer.com instead. The main branch today is a coding-agent workspace with no approvals decorator in it.
Does DueReason keep my payload private, or does it leave the EU?
Request data, payloads and evidence stay in the region you deploy in; Slack, Teams, email and push notifications carry only a title and a link back to the console by default, not the payload or the reason, specifically so that data does not have to leave with a notification. Showing more in a channel is an explicit, owner-only opt-in.
What does this cost during the beta?
DueReason is free today for one organization with up to five members, with all core features available; a yearly license key lifts those limits, verified entirely offline with no phone-home and applied in Settings > License. See the self-hosting guide for the no-SLA, self-run path if you would rather not use the hosted product at all.
Can I self-host instead of using the hosted product?
Yes. Self-hosting runs on one Postgres database and one pre-built image you run with Docker Compose, with no repository to clone; withApproval() talks to a self-hosted deployment exactly as it does to the hosted one, since both speak the same API.
Do I have to rewrite my agent in TypeScript to use withApproval()?
No. @duereason/sdk is the TypeScript client, but the API it calls is plain HTTP, so a Python agent (like one built on HumanLayer's old SDK) can request approval, wait for the decision and verify the grant directly against the API without adopting TypeScript; the SDK just makes that easier from Node.

Move your approval gate to DueReason

Create an account and an API key, then point withApproval() at the action you already gate - no contact channel to reconfigure.

Create your account

Sources

This guide explains the regulation as we read it; it is not legal advice. Check the official text and your national law, which may add obligations.

Start with DueReason

Create a free account, try it live, or talk to us about your workflow.

Get product updates