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

Start runs from GitHub issues

Start runs from GitHub issues when your team plans its work in issues and wants an agent to pick up the ones you mark. In this guide you let the label codeband/webshop/fix_issue start the pipeline fix_issue of the factory webshop on an issue of the repository acme/webshop. At the end, the issue’s thread shows a comment that names the run, and the run ends with a draft pull request in acme/webshop. If no run starts, see Troubleshooting at the end of this page.

  • A daemon serves your factory as webshop, as codeband.toml names it.
  • You have write access to the GitHub repository, here acme/webshop.
  • You have a GitHub token with Contents, Pull requests and Issues set to Read and write, such as the one of gh auth token.

The daemon polls the issues of each repository that codeband.toml names. When a person with write or triage access sets the label codeband/FACTORY/PIPELINE on an issue, the daemon starts that pipeline with the issue as its ticket. The person who sets the label vouches for the issue’s text: the run input holds the issue and every comment written before the label, by anyone. Comments written later reach no running run.

  1. Take a ticket in the pipeline

    Only a pipeline with a parameter ticket of the SDK’s ticket type starts from an issue. The ticket holds the issue’s number as its ID, its title, its body followed by the comments written before the label, its labels as tags, and its URL:

    webshop/pipelines/fix_issue.py
    import codeband as cb
    from webshop.agents.fixer import FixInput, fixer
    @cb.pipeline
    def fix_issue(ticket: cb.Ticket) -> cb.RunResult | None:
    """Fix the bug that the issue describes and end the run with the fix."""
    agent_step = fixer.do(FixInput(title=ticket.title, body=ticket.body))
    change = cb.CodeChange(commit=agent_step.commit, title=agent_step.output.title, description=agent_step.output.summary)
    return cb.RunResult(code_change=change)

    cb.Ticket lists the fields of a ticket.

  2. Name the repository in codeband.toml

    Add the repository to repositories of the [github] table, next to the token:

    codeband.toml
    [factories.webshop]
    code_server = "unix:/var/run/codeband/webshop.sock"
    [github]
    token = { command = ["gh", "auth", "token"] }
    repositories = ["acme/webshop"]

    The token also needs read access to the collaborators of the repository, so that the daemon can check who set a label and who answers.

  3. Restart the daemon

    The daemon reads codeband.toml only when it starts. Stop it with Ctrl-C and start it again:

    Terminal window
    codeband daemon

    The daemon creates the label codeband/webshop/fix_issue in acme/webshop, with the description of fix_issue. The labels page of the repository on GitHub lists it. A label name has at most 50 characters, so FACTORY/PIPELINE may have at most 41.

  4. Set the label on an issue

    Open an issue in acme/webshop, such as “The cart total ignores the discount”, and set the label codeband/webshop/fix_issue. On its next poll, the daemon starts a run of webshop/fix_issue on the default branch of acme/webshop and comments on the issue with the run ID.

  5. Answer in the thread

    A human step of the run posts its question as a comment in the issue’s thread. Answer it with a comment. Only a comment by a person with write access to the repository answers a human step, and the first answer that the run accepts counts. You can also answer in the web interface or with codeband answer.

When the run ends, the daemon comments on the issue with how it ended, and the run’s code change is a draft pull request in acme/webshop. Its description ends with a line that names the run. The page for the run in the web interface shows its steps, its agent transcripts and its scores.

What you see Why Fix
No run starts and no comment appears The person who set the label has neither write nor triage access, or the repository is not in repositories Have a person with access set the label, or add the repository and restart the daemon
A comment says the pipeline does not exist or takes no ticket The label names a pipeline that no factory has, or one without the parameter ticket Fix the label, or add the parameter ticket to the pipeline
A comment says the pipeline name is too long codeband/FACTORY/PIPELINE is longer than GitHub’s 50 characters for a label Rename the pipeline or the factory
The daemon logs a warning that it cannot create labels The token may not create labels in the repository Create the label by hand, or give the token Issues set to Read and write. codeband check names the missing permission
  • Run result: how the daemon changes the text of pull requests and issues before it writes them.
  • Human step: the questions that a run asks in the issue’s thread.
  • Scorer: the scores by which you see how the runs of your issues go.