You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removed all 7 static prompt constants (buildSystem, debugSystem,
testSystem, reviewSystem, refactorSystem, configSystem, researchSystem)
and classifyGoal().
New buildSubagentPrompt(goal, context) constructs a per-task prompt:
- Embeds the actual goal text — every prompt is unique
- Detects task intent from keywords (debug/test/review/refactor/config/research)
- Builds persona, methodology, and focus strings dynamically
- Includes context when provided
- Keeps under ~120 tokens
Three-tier resolution preserved:
1. system field in delegate_tasks (parent-crafted)
2. KODE_SYSTEM / config override (user-configured)
3. buildSubagentPrompt() (dynamic Go-level fallback)
Updated 12 contract tests to verify:
- goal text embedded in prompt
- context included when provided
- intent detection per category (debugger, test, review, etc.)
- empty goal falls back to subagentSystem
- different goals produce different prompts
- max length 800 chars
All 12 packages pass, race detector clean, E2E pass.
| 3 |`classifyGoal()`auto-detection | Fallback — analyses the goal text|
222
+
| 3 |`buildSubagentPrompt()`dynamic generation | Go-level fallback — analyzes goal text and constructs a per-task prompt with the actual goal embedded|
223
223
224
224
### Parent-crafted prompts
225
225
@@ -240,21 +240,30 @@ The parent agent (kode) is instructed to write system prompts for each sub-task.
240
240
}
241
241
```
242
242
243
-
### Auto-classified prompts
243
+
### Dynamically generated prompts
244
244
245
-
When no `system` field is provided, `classifyGoal()`analyzes the goal text and picks a matching category:
245
+
When no `system` field is provided, `buildSubagentPrompt()`constructs a prompt at runtime by analyzing the goal text. Every call produces a **unique prompt** because the actual goal is embedded:
246
246
247
-
| Category | Trigger keywords | Prompt persona |
248
-
|----------|-----------------|----------------|
249
-
|**build** (default) |*(no match)*| Expert engineer building production code |
250
-
|**debug**| fix, bug, error, crash, broken, incorrect | Expert debugger — find root cause first |
251
-
|**test**| test, spec, coverage, assert, unit test | Testing & quality expert |
252
-
|**review**| review, audit, check, inspect, verify | Senior engineer reading every line critically |
|*(default / no match)*| Expert engineer | Architect and implement with confidence |
258
267
259
268
### Default fallback
260
269
@@ -281,7 +290,7 @@ The temp file written by `delegate_tasks` carries the system prompt:
281
290
}
282
291
```
283
292
284
-
When invoked directly via `kode subagent --goal "..."`, the `--goal` path uses `classifyGoal()` (no manual override) while `--task <file>` reads the `system` field from the JSON file.
293
+
When invoked directly via `kode subagent --goal "..."`, the `--goal` path uses `buildSubagentPrompt()` (no manual override) while `--task <file>` reads the `system` field from the JSON file.
285
294
286
295
## Configuration
287
296
@@ -319,7 +328,7 @@ The sub-agent system has three test layers:
319
328
320
329
| Layer | Tests | Runner | What's verified |
321
330
|-------|-------|--------|-----------------|
322
-
|**Contract tests**|48|`go test ./cmd/kode/`| Flag parsing, JSON stdout protocol, exit codes, tool schema, config parsing, classifyGoal categories, system prompt length/empty checks|
331
+
|**Contract tests**|~50|`go test ./cmd/kode/`| Flag parsing, JSON stdout protocol, exit codes, tool schema, config parsing, buildSubagentPrompt dynamic generation (goal embedded, context, intent detection, uniqueness, max length)|
323
332
|**E2E tests**| 16 |`KODE_E2E=true go test ./cmd/kode/ -run "TestE2E_"`| Real subprocess spawning, tool → binary pipeline, stderr protocol, concurrency, timeouts, custom system prompt threading |
324
333
|**Full suite**| All |`go test -race ./...`| 12 packages, race-detector clean |
0 commit comments