Writing steps
You write a quest as steps in its quest file, each a turn of one member or a script, and choose what each step is sent and where the quest goes after it.
The guild file names each quest's directory beside the members:
[quests.change]
path = "quests/change"The quest file is quest.toml in that directory, with an optional description and the steps in order as [[steps]] tables:
#:schema https://pandra.io/schemas/quest/v0.schema.json
description = "Implement a change, reviewed for code and security, and write its release note."
[[steps]]
name = "implement"
member = "implementer"
[[steps.checks]]
name = "code"
member = "reviewer"
prompt = "Review this change: ${{ steps.previous.output }}"
[[steps.checks]]
name = "security"
member = "security-reviewer"
prompt = "Review this change for security: ${{ steps.previous.output }}"
[[steps]]
name = "release-note"
member = "release-notes"A step without prompt is sent the output before it: the first step gets the request, and release-note gets the output of implement. In a check's prompt, ${{ steps.previous.output }} is the output of the step it checks (pass outputs to later steps). A remote member runs only once it is pinned and approved (pinning and approving); the quest asks for an approval it lacks before its first step.
Each step has a name, the member that carries it out, and an optional prompt. Steps and checks share one set of names, so each name is unique in the quest. A step can run a script instead, with run in place of member and prompt. The quest.toml reference lists every key.
Each step and check of a member runs in a session of its own, as pandra guild run would start it, and its output is the run's answer. The quest's output is the output of the last step that ran. A mistake in a quest file fails pandra quest run, pandra quest resume, and every pandra guild command with an error that names the file, line, and key.
Pass outputs to later steps
A prompt is what is sent to the member, and nothing else is sent. Each ${{ EXPR }} in it is replaced when its step or check starts:
[[steps]]
name = "implement"
member = "implementer"
prompt = """
Implement the request below.
Commit once the tests pass, and report what you changed.
${{ steps.previous.output }}
"""
[[steps.checks]]
name = "code"
member = "reviewer"
prompt = """
Review the change below against its request. Approve unless a finding must be fixed before merge.
Request:
${{ quest.prompt }}
Change:
${{ steps.previous.output }}
"""| Expression | Value |
|---|---|
quest.prompt | The quest's request, the text of --prompt. |
steps.previous.output | In a step, the output of the step that ran before it, or the request in the first step; in a check, the output of the step it checks. |
steps.<name>.output | The latest output of an earlier step. |
steps.<name>.output.<field> | A field of the output of a step with output-schema, such as steps.triage.output.size. |
A step with output-schema, a path inside the quest's directory to a JSON Schema, outputs JSON that matches it, as --output-schema of pandra run does; a step without one outputs the member's answer as text. A field that the output does not have fails the quest. Only the request and the steps' outputs are ever inserted, never an environment variable or a secret.
Security
Pandra inserts an output as the agent wrote it, unfiltered, so a member that read untrusted text, such as an issue, can pass instructions on to a later step or check.
End early or skip steps
A step with output-schema, or a command step, can end the quest or skip ahead with next, a list of cases, each with when, the fields of the step's output to compare, and to, where to go when they all match. Here a triage step ends the quest when the issue cannot be reproduced, and skips the plan for a small fix:
[[steps]]
name = "triage"
member = "triager"
output-schema = "schemas/triage.json"
prompt = """
Try to reproduce the issue below. Say whether you could, and whether the fix is small.
${{ quest.prompt }}
"""
next = [
{ when = { output.reproduced = false }, to = "end" },
{ when = { output.size = "small" }, to = "implement" },
]
[[steps]]
name = "plan"
member = "planner"
[[steps]]
name = "implement"
member = "implementer"schemas/triage.json describes the answer the cases compare:
{
"type": "object",
"additionalProperties": false,
"required": ["reproduced", "size"],
"properties": {
"reproduced": {"type": "boolean"},
"size": {"type": "string", "enum": ["small", "large"]}
}
}- The cases are tried once the step's output is final, after its checks approve. The first case that matches decides; when none matches, the next step starts. When a case matches, stderr says where the quest goes, such as
[triage] end. - A value equals only a JSON value of the same type:
falsedoes not match"false". to = "end"ends the quest with this step's output, andto = "fail"fails it. Any othertonames a later step; a quest never goes back.- A prompt cannot name a step that a
nextcan skip on the way to it: here,implementcan nametriagebut notplan.
Security
A member steered by text it read, such as an issue, can choose a case. Place a step that must always run, such as a review, where no next can skip it.
A command step without output-schema compares its whole output, as one exact string, with when = { output = "..." }. Here a step skips the release note when the pull request has the label no-release-note:
[[steps]]
name = "labels"
run = """
gh pr view --json labels --jq 'any(.labels[]; .name == "no-release-note")'
"""
next = [{ when = { output = "true" }, to = "push" }]push is a later step of the quest. Output that matches no case, such as false, starts the next step.