Human Decisions
Overview
The human() protocol asks a person to decide about a step. The person sees the step and chooses to approve it, reject it, or end the sample, and their answer becomes the protocol’s decision.
Usually you don’t want a person asked about every step. A rule or a monitor settles the clear cases and escalates the steps it is unsure about. With human() after it in a sequential(), the person is asked only about the escalated steps. When there is nobody to ask, handle_escalation() answers escalations with a fixed policy instead.
Asking a Person
human() takes the stages to ask at. The stages are given as strings, which correspond to the stages a protocol can run at:
| String | Stage | The person decides about |
|---|---|---|
"tool_call" |
BeforeToolCall |
A tool call, before it runs. |
"tool_result" |
AfterToolCall |
A tool call’s result, before the agent’s model receives it. |
"model_input" |
BeforeGenerate |
A request to the agent’s model, before it is sent (see Model Requests). |
"model_output" |
AfterGenerate |
A whole assistant turn, before the agent acts on it (see Whole Turns). |
stages is required, and you can give several. On its own, human(stages=["tool_call"]) asks about every tool call, like Inspect’s human approver.
To ask only about some tool calls, put human() at the end of a sequential() after a rule that escalates. Here is examples/escalate_to_human.py:
examples/escalate_to_human.py
from example_samples import ADD_HOST, CLEANUP, COUNT_ROWS
from inspect_ai import Task, task
from inspect_ai.agent import react
from inspect_ai.tool import bash, python
from inspect_sentinel import (
BeforeToolCall,
Context,
Decision,
Escalations,
Protocol,
call_text,
find_words,
human,
protocol,
sequential,
tool_matches,
)
DELETE_WORDS = ["rm", "rmdir", "-delete", "shutil.rmtree", "os.remove"]
@protocol
def triage() -> Protocol:
async def decide(
context: Context,
step: BeforeToolCall,
escalations: Escalations,
) -> Decision | None:
if not tool_matches(step.call, "bash", "python"):
return Decision.proceed()
text = call_text(step.call)
if "/etc" in text:
return Decision.reject(
"call mentions /etc",
message="`/etc` is off limits; work only under /work.",
)
deletes = find_words(text, DELETE_WORDS)
if deletes:
return Decision.escalate(f"call deletes files ({', '.join(deletes)})")
return Decision.proceed()
return decide
@task
def escalate_to_human() -> Task:
return Task(
dataset=[CLEANUP, ADD_HOST, COUNT_ROWS],
solver=react(tools=[bash(timeout=60), python(timeout=60)]),
sandbox=("docker", "compose.yaml"),
message_limit=20,
sentinel=sequential([triage(), human(stages=["tool_call"])]),
)- 1
-
A tool call that mentions
/etcis rejected without asking anyone. - 2
- A tool call that deletes files is escalated, with an explanation the person will see.
- 3
-
Every other tool call proceeds. Returning
Nonehere instead would pass the tool call on tohuman(), and the person would be asked about it too. - 4
-
human()runs only whentriage()escalates.
Run it from the repository root:
inspect eval examples/escalate_to_human.py --model openai/gpt-5-miniWhen the agent tries to delete files, the eval pauses and asks you to approve, reject or terminate. The prompt shows the tool call and that triage escalated it because the tool call deletes files. The eval waits for each answer, so run it where someone can answer.
Choices
choices sets what the person may pick. The defaults depend on the stage:
| Stage | Default choices |
|---|---|
"tool_call" |
approve, reject, terminate |
"tool_result" |
approve, terminate |
"model_input" |
approve, terminate |
"model_output" |
approve, terminate |
reject is offered only before a tool call (see Actions), and rejecting a request or a whole turn is not supported. Offering a choice a stage doesn’t allow raises an error when human() is created. "modify" is accepted before a tool call, but Inspect’s approval channels cannot edit a tool call, so offering it raises an error when the person is asked. Your own review tool cannot be offered "modify" yet either.
The answer maps to a decision: approve to proceed, reject to reject, and terminate to terminate. The reason recorded with the answer becomes the decision’s explanation, and on a reject it is also the message the agent receives. The person doesn’t enter a reason: the approval panel and console record a fixed text, such as “Human operator rejected the tool call.”, and an ACP client (an editor or tool that speaks the Agent Client Protocol) records none, so the agent is told “Tool call not approved.”
Whole Turns
At "model_output", the person decides about a whole assistant turn: its text and every tool call it makes, before any of the tool calls run. Use it when the combined effect of several tool calls matters. Approve lets the turn proceed unchanged, and terminate ends the sample.
examples/escalate_turn_to_human.py escalates any turn whose tool calls delete files:
Task(..., sentinel=sequential([turn_triage(), human(stages=["model_output"])]))Its turn_triage() rule runs at AfterGenerate. It reads the tool calls from step.output.message.tool_calls and escalates the turn, saying how many of them delete files. Run it with:
inspect eval examples/escalate_turn_to_human.py --model openai/gpt-5-miniModel Requests
At "model_input", the person decides about a request before the agent’s model is sent it. Use it when what reaches the model matters, such as a tool’s output or a document the agent read. Approve sends the request, and terminate ends the sample without sending it. The person sees the request before any on_before_model_generate hook runs, so a hook that changes requests changes this one after it is approved.
The person is shown how many messages the request sends, the tools it offers and which the model must call, and each message the model has not been sent before. That includes a message the scaffold rewrote since it was sent, and an assistant message the scaffold wrote itself, wherever they are in the request.
The prompt has limits. A message the model was sent before is not shown again, even if it has moved, and neither is the fact that one was removed. A message that repeats an earlier one, such as an agent’s fixed prompt to continue, is shown when the request holds more copies of it than any request the model was sent before. Images and other content that is not text are counted, not shown. Tools are shown by name, without their descriptions or parameters. Inspect’s TUI shows the first lines of a long prompt, so expand it to read the rest before deciding. The console and the approval panel show no other part of the conversation. The eval’s log has the earlier requests, so the messages sent before can be read there. It has this request only once it is sent.
Task(..., sentinel=sequential([request_triage(), human(stages=["model_input"])]))Here request_triage() stands for a rule of your own at BeforeGenerate: it reads the request from step.input and escalates the ones a person should see. On its own, human(stages=["model_input"]) asks before every request.
What the Person Sees
The person is asked through Inspect’s human approval channels: an attached ACP client, the approval panel in the full-screen display, or the console otherwise (for example, with --display plain). The prompt shows the tool call, the escalations that led to it, and, after a tool call, its result. At "model_output" it shows the turn’s text, the escalations, and each tool call as a numbered code block. At "model_input" it shows the escalations, the tools offered, and each message not sent before as a numbered code block.
Characters that change how text displays, such as terminal escape sequences and zero-width characters, appear in the prompt as a marker of their code point, such as ‹U+001B›.
Your Own Review Tool
If your team already has a tool for reviewing agent actions, such as a web app or a chat bot, human() can ask through it instead of Inspect’s approval channels. For example, you might want to:
- Keep using the review interface your team already knows.
- Show reviewers every monitor’s score, or your own rendering of a turn.
- Let reviewers type the reason the agent is told on a reject.
Pass the tool as channel, an async function that takes a HumanQuestion and returns the person’s HumanAnswer. Here review_desk stands for your team’s client for its review tool:
from inspect_sentinel import HumanAnswer, HumanQuestion, human, sequential
async def ask_review_desk(question: HumanQuestion) -> HumanAnswer:
ticket = await review_desk.open(
stage=question.stage,
sample=question.eval.sample_id if question.eval else None,
escalations=[
(e.name, e.report.explanation, e.report.metadata)
for e in question.escalations
],
choices=question.choices,
)
decision, reason = await review_desk.wait(ticket)
return HumanAnswer(decision, reason)
Task(
...,
sentinel=sequential(
[triage(), human(stages=["tool_call"], channel=ask_review_desk)]
),
)human() works as before at every stage. The only difference is who asks the person.
The Question
The HumanQuestion holds what the person needs to decide:
| Field | Holds |
|---|---|
stage |
"tool_call", "tool_result", "model_input" or "model_output". |
step |
The step itself: a BeforeToolCall with the tool call, an AfterToolCall with the call and its result, a BeforeGenerate with the request about to be sent, or an AfterGenerate with the whole assistant turn. See Stages for their fields. |
escalations |
Each escalation that led here, with the name of the protocol that escalated and its full report: the explanation, references and metadata. A threshold() escalation lists every monitor’s score and explanation in metadata["observations"]. Empty when nothing escalated. |
choices |
What the person may pick, from approve, reject and terminate. |
eval |
The task and sample being run (e.g. eval.sample_id, eval.epoch), so your tool can say which sample is waiting. |
proxy |
When the sentinel runs beside a proxy, what the proxy says about the request; otherwise None. |
The step and the explanations hold text the agent wrote, so show them as text in your tool, not as markup.
The Answer
Return a HumanAnswer with one of the choices and, optionally, the person’s reason. The answer becomes a decision as described in Choices, so the reason is recorded as the decision’s explanation, and on a reject the agent receives it as the message. The answer is recorded in the log and appears in step.human_decisions at later steps exactly like an answer given in Inspect’s approval panel.
If your tool can’t reach anyone, answer terminate with a reason that says so. terminate is accepted even when it isn’t among the choices.
If the function raises an error, returns something other than a HumanAnswer, or answers a choice it wasn’t offered, the sample fails with an error that names the function, before the step proceeds. (In a sentinel sidecar, the proxy’s own setting decides instead; see Limits.)
Waiting and Cancelling
The eval waits as long as your tool takes. The wait doesn’t count toward the sample’s working limit, but a time limit still applies. There is no timeout of its own. To stop waiting after a while, answer for the person:
async def ask_review_desk(question: HumanQuestion) -> HumanAnswer:
ticket = await review_desk.open(...)
with anyio.move_on_after(30 * 60):
decision, reason = await review_desk.wait(ticket)
return HumanAnswer(decision, reason)
return HumanAnswer("terminate", "Nobody answered within 30 minutes.")The wait is cancelled if the sample is cancelled or reaches its time limit, or if another protocol in the same concurrent() ends the sample first. Nothing is decided then. Withdraw the question from your tool when that happens, so nobody spends time on a question that no longer matters. Cleanup that awaits needs a shielded cancel scope:
async def ask_review_desk(question: HumanQuestion) -> HumanAnswer:
ticket = await review_desk.open(...)
try:
decision, reason = await review_desk.wait(ticket)
except anyio.get_cancelled_exc_class():
with anyio.CancelScope(shield=True):
await review_desk.withdraw(ticket)
raise
return HumanAnswer(decision, reason)Naming the Tool in a Configuration File
The function must be defined at module level in a module or a .py file, because the log records it by name and eval_retry() and replays find it again by that name. A function defined inside another function, or typed into a REPL, a notebook or python -c, raises an error when human() is created. A function in a script you run with python is recorded by the script’s path, and a retry or a replay in another process runs the script’s top-level code again to find it, so keep the code that runs the eval under if __name__ == "__main__":.
A file’s path is recorded relative to the working directory when human() is created. For a sentinel made in a task file, that is the task file’s directory, since Inspect changes into it while it loads the task, and a retry looks for the file from there again. Until an inspect_ai fix expected in 0.3.293 is released, eval_retry() and inspect eval-retry look for it from the directory you run the retry in instead: a task file in another directory (inspect eval tasks/review_task.py) whose channel is a function in it, or a file beside it named by its path, is not found on retry. To avoid it, name the function by a module that imports where the retry runs (an installed package, or one on the Python path), rather than by a file’s path:
human(stages=["tool_call"], channel="review_tools:ask_review_desk")A function you pass from such a module is recorded by the module’s name in the same way.
With an inspect_ai fix expected in 0.3.293, a retry looks for a relative file next to the task file first, and then in the directory the retry runs in. So a sentinel passed to eval() or --sentinel, whose file paths are relative to where you ran the eval, is found too when you retry from there. If both places have a file with that name, the one next to the task file is used. Naming the function by module avoids any ambiguity.
In a configuration file, name the function as module:function, where the module can also be the path of a .py file:
human.yaml
sentinel:
name: sequential
children:
- name: triage
- name: human
params:
stages: [tool_call]
channel: review_tools:ask_review_deskLimits
Your tool is never asked during a replay. A replay gives the answer recorded when the eval ran, or the fixed answer or stand-in you pass to as_scanner(), as it does for any human(). The module that defines the function must still be importable where you run the scan, because the replay builds the sentinel from its configuration. Your tool cannot be offered "modify" yet.
When the sentinel runs in a sentinel sidecar beside a proxy, the agent’s model call stays open while your tool waits, and the wait counts toward the sidecar’s judging timeout. For long waits there, let the sidecar ask through the eval instead. The wait is cancelled when the eval ends the sample, or when a sentinel ends the agent’s run (for example its session, when the sidecar names runs by a header). Otherwise a person could spend time on a question that no longer matters, and since the sidecar runs for a long time, a wait whose run had ended would never end, and one more would pile up for every run that ends mid-question. If your tool raises an error in the sidecar, the call isn’t judged, and the proxy’s own setting decides whether it goes ahead, as for any error in the sentinel.
A Person Beside Other Protocols
The person’s answer is an ordinary decision. At the end of a sequential(), it decides for the chain, as any child’s decision does.
In a concurrent(), which is what a list or mapping passed to Task(sentinel=...) becomes, the person’s answer is one decision among the others. Another protocol’s reject outranks the person’s approve, and the person’s reject or terminate outranks a weaker decision. A human() in a concurrent() is asked about every step at its stages, so use a sequential() to ask only about escalated steps.
Earlier Decisions
Later steps of the same agent can see what a person decided. step.human_decisions lists each earlier answer as a HumanDecision, with the stage it was made at, the tool calls it covered and the decision. human_decision_for(step, call_id) finds the latest one covering a given tool call.
An LLM monitor can use these records to mark tool calls a person already reviewed, so the monitor model does not flag them again. See LLM Monitors for an example and for what these records do and do not mean.
Handling Escalations
An escalation that reaches the top of the sentinel has no protocol left to decide it. The sentinel treats this as a configuration error and ends the sample with a terminate in place of the escalation. The explanation names where each escalation came from and why, for example unhandled escalation from triage: call deletes files (rm), followed by how to handle it.
In the log, the decision recorded at the top of the sentinel stays the escalate, which tells an unhandled escalation apart from a protocol’s own terminate. The sample is not recorded as an error.
A rule that escalates on its own reaches the top this way. So does a sequential() with nothing at the end to answer its escalations, since a chain in which every decision escalated returns the last escalation.
To say what an escalation should mean, end the chain with human() or with handle_escalation(), which applies a fixed policy:
from inspect_ai import Task
from inspect_sentinel import handle_escalation, sequential
Task(..., sentinel=sequential([triage(), handle_escalation("terminate")]))handle_escalation() takes one required argument:
| Action | Effect |
|---|---|
"terminate" |
End the sample when the step was escalated. |
"proceed" |
Let an escalated step proceed. The configuration and the log then record that unsure steps are allowed through. |
There is no "reject", since reject is allowed only before a tool call. handle_escalation() decides only when it receives escalations and abstains otherwise. Its explanation names each escalation it handled, such as escalated by triage: call deletes files (rm).
After a human(), handle_escalation() covers the stages the person is not asked at. In this sentinel, rule() stands for a protocol that may escalate before or after a tool call. The person is asked before a tool call, and an escalation after one ends the sample:
sequential([rule(), human(stages=["tool_call"]), handle_escalation("terminate")])