Skip to content

Commit 40ca47f

Browse files
authored
Merge pull request #77 from jwm4/docs/bugfix-tutorial
docs: add tutorial guide for the Bug Fix workflow
2 parents 2e5a054 + 2b9b629 commit 40ca47f

2 files changed

Lines changed: 417 additions & 9 deletions

File tree

docs/bugfix-tutorial.md

Lines changed: 393 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,393 @@
1+
# Bug Fix Workflow Tutorial
2+
3+
This tutorial walks you through using the Bug Fix workflow on the Ambient
4+
Code Platform to diagnose and fix software bugs. By the end you will know how
5+
to start a session, move through each phase of the workflow, and submit a pull
6+
request with the fix.
7+
8+
## Getting Started
9+
10+
### Log in and create a session
11+
12+
Open [red.ht/ambient](https://red.ht/ambient) and start a new session. Select
13+
the **Bug Fix** workflow and the model you want to use.
14+
15+
### Choosing a model
16+
17+
At the time of writing, **Claude Opus** is the model we find works best for
18+
fixing bugs. If your bug is straightforward (a clear error message pointing to
19+
an obvious cause), a less powerful model may be fine and can be quicker and
20+
cheaper.
21+
22+
Keep in mind, though, that if the bug turns out to be more complex than you
23+
expect, a less powerful model can end up being *slower* and *more expensive*. A
24+
bug that a stronger model solves in one pass may take several rounds of
25+
back-and-forth with a weaker model, consuming more time and tokens overall. When
26+
in doubt, start with a capable model.
27+
28+
### Adding repository context
29+
30+
You can add the GitHub repository you want to work on by clicking the
31+
**Add Context** tab in the Explorer panel before you begin. However, this is
32+
not strictly necessary. If you give the workflow a link to the repository, or
33+
to an issue in that repository, it will clone the repo into your session
34+
automatically. Adding it in the Explorer panel can still be helpful for
35+
simplifying the model's task by ensuring it has the repo you want available
36+
before starting.
37+
38+
## Starting the Workflow
39+
40+
There are several ways to kick things off once your session is running.
41+
42+
### Option 1: Paste a bug issue link
43+
44+
Simply paste a link to a GitHub issue and the workflow will clone the repository
45+
and begin walking you through the bug fix process interactively. For example:
46+
47+
```text
48+
https://github.com/llamastack/llama-stack/issues/5119
49+
```
50+
51+
The workflow will assess the issue, summarize its understanding, and ask for
52+
your input before moving on to the next step. Alternatively, you could start with:
53+
54+
```text
55+
/assess https://github.com/llamastack/llama-stack/issues/5119
56+
```
57+
58+
That makes it more explicit that you want to start at the beginning with the assessment.
59+
60+
### Option 2: Speedrun a bug issue
61+
62+
If you want the workflow to run through every phase without stopping for
63+
input between steps, use the `/speedrun` command followed by the issue link:
64+
65+
```text
66+
/speedrun https://github.com/llamastack/llama-stack/issues/5119
67+
```
68+
69+
See [Speedrun mode](#speedrun-mode) below for details on what this does and
70+
when to use it.
71+
72+
### Option 3: Describe the bug yourself
73+
74+
You do not need a GitHub issue at all. You can describe the bug in your own
75+
words and provide a link to the repository:
76+
77+
```text
78+
The Milvus vector store integration rejects collection names that contain
79+
hyphens. Repo: https://github.com/llamastack/llama-stack
80+
```
81+
82+
The workflow will clone the repo and proceed from there. This works with or
83+
without `/speedrun`. Prefix your description with `/speedrun` to run through
84+
all phases automatically, or leave it off to step through interactively.
85+
86+
## Workflow Phases
87+
88+
The Bug Fix workflow is organized into a series of phases. The in-product
89+
greeting summarizes six core phases (Assess through Document), but in practice
90+
the full workflow includes eight: the six core phases plus Review (an optional
91+
quality check) and PR (to submit the fix). All eight are described below.
92+
93+
In the default interactive mode the workflow completes one phase at a time,
94+
presents you with results and recommendations, and then waits for you to decide
95+
what to do next. You can follow the suggested order, skip ahead, or go back to
96+
revisit an earlier phase at any point.
97+
98+
Most phases produce a **report**, a Markdown file you can view in the
99+
**Files** section of the Explorer panel. These reports are internal to
100+
your session (they are not published to GitHub or anywhere else) and serve
101+
two purposes:
102+
103+
1. **Visibility for you.** The reports give you a deeper view of what the
104+
workflow found and decided at each step, so you can provide more informed
105+
input and steer the process effectively.
106+
107+
2. **Memory for the workflow.** The platform can only keep a finite amount of
108+
context in memory at a time. By the time the workflow reaches the Test or
109+
Review phase, for example, the details of the original assessment may no
110+
longer be in its working context. The written reports let later phases refer
111+
back to earlier analysis without losing important details.
112+
113+
### Assess
114+
115+
**Command:** `/assess`
116+
117+
The first phase reads the bug report (or your description) and presents a
118+
summary of its understanding: what the bug is, where it likely occurs, what
119+
information is available, what is missing, and a proposed plan for
120+
reproducing it. No code is changed or executed in this phase; it is purely
121+
analysis and planning.
122+
123+
This is your chance to correct any misunderstandings or fill in missing
124+
details before work begins.
125+
126+
**Report:** `artifacts/bugfix/reports/assessment.md`
127+
128+
### Reproduce
129+
130+
**Command:** `/reproduce`
131+
132+
This phase attempts to reproduce the bug in a controlled environment. It
133+
follows the plan from the Assess phase, documents the steps taken, and records
134+
what happened. Even a failed reproduction attempt is documented, since
135+
understanding *why* a bug is hard to reproduce is useful information for
136+
diagnosis.
137+
138+
**Report:** `artifacts/bugfix/reports/reproduction.md`
139+
140+
### Diagnose
141+
142+
**Command:** `/diagnose`
143+
144+
Root cause analysis. The workflow traces through the code, examines git
145+
history, forms hypotheses about what is going wrong, and tests them. The goal
146+
is to understand *why* the bug happens, not just *what* happens. The diagnosis
147+
also assesses how much of the codebase is affected and recommends an approach
148+
for the fix.
149+
150+
**Report:** `artifacts/bugfix/analysis/root-cause.md`
151+
152+
### Fix
153+
154+
**Command:** `/fix`
155+
156+
Implements the bug fix. The workflow creates a feature branch, makes the
157+
minimal code changes needed to resolve the root cause, runs linters and
158+
formatters, and documents the implementation choices it made.
159+
160+
**Report:** `artifacts/bugfix/fixes/implementation-notes.md`
161+
162+
### Test
163+
164+
**Command:** `/test`
165+
166+
Verifies the fix. The workflow creates regression tests that fail without the
167+
fix and pass with it, runs the project's full test suite to check for
168+
unintended side effects, and performs manual verification of the original
169+
reproduction steps.
170+
171+
**Report:** `artifacts/bugfix/tests/verification.md`
172+
173+
### Review
174+
175+
**Command:** `/review`
176+
177+
An optional but recommended self-review phase. The workflow steps back and
178+
critically evaluates the fix and tests: Does the fix address the root cause or
179+
just suppress a symptom? Do the tests actually prove the bug is resolved, or
180+
could they be hiding problems? The review produces a verdict:
181+
182+
- **Fix and tests are solid.** Ready to proceed to documentation and PR.
183+
- **Fix is adequate but tests are incomplete.** Additional testing is
184+
recommended before proceeding.
185+
- **Fix is inadequate.** The fix needs more work. The workflow will suggest
186+
going back to the Fix phase with specific guidance.
187+
188+
**Report:** `artifacts/bugfix/review/verdict.md`
189+
190+
### Document
191+
192+
**Command:** `/document`
193+
194+
Creates the supporting documentation for the fix: release notes, a changelog
195+
entry, an issue update, and a draft pull request description.
196+
197+
**Reports:** `artifacts/bugfix/docs/` (multiple files including
198+
`release-notes.md`, `changelog-entry.md`, and `pr-description.md`)
199+
200+
### PR
201+
202+
**Command:** `/pr`
203+
204+
The final phase. The workflow pushes the feature branch to a fork and creates a
205+
draft pull request against the upstream repository. If automated PR creation
206+
fails for any reason (e.g., missing permissions), it provides instructions for
207+
creating the PR manually.
208+
209+
## Speedrun Mode
210+
211+
**Command:** `/speedrun`
212+
213+
Speedrun mode runs through all remaining phases in sequence without pausing for
214+
your input between steps. It is useful when you have a well-defined bug and
215+
trust the workflow to handle the full lifecycle autonomously.
216+
217+
Even in speedrun mode, the workflow will stop and ask you for guidance if it
218+
hits a situation that needs human judgment, such as when the root cause is
219+
unclear, if there are multiple valid fix approaches with different trade-offs,
220+
or if a security concern arises. It will also stop if it hits an obstacle it
221+
cannot get past on its own, for example if you gave it a link to a repository
222+
that does not exist.
223+
224+
You can also interrupt a speedrun at any time by clicking the **stop** button
225+
in the chat UI. Once stopped, you can interact with the session freely: review
226+
what has been done so far, request changes, provide additional context, or tell
227+
it to continue the speedrun from where it left off.
228+
229+
### Why speedrun is not the default
230+
231+
The default interactive mode pauses after each phase so you can review the
232+
results and steer the process. For many bugs, especially complex ones or bugs
233+
where the report is incomplete or ambiguous, this deliberate pacing is
234+
valuable. Reviewing the assessment before reproduction begins, or checking the
235+
diagnosis before a fix is attempted, lets you catch mistakes early and provide
236+
context that the workflow might not have.
237+
238+
Speedrun is best suited for well-understood bugs where you are confident the
239+
report contains enough information for the workflow to proceed on its own.
240+
241+
### Speedrun examples
242+
243+
Run from the beginning with a bug issue link:
244+
245+
```text
246+
/speedrun https://github.com/llamastack/llama-stack/issues/5119
247+
```
248+
249+
Continue from wherever you are in the flow (the workflow detects which phases are already complete):
250+
251+
```text
252+
/speedrun
253+
```
254+
255+
Jump ahead to a specific phase:
256+
257+
```text
258+
/speedrun Jump ahead to /fix
259+
```
260+
261+
## Viewing Reports and Artifacts
262+
263+
As the workflow progresses, reports and other artifacts are written to the
264+
`artifacts/bugfix/` directory. You can view these files at any time in the
265+
**Files** section of the Explorer panel. The reports are Markdown files that
266+
provide a detailed record of each phase's analysis, decisions, and outcomes.
267+
268+
## Automation (for advanced users)
269+
270+
Everything above describes using the Bug Fix workflow through the interactive
271+
UI. The Ambient Code Platform also supports triggering sessions
272+
programmatically, so you can incorporate bug fixing into CI/CD pipelines,
273+
scheduled jobs, or custom tooling.
274+
275+
### How it works
276+
277+
Under the hood, creating a session is a single HTTP POST to the platform's
278+
backend API. The request body includes the prompt, the repositories to clone,
279+
and an `activeWorkflow` object that tells the platform which workflow to load.
280+
Anything that can make an authenticated HTTP request can create a bug fix
281+
session.
282+
283+
Here is the equivalent `curl` call:
284+
285+
```bash
286+
curl -X POST \
287+
"${ACP_API_URL}/projects/${ACP_PROJECT}/agentic-sessions" \
288+
-H "Authorization: Bearer ${ACP_TOKEN}" \
289+
-H "Content-Type: application/json" \
290+
-d '{
291+
"initialPrompt": "/speedrun https://github.com/llamastack/llama-stack/issues/5119",
292+
"activeWorkflow": {
293+
"gitUrl": "https://github.com/ambient-code/workflows",
294+
"branch": "main",
295+
"path": "workflows/bugfix"
296+
},
297+
"repos": [
298+
{"url": "https://github.com/llamastack/llama-stack", "branch": "main", "autoPush": true}
299+
],
300+
"llmSettings": {"model": "claude-sonnet-4-5"},
301+
"timeout": 1800
302+
}'
303+
```
304+
305+
The key fields are:
306+
307+
- **`initialPrompt`** is what the agent sees as its first instruction. This is
308+
where you pass the bug description, issue link, or `/speedrun` command.
309+
- **`activeWorkflow`** tells the platform which workflow to load. For the Bug
310+
Fix workflow, point it at this repository with the path `workflows/bugfix`.
311+
If you omit this field, the session starts with no workflow.
312+
- **`repos`** is an array of repositories to clone into the session. Set
313+
`autoPush` to `true` if you want the agent to push its fix automatically.
314+
- **`llmSettings.model`** selects the model.
315+
- **`timeout`** is the session timeout in seconds.
316+
317+
Authentication uses a bearer token in the `Authorization` header.
318+
319+
### GitHub Action
320+
321+
The [`ambient-action`](https://github.com/ambient-code/ambient-action) GitHub
322+
Action wraps this API call for use in GitHub workflows. You can use it to
323+
automatically kick off a bug fix session when a new issue is opened, when a
324+
label is applied, or on any other GitHub event.
325+
326+
The action supports two modes:
327+
328+
- **Fire-and-forget.** Create the session and let the GitHub workflow continue.
329+
The agent runs in the background.
330+
- **Wait-for-completion.** Block the GitHub workflow until the session finishes
331+
(or times out), then use the session result in subsequent steps.
332+
333+
Here is an example that triggers a bug fix speedrun whenever an issue is
334+
labeled `auto-fix`:
335+
336+
```yaml
337+
name: Auto Bug Fix
338+
on:
339+
issues:
340+
types: [labeled]
341+
342+
jobs:
343+
fix:
344+
if: github.event.label.name == 'auto-fix'
345+
runs-on: ubuntu-latest
346+
steps:
347+
- uses: ambient-code/ambient-action@v0.0.2
348+
with:
349+
api-url: ${{ secrets.ACP_URL }}
350+
api-token: ${{ secrets.ACP_TOKEN }}
351+
project: my-team
352+
prompt: |
353+
/speedrun https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }}
354+
repos: |
355+
[{"url": "https://github.com/${{ github.repository }}", "branch": "main", "autoPush": true}]
356+
workflow: |
357+
{"gitUrl": "https://github.com/ambient-code/workflows", "branch": "main", "path": "workflows/bugfix"}
358+
wait: true
359+
timeout: 30
360+
```
361+
362+
When `wait` is `true`, the action outputs `session-name`, `session-uid`,
363+
`session-phase`, and `session-result`, which you can use in subsequent workflow
364+
steps. See the
365+
[action repository](https://github.com/ambient-code/ambient-action) for the
366+
full list of inputs and outputs.
367+
368+
### Tools that do NOT yet support workflows
369+
370+
Several other tools can create and manage ACP sessions. At the time of writing,
371+
none of them support setting `activeWorkflow`, which means they cannot load the
372+
structured Bug Fix workflow described in this tutorial. They will create a
373+
session, but it will not have the phases, commands, or reports that the workflow
374+
provides.
375+
376+
- **[`acpctl`](https://github.com/ambient-code/platform/tree/main/components/ambient-cli)**
377+
is a command-line tool for the platform. It can create sessions and check
378+
their status, but does not have a flag for specifying a workflow.
379+
- **[`mcp-acp`](https://github.com/ambient-code/mcp)** is an MCP server that
380+
lets you manage ACP sessions from Claude Desktop, Claude Code, or any
381+
MCP-compatible client. It has a "bugfix" template, but that template only
382+
sets a generic prompt and model. It does not load the Bug Fix workflow.
383+
- **[Ambient Platform SDKs](https://github.com/ambient-code/platform/tree/main/components/ambient-sdk)**
384+
provide client libraries in Go, Python, and TypeScript for programmatic
385+
session management.
386+
387+
If you want to automate bug fix sessions from a script, CI pipeline, or any
388+
other environment, you do not need any of these tools. The platform's backend
389+
API accepts a straightforward JSON POST request (as shown in the `curl` example
390+
above). The `activeWorkflow` field in that request is what tells the platform to
391+
load the Bug Fix workflow into the session. Any HTTP client in any language can
392+
make that call. The GitHub Action is just a convenience wrapper that does the
393+
same thing and adds polling for completion.

0 commit comments

Comments
 (0)