Skip to content

Commit 2d8f5fc

Browse files
committed
fix: prefer enqueue over preflight DAG checks
1 parent 15ef655 commit 2d8f5fc

4 files changed

Lines changed: 34 additions & 7 deletions

File tree

internal/agent/system_prompt.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ env:
141141
- B: ${A}/bar
142142
```
143143

144-
Parameter values with spaces must be quoted: `dagu start dag -- name="John Doe"`. Unquoted `name=John Doe` splits into two separate parameters.
144+
Parameter values with spaces must be quoted: `dagu enqueue dag -- name="John Doe"`. Unquoted `name=John Doe` splits into two separate parameters.
145145
</correctness>
146146

147147
<output_documents>
@@ -214,10 +214,11 @@ This keeps the main conversation context lean and avoids token waste.
214214

215215
### Executing a DAG
216216
1. Only run when user explicitly requests execution.
217-
2. Start: `dagu start <dag-name>` (capture the run-id)
218-
3. Verify: `dagu status <dag-name> --run-id=<run-id>`
219-
4. On failure: `read` the log file, identify root cause, propose fix.
220-
5. Navigate to run: `/dag-runs/<dag-name>/<run-id>`
217+
2. Default to queue-based execution: `dagu enqueue <dag-name>` (capture the run-id). Use `dagu start` only if the user explicitly asks for immediate local execution instead of queueing.
218+
3. Do not check running jobs, queued jobs, or call `dagu status` / `dagu history` before enqueueing unless the user explicitly asks for that check or requests singleton behavior.
219+
4. Verify the enqueued run with `dagu status <dag-name> --run-id=<run-id>` or `dagu history <dag-name> --run-id=<run-id>`
220+
5. On failure: `read` the log file, identify root cause, propose fix.
221+
6. Navigate to run: `/dag-runs/<dag-name>/<run-id>`
221222

222223
### Debugging a Failed Run
223224
1. Status: `dagu status <dag-name> --run-id=<run-id>`

internal/agent/system_prompt_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ func TestGenerateSystemPrompt(t *testing.T) {
228228
// Fallback prompt must NOT be used.
229229
assert.NotContains(t, result, "You are Dagu Assistant, an AI assistant")
230230
})
231+
232+
t.Run("execution guidance prefers enqueue without preflight checks", func(t *testing.T) {
233+
t.Parallel()
234+
env := EnvironmentInfo{DAGsDir: "/dags"}
235+
236+
result := GenerateSystemPrompt(SystemPromptParams{Env: env, Role: auth.RoleDeveloper})
237+
238+
assert.Contains(t, result, "Default to queue-based execution: `dagu enqueue <dag-name>`")
239+
assert.Contains(t, result, "Do not check running jobs, queued jobs")
240+
assert.Contains(t, result, "dagu enqueue dag -- name=\"John Doe\"")
241+
assert.NotContains(t, result, "2. Start: `dagu start <dag-name>`")
242+
})
231243
}
232244

233245
func TestFallbackPrompt(t *testing.T) {

internal/persis/fileagentskill/examples/dagu/SKILL.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ steps:
133133
command: deploy --env ${env} --region ${region}
134134
```
135135

136-
Override at runtime: `dagu start my-dag -- env=staging region=eu-west-1`
136+
Override at runtime: `dagu enqueue my-dag -- env=staging region=eu-west-1`
137137

138138
## Environment Variables
139139

@@ -240,7 +240,9 @@ dagu schema config auth # Auth config
240240

241241
## Checking Run Status
242242

243-
After running a DAG with `dagu start`, use `dagu status` to inspect the result. The output is a tree showing each step's status, command, stdout/stderr content, and errors.
243+
For agent-triggered execution, prefer `dagu enqueue` over `dagu start`. Do not check whether the DAG is already running or queued before enqueueing unless the user explicitly asks for that check or requests singleton behavior.
244+
245+
After enqueueing or starting a DAG, use `dagu status` to inspect the result. The output is a tree showing each step's status, command, stdout/stderr content, and errors.
244246

245247
```bash
246248
dagu status my-dag # Latest run

internal/persis/fileagentskill/examples_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,15 @@ func TestSeedExampleSkills_ValidContent(t *testing.T) {
8787
assert.NotEmpty(t, skill.Knowledge, "skill %s should have knowledge", skill.ID)
8888
}
8989
}
90+
91+
func TestBundledDaguSkillPrefersEnqueue(t *testing.T) {
92+
t.Parallel()
93+
94+
data, err := SkillFS().ReadFile("examples/dagu/SKILL.md")
95+
require.NoError(t, err)
96+
97+
content := string(data)
98+
assert.Contains(t, content, "Override at runtime: `dagu enqueue my-dag -- env=staging region=eu-west-1`")
99+
assert.Contains(t, content, "prefer `dagu enqueue` over `dagu start`")
100+
assert.Contains(t, content, "Do not check whether the DAG is already running or queued before enqueueing")
101+
}

0 commit comments

Comments
 (0)