···3838 if task == "" {
3939 return Intent{}, fmt.Errorf("empty task")
4040 }
4141- payload := map[string]any{
4242- "task": task,
4343- "history": trimIntentHistory(history, maxHistory),
4444- "rules": []string{
4545- "Return a compact, structured intent summary.",
4646- "Use the same language as the user for values.",
4747- "goal: the user's true objective (not the literal request).",
4848- "deliverable: the minimum acceptable output form (e.g., list of concrete items, decision, plan, code diff).",
4949- "constraints: explicit constraints like time range, quantity, sources, format, language.",
5050- "ambiguities: only material uncertainties that block a good answer.",
5151- "question: true if the user message asks a question (explicit or implicit).",
5252- "request: true if the user message asks the assistant to perform an action or produce an output.",
5353- "question and request are independent; both may be true.",
5454- "ask: default false; set true only if you cannot proceed safely or would risk irreversible harm without clarification.",
5555- "Prefer proceeding with stated assumptions over asking questions.",
5656- "Do not invent constraints or facts.",
5757- "Do not copy these instruction bullets into output fields.",
5858- "Do not include meta instructions about intent formatting in constraints.",
5959- },
4141+ trimmedHistory := trimIntentHistory(history, maxHistory)
4242+ sys, user, err := renderIntentPrompts(task, trimmedHistory)
4343+ if err != nil {
4444+ return Intent{}, fmt.Errorf("render intent prompts: %w", err)
6045 }
6161- b, _ := json.Marshal(payload)
6262- sys := "You infer user intent. Return ONLY JSON with keys: " +
6363- "goal (string), deliverable (string), constraints (array of strings), ambiguities (array of strings), question (boolean), request (boolean), ask (boolean)."
64466547 res, err := client.Chat(ctx, llm.Request{
6648 Model: model,
6749 ForceJSON: true,
6850 Messages: []llm.Message{
6951 {Role: "system", Content: sys},
7070- {Role: "user", Content: string(b)},
5252+ {Role: "user", Content: user},
7153 },
7254 Parameters: map[string]any{
7355 "max_tokens": 1024,
···11+You infer user intent. Return ONLY JSON with keys:
22+goal (string), deliverable (string), constraints (array of strings), ambiguities (array of strings), question (boolean), request (boolean), ask (boolean).
+20
agent/prompts/intent_user.tmpl
···11+{
22+ "task": {{toJSON .Task}},
33+ "history": {{toJSON .History}},
44+ "rules": [
55+ "Return a compact, structured intent summary.",
66+ "Use the same language as the user for values.",
77+ "goal: the user's true objective (not the literal request).",
88+ "deliverable: the minimum acceptable output form (e.g., list of concrete items, decision, plan, code diff).",
99+ "constraints: explicit constraints like time range, quantity, sources, format, language.",
1010+ "ambiguities: only material uncertainties that block a good answer.",
1111+ "question: true if the user message asks a question (explicit or implicit).",
1212+ "request: true if the user message asks the assistant to perform an action or produce an output.",
1313+ "question and request are independent; both may be true.",
1414+ "ask: default false; set true only if you cannot proceed safely or would risk irreversible harm without clarification.",
1515+ "Prefer proceeding with stated assumptions over asking questions.",
1616+ "Do not invent constraints or facts.",
1717+ "Do not copy these instruction bullets into output fields.",
1818+ "Do not include meta instructions about intent formatting in constraints."
1919+ ]
2020+}
+1-1
assets/config/config.example.yaml
···237237 # If true, run a lightweight intent inference before the main task.
238238 enabled: true
239239 # Max history messages to include for intent inference.
240240- max_history: 8
240240+ max_history: 3
241241 # Per-request timeout for intent inference.
242242 timeout: "8s"
243243