Skip to content

Commit 29a838a

Browse files
committed
AI: Improve workflow error handling
We don't use shebang scripts anymore, and have replaced them with a feature from Just 1.33.0: script recipies. This allows us to configure the script runner globally using `set script_interpreter`. The default interpterter is `sh -eu` which means that we will crash on errors from now on
1 parent 3520bd3 commit 29a838a

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

agents.just

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
# Runs the given task in a workspace
1+
set unstable
2+
# We are using an unstable feature here: [script] recipies. To
3+
# configure the script interpreter you can do
4+
#
5+
# set script-interpreter := ...
6+
#
7+
# The default script interpreter crashes on error which is the
8+
# behavior that we desire.
9+
210

11+
# Runs the given task in a workspace
312
workspace_just := "just -d . --justfile .agent-tools/agents.just"
413

514
[private]
@@ -12,8 +21,8 @@ codex-ui := "codex --config model_reasoning_effort=high --full-auto"
1221

1322
consolidate workspace_id start_change_id end_change_id: (run workspace_id "consolidate" "consolidate-inner" start_change_id end_change_id)
1423

24+
[script]
1525
consolidate-inner start_change_id end_change_id:
16-
#!/usr/bin/env sh
1726
read -r -d '' INSTRUCTIONS <<-EOF
1827
You will be given a diff with 'jj diff --from {{start_change_id}} --to {{end_change_id}}'. The task is to write a specification which describes the introduced changes.
1928

@@ -56,8 +65,8 @@ workspace-sync-tools workspace_id:
5665

5766
questions-for-pm workspace_id rev='@': (run workspace_id "questions-for-pm" "questions-for-pm-inner" rev)
5867

68+
[script]
5969
questions-for-pm-inner rev='@':
60-
#!/usr/bin/env sh
6170
read -r -d '' INSTRUCTIONS_1 <<-EOF
6271
1. Read the current state of open issues in issues.md
6372
2. Read relevant state of the code base
@@ -119,8 +128,8 @@ questions-for-pm-inner rev='@':
119128

120129
pm-flow-update workspace_id rev='@': (run workspace_id "pm-flow-update" "pm-flow-update-inner" rev)
121130

131+
[script]
122132
pm-flow-update-inner rev='@':
123-
#!/usr/bin/env sh
124133
read -r -d '' INSTRUCTIONS_2 <<-EOF
125134
1. Read the current state of open issues in 'issues.md'
126135
2. Read the conversation with the product manager so far in 'pm-faq.md'. Read ONLY THE LATEST SECTION. IGNORE PREVIOUS SECTIONS as they were already handled
@@ -144,8 +153,8 @@ pm-flow-update-inner rev='@':
144153
145154
next-issue workspace_id: (run workspace_id "next-issue" "next-issue-inner")
146155
156+
[script]
147157
next-issue-inner:
148-
#!/usr/bin/env sh
149158
[ -f next-issue.md ] || exit 1
150159
151160
{{codex}} <<EOF
@@ -176,8 +185,8 @@ next-issue-inner:
176185
177186
review-change workspace_id: (run workspace_id "review-change" "review-change-inner")
178187
188+
[script]
179189
review-change-inner:
180-
#!/usr/bin/env sh
181190
{{codex}} <<EOF
182191
1. Fetch the current changes by writing 'jj show'
183192
2. Create a new change by calling 'jj new -m "review(codex): ..."'. For example 'jj new -m "review(codex): Issue 004 - introducing dog barking functionality"'
@@ -208,8 +217,8 @@ review-change-inner:
208217

209218
tidy-issues workspace_id: (run workspace_id "tidy-issues" "tidy-issues-inner")
210219

220+
[script]
211221
tidy-issues-inner:
212-
#!/usr/bin/env sh
213222
{{codex}} <<EOF
214223
1. Read the file '/issues.md'.
215224
2. Check if it follows the rules listed below
@@ -224,8 +233,8 @@ tidy-issues-inner:
224233

225234
archive-issues workspace_id: (run workspace_id "archive-issues" "archive-issues-inner")
226235

236+
[script]
227237
archive-issues-inner:
228-
#!/usr/bin/env sh
229238
{{codex}} <<EOF
230239
This is a task to archive done issues.
231240
1. Read file '/issues.md'.
@@ -234,11 +243,12 @@ archive-issues-inner:
234243
4. Change the status of all "Done" issues to "Archived"
235244
5. Then move achived issues to '.archive/issues-yyyy-mm-dd.md' file. Use current date.
236245
6. Finally update the file '/issues-overview.md'. It is a table of issues and statuses
246+
EOF
237247

238248
pick-next-issue workspace_id: (run workspace_id "pick-next-issue" "pick-next-issue-inner")
239249

250+
[script]
240251
pick-next-issue-inner:
241-
#!/usr/bin/env sh
242252
{{codex}} <<EOF
243253
1. Examine issues.md and choose a single issue to work on.
244254
2. If no issue is chosen, then STOP and don''t do anything else.
@@ -251,9 +261,8 @@ pick-next-issue-inner:
251261

252262
edit workspace_id rev='@': (run workspace_id "edit" "edit-inner" rev)
253263

264+
[script]
254265
edit-inner rev='@':
255-
#!/usr/bin/env sh
256-
257266
CURRENT_CHANGE=`jj log -r @ --template 'change_id' --no-graph`
258267
jj edit {{rev}}
259268

@@ -264,29 +273,25 @@ edit-inner rev='@':
264273
human-work-step workspace_id:
265274
bash scripts/agent-workspace.sh run {{workspace_id}} --workflow human-work-step -- just --justfile .agent-tools/agents.just --set workspace_id {{workspace_id}} human-work-step-inner
266275

267-
276+
[script]
268277
human-work-step-inner:
269-
#!/usr/bin/env sh
270278
{{workspace_just}} edit-inner
271279
jj split issues.md -m "issues: Update after review"
272280
jj edit @-
273281

274282
ai-work-step workspace_id:
275283
bash scripts/agent-workspace.sh run {{workspace_id}} --workflow ai-work-step -- just --justfile .agent-tools/agents.just --set workspace_id {{workspace_id}} ai-work-step-inner
276284

277-
285+
[script]
278286
ai-work-step-inner:
279-
#!/usr/bin/env sh
280287
{{workspace_just}} next-issue-inner
281288
{{workspace_just}} review-change-inner
282289

283290
# Use this step when starting to work on a new issue
284291
work workspace_id rev="@": (run workspace_id "work" "work-inner" rev)
285292

293+
[script]
286294
work-inner rev:
287-
#!/usr/bin/env sh
288-
echo AAAA: `pwd`
289-
290295
jj edit {{rev}}
291296
while true; do
292297
{{workspace_just}} questions-for-pm-inner
@@ -302,8 +307,8 @@ work-inner rev:
302307
# Current commit should be the last review commit
303308
continue-work workspace_id: (run workspace_id "continue-work" "continue-work-inner")
304309

310+
[script]
305311
continue-work-inner:
306-
#!/usr/bin/env sh
307312
while true; do
308313
{{workspace_just}} human-work-step-inner
309314
{{workspace_just}} pick-next-issue-inner
@@ -316,10 +321,9 @@ test:
316321

317322
review-old workspace_id start_rev end_rev: (run workspace_id "review-old" "review-old-inner" start_rev end_rev)
318323

324+
[script]
319325
review-old-inner start_rev end_rev:
320-
#!/usr/bin/env sh
321326
CURRENT_CHANGE=`jj log -r @ --template 'change_id' --no-graph`
322-
echo BBBB: `pwd`
323327

324328
read -r -d '' INSTRUCTIONS <<-EOF
325329
I was working on something long ago but I forgot what I was doing. Go over the changes and bring me up-to-speed. The changes in question are all changes between "{{start_rev}}" and "{{end_rev}}".

0 commit comments

Comments
 (0)