Build tracker identification prompt categories dynamically
Generate the category list from coredata.ThirdPartyCategories() at runtime instead of hardcoding it in the prompt text. Type the TrackerIdentification.Category field as coredata.ThirdPartyCategory so JSON unmarshaling validates values automatically. Also documents the .txt.tmpl template file naming convention. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -72,6 +72,27 @@ shutdown broadcast onto a per-run `cancelRun(agent.ErrSuspendForCheckpoint)`,
|
||||
so the same contract drives both the public Go API and the worker
|
||||
infrastructure path.
|
||||
|
||||
## Prompt templates
|
||||
|
||||
Prompt files with placeholders use `.txt.tmpl` (see general template naming
|
||||
convention in `.cursor/rules/template-files.mdc`).
|
||||
|
||||
Use `agent.WithInstructionsFunc` to build prompts dynamically at runtime:
|
||||
|
||||
```go
|
||||
//go:embed prompts/tracker_identification.txt.tmpl
|
||||
var trackerIdentificationPrompt string
|
||||
|
||||
func trackerMappingInstructions(_ context.Context, _ *agent.Agent) string {
|
||||
categories := coredata.ThirdPartyCategories()
|
||||
parts := make([]string, len(categories))
|
||||
for i, c := range categories {
|
||||
parts[i] = string(c)
|
||||
}
|
||||
return strings.Replace(trackerIdentificationPrompt, "{{.Categories}}", strings.Join(parts, ", "), 1)
|
||||
}
|
||||
```
|
||||
|
||||
## Limits
|
||||
|
||||
- Max turns: 10 (default)
|
||||
|
||||
Reference in New Issue
Block a user