Skip to content
codeband is pre-release. These docs describe its first release, and some of what they describe is still being built.

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.

  • You built intake in the tutorial Build a pipeline that files tickets, and your terminal is in its folder py-factory. Run each command there.
  • codeband dev doesn’t run. If it still runs from the tutorial, press Ctrl-C in its terminal.
  • jq for the check at the end, as jq --version shows.

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.

  1. 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 cb
    from py_factory.planning import plan_tickets
    @cb.pipeline
    def 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_intake is a new pipeline, so intake and its tests stay as they are. It calls cb.human_step after 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, which codeband answer takes
    question A cb.Question with the titles of the tickets What the person sees. Any model works, so give it the facts that the decision needs
    answer bool The type of the answer. cb.human_step returns a value of this type, and the terminal asks for y or n

    cb.human_step returns True or False here. On False, reviewed_intake raises cb.Stop with the reason.

    In pyproject.toml, add the new pipeline to the pipelines line 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 -A
    git commit -m "Ask a person before filing the tickets"

    git prints the commit’s ID and 2 files changed.

  2. Start codeband

    Open a second terminal, change to the folder py-factory and start the daemon and the code server:

    Terminal window
    uv run codeband dev

    It 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-factory
    Nov 25 21:25:06.859 INF Serving pipelines comp=codeserver address=unix:~/.local/state/codeband/codeserver.sock
  3. Answer in the terminal of codeband run

    In the first terminal, make the folder for the ticket files and start a run. codeband dev serves your factory under the name of its folder, py-factory, so the pipeline is py-factory/reviewed_intake:

    Terminal window
    mkdir -p /tmp/py-factory-tickets
    uv 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 run prints the question and Answer y or n:. Type y and press Enter. The run takes the answer and ends with no code change and the two tickets, which codeband writes as files in /tmp/py-factory-tickets, and codeband run exits with code 0. Your run ID and user name differ:

    Output
    Started run 788gpcxtcd
    ▸ approve#0 human step opens
    Human 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.8s
    no code change
    new ticket: Fix the crash on start: /tmp/py-factory-tickets/788gpcxtcd/01-fix-the-crash-on-start.md
    new ticket: Add a dark mode: /tmp/py-factory-tickets/788gpcxtcd/02-add-a-dark-mode.md

    The terminal takes y, yes, n or no, and asks again after any other text. codeband run asks only when its stdin is a terminal.

  4. 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 answer fits 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"}'

    -d prints the run ID and exits without following the run. The run waits at approve#0. Your run ID differs:

    Output
    ct0aayrmaz
  5. 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. --json sends the answer as JSON, and the code server checks it against bool. It rejects "maybe", so codeband answer prints the reason and exits with code 1:

    Output
    answer: answer rejected: human step approve#0 does not accept the answer: 1 validation error for bool
    Input 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_parsing

    A rejected answer changes nothing in the run journal, and the human step stays open.

  6. Answer the human step with codeband answer

    Send false, the JSON for no:

    Terminal window
    uv run codeband answer RUN_ID --json false

    It prints one line with your run ID and exits with code 0:

    Output
    Answered human step approve#0 of run ct0aayrmaz

    Without a human step ID after the run ID, codeband answer answers the run’s only open human step. Without --json, it asks the question in the terminal, as codeband run does.

Show the run of step 4. Put its run ID in place of RUN_ID here and in the next command:

Terminal window
uv run codeband show RUN_ID

codeband 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:

Output
Run ct0aayrmaz
Pipeline py-factory/reviewed_intake
Status stopped
Repository …/py-factory
Start commit 631fce6c26f4ac79d0176e5e5fb1a79d0a4412e4
Started 2026-11-25 21:25:29
Ended 2026-11-25 21:25:30
Cost $0.00
Reason a person rejected the tickets of Release 1.3
Input {"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.0s
stopped: a person rejected the tickets of Release 1.3

The run journal holds only the answer that the run took. Print it:

Terminal window
jq -c '.stepFinished.humanStep // empty' \
~/.local/state/codeband/store/runs/RUN_ID/journal.jsonl
Output
{"answer":"false","answeredBy":"ada"}

The rejected "maybe" is not in the run journal.

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.

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.

  • 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 how codeband run and codeband attach ask at a human step.
  • Python SDK lists cb.human_step, cb.Question, cb.Questions and cb.Answers.
  • Test a pipeline without a daemon answers a human step in a test.