Answer a human step
Open a human step when a person must decide before your pipeline goes on, such as before it ends with new tickets or a code change. In this guide you write reviewed_intake, a pipeline that plans the tickets as intake does and asks a person to approve them with cb.human_step before it returns them. You answer its human step twice: in the terminal of codeband run, and with codeband answer from another terminal. At the end, the first run prints ✓ approve#0 answered by your user name and the paths of its two ticket files, codeband answer prints why the run rejected the answer "maybe", and the second run ends with stopped: a person rejected the tickets of Release 1.3. If a command fails, see Troubleshooting at the end of this page.
Before you start
Section titled “Before you start”- You built
intakein the tutorial Build a pipeline that files tickets, and your terminal is in its folderpy-factory. Run each command there. codeband devdoesn’t run. If it still runs from the tutorial, press Ctrl-C in its terminal.- jq for the check at the end, as
jq --versionshows.
How a run waits at a human step
Section titled “How a run waits at a human step”A human step is a step, like a function step. Its first call in a run writes the question to the run journal, the run’s status becomes waiting, and nothing runs until a person answers. The code server checks each answer against the human step’s answer type. The run journal records the first answer that the code server accepts, with the user who gave it, and the pipeline goes on with that answer.
-
Add a human step to a pipeline
Save this file as
py_factory/review.py:py_factory/review.py """The pipeline reviewed_intake: intake with a human step before the run ends with its tickets."""import codeband as cbfrom py_factory.planning import plan_tickets@cb.pipelinedef reviewed_intake(title: str, body: str) -> cb.RunResult | None:"""Plan one ticket per Markdown bullet of the request body, and end with them after a person approves them."""plan = plan_tickets(title, body)if not plan.tickets:raise cb.Stop("the request has no tickets: write each one as a '- ' bullet")titles = "; ".join(ticket.title for ticket in plan.tickets)question = cb.Question(text=f"File these tickets for {plan.title}? {titles}")if not cb.human_step("approve", question, answer=bool):raise cb.Stop(f"a person rejected the tickets of {plan.title}")return cb.RunResult(tickets=[cb.NewTicket(title=t.title, body="", tags=[t.kind]) for t in plan.tickets])reviewed_intakeis a new pipeline, sointakeand its tests stay as they are. It callscb.human_stepafter the plan and before it returns the tickets, so codeband writes no ticket before a person approves. The call takes three arguments:Argument Here What it does name"approve"The name of the human step. Its first call in a run has the step ID approve#0, whichcodeband answertakesquestionA cb.Questionwith the titles of the ticketsWhat the person sees. Any model works, so give it the facts that the decision needs answerboolThe type of the answer. cb.human_stepreturns a value of this type, and the terminal asks foryorncb.human_stepreturnsTrueorFalsehere. OnFalse,reviewed_intakeraisescb.Stopwith the reason.In
pyproject.toml, add the new pipeline to thepipelinesline of[tool.codeband]:pyproject.toml [tool.codeband]pipelines = ["py_factory.pipeline:intake", "py_factory.review:reviewed_intake"]Commit the change, so that the runs start at a commit that has the new pipeline:
Terminal window git add -Agit commit -m "Ask a person before filing the tickets"git prints the commit’s ID and
2 files changed. -
Start codeband
Open a second terminal, change to the folder
py-factoryand start the daemon and the code server:Terminal window uv run codeband devIt logs the same lines as in the tutorial and keeps running. The code server now loads both pipelines:
Output Nov 25 21:25:06.830 INF Loaded pipelines comp=codeserver pipelines="[intake reviewed_intake]" folder=…/py-factoryNov 25 21:25:06.859 INF Serving pipelines comp=codeserver address=unix:~/.local/state/codeband/codeserver.sock -
Answer in the terminal of
codeband runIn the first terminal, make the folder for the ticket files and start a run.
codeband devserves your factory under the name of its folder,py-factory, so the pipeline ispy-factory/reviewed_intake:Terminal window mkdir -p /tmp/py-factory-ticketsuv run codeband run py-factory/reviewed_intake --tickets /tmp/py-factory-tickets \--input '{"title": "Release 1.2", "body": "- Fix the crash on start\n- Add a dark mode"}'The run reaches the human step and waits.
codeband runprints the question andAnswer y or n:. Typeyand press Enter. The run takes the answer and ends withno code changeand the two tickets, which codeband writes as files in/tmp/py-factory-tickets, andcodeband runexits with code 0. Your run ID and user name differ:Output Started run 788gpcxtcd▸ approve#0 human step opensHuman step approve#0 asks:{"options": [],"text": "File these tickets for Release 1.2? Fix the crash on start; Add a dark mode"}Answer y or n: y✓ approve#0 answered by ada after 2.8sno code changenew ticket: Fix the crash on start: /tmp/py-factory-tickets/788gpcxtcd/01-fix-the-crash-on-start.mdnew ticket: Add a dark mode: /tmp/py-factory-tickets/788gpcxtcd/02-add-a-dark-mode.mdThe terminal takes
y,yes,norno, and asks again after any other text.codeband runasks only when its stdin is a terminal. -
Start a run that you answer elsewhere
We recommend answering in the terminal of
codeband run, where the question appears when the run reaches it.codeband answerfits when the run was started with-d, when a script starts it, or when you answer from another terminal. The web interface shows an open human step with a form on the page for its run, as Answer a human step in the web interface shows.Start a run with
-d:Terminal window uv run codeband run -d py-factory/reviewed_intake \--input '{"title": "Release 1.3", "body": "- Update the docs\n- Add a search box"}'-dprints the run ID and exits without following the run. The run waits atapprove#0. Your run ID differs:Output ct0aayrmaz -
Send an answer that the human step rejects
Answer with JSON that is not a boolean:
Terminal window uv run codeband answer RUN_ID --json '"maybe"'Put the run ID of step 4 in place of
RUN_ID.--jsonsends the answer as JSON, and the code server checks it againstbool. It rejects"maybe", socodeband answerprints the reason and exits with code 1:Output answer: answer rejected: human step approve#0 does not accept the answer: 1 validation error for boolInput should be a valid boolean, unable to interpret input [type=bool_parsing, input_value='maybe', input_type=str]For further information visit https://errors.pydantic.dev/2.14/v/bool_parsingA rejected answer changes nothing in the run journal, and the human step stays open.
-
Answer the human step with
codeband answerSend
false, the JSON for no:Terminal window uv run codeband answer RUN_ID --json falseIt prints one line with your run ID and exits with code 0:
Output Answered human step approve#0 of run ct0aayrmazWithout a human step ID after the run ID,
codeband answeranswers the run’s only open human step. Without--json, it asks the question in the terminal, ascodeband rundoes.
Check that it worked
Section titled “Check that it worked”Show the run of step 4. Put its run ID in place of RUN_ID here and in the next command:
uv run codeband show RUN_IDcodeband show prints the run’s status stopped, the reason that reviewed_intake gave, and who answered the human step. Your user name, commit and times differ:
Run ct0aayrmazPipeline py-factory/reviewed_intakeStatus stoppedRepository …/py-factoryStart commit 631fce6c26f4ac79d0176e5e5fb1a79d0a4412e4Started 2026-11-25 21:25:29Ended 2026-11-25 21:25:30Cost $0.00Reason a person rejected the tickets of Release 1.3Input {"body":"- Update the docs\n- Add a search box","title":"Release 1.3"}
▸ approve#0 human step opens✓ approve#0 answered by ada after 1.0sstopped: a person rejected the tickets of Release 1.3The run journal holds only the answer that the run took. Print it:
jq -c '.stepFinished.humanStep // empty' \ ~/.local/state/codeband/store/runs/RUN_ID/journal.jsonl{"answer":"false","answeredBy":"ada"}The rejected "maybe" is not in the run journal.
Troubleshooting
Section titled “Troubleshooting”For an error that this page doesn’t cover, see Run problems.
start run: run request rejected: the factory has no pipeline 'reviewed_intake'
Section titled “start run: run request rejected: the factory has no pipeline 'reviewed_intake'”The code server doesn’t know the new pipeline, and codeband run exits with code 1. Check that the pipelines line of step 1 names py_factory.review:reviewed_intake and that you saved pyproject.toml. codeband dev loads the factory again when the file changes.
codeband run prints Run … waits for an answer to human step approve#0. Answer it with:
Section titled “codeband run prints Run … waits for an answer to human step approve#0. Answer it with:”codeband run can’t ask, because its stdin is not a terminal, such as in a script, or you pressed Ctrl-D at Answer y or n:, which prints No answer to human step approve#0: EOF first. The run waits. Answer with the codeband answer command that it prints, or run uv run codeband attach RUN_ID in a terminal, which asks the question again.
without a terminal on stdin, give the answer with --json
Section titled “without a terminal on stdin, give the answer with --json”codeband answer without --json asks in the terminal, and its stdin is not one. It exits with code 2. Give the answer with --json, such as --json true.
run … has no open human step
Section titled “run … has no open human step”The human step has its answer already, from another terminal or an earlier codeband answer, or the run has ended. codeband answer exits with code 1. uv run codeband show RUN_ID shows who answered and how the run ended.
RuntimeError: cb.human_step works only in a run, where a person can answer it
Section titled “RuntimeError: cb.human_step works only in a run, where a person can answer it”A test or a script calls reviewed_intake outside a run. In a test, call it with call_pipeline and give the answer in answers, as Test a pipeline with agent steps, shell steps and human steps shows.
Related
Section titled “Related”- Answer a human step in the web interface answers the human step of a run on the page for the run, with a form built from the answer type.
- Human step explains who may answer, the other answer types and how the terminal asks for each, and how an agent’s questions reach a human step.
- codeband CLI lists the flags and exit codes of
codeband answer, and howcodeband runandcodeband attachask at a human step. - Python SDK lists
cb.human_step,cb.Question,cb.Questionsandcb.Answers. - Test a pipeline without a daemon answers a human step in a test.