Skip to content

feat: improve tip generation prompt with richer guidance#124

Open
jayaramkr wants to merge 1 commit intoAgentToolkit:mainfrom
jayaramkr:feat/guideline-extraction-prompts
Open

feat: improve tip generation prompt with richer guidance#124
jayaramkr wants to merge 1 commit intoAgentToolkit:mainfrom
jayaramkr:feat/guideline-extraction-prompts

Conversation

@jayaramkr
Copy link
Copy Markdown
Collaborator

@jayaramkr jayaramkr commented Apr 1, 2026

Restructures the prompt to produce more specific, actionable tips by adding explicit categories (strategy/recovery/optimization), step instructions, trigger conditions, and domain-specific pattern hints (API discovery, pagination, auth, error handling).

Summary by CodeRabbit

  • Chores
    • Enhanced AI tip generation to produce more actionable, task-specific guidance for agents
    • Tips now include structured information: content, rationale, category classification, implementation steps, and trigger conditions
    • Improved AI instructions to distinguish between successful strategies and failure recovery patterns
    • Expanded analysis scope to cover API discovery, authentication, pagination, and error handling

Restructures the prompt to produce more specific, actionable tips by
adding explicit categories (strategy/recovery/optimization), step
instructions, trigger conditions, and domain-specific pattern hints
(API discovery, pagination, auth, error handling).
@jayaramkr jayaramkr requested review from illeatmyhat and visahak April 1, 2026 17:18
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

Updated the Jinja2 prompt template to reframe tip generation from generic extraction to actionable, task-specific guidance. Added structured tip requirements including content, rationale, category classification, implementation steps, and trigger conditions. Incorporated branching logic for success-focused versus failure-recovery strategies and expanded the checklist of trajectory aspects to analyze.

Changes

Cohort / File(s) Summary
Prompt Template Update
evolve/llm/tips/prompts/generate_tips.jinja2
Reframed tip extraction goal to focus on actionable, task-specific guidance. Introduced "IMPORTANT TO REMEMBER" instruction set with structured requirements: tips must include content, rationale/purpose, category (strategy|recovery|optimization), implementation steps, and trigger conditions. Added explicit branching for success vs. failure scenarios and expanded checklist of aspects to mine (API discovery, authentication, pagination, approach structuring, error handling).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A template revised with care so fine,
Tips now flow in structured line,
From vague to clear, from broad to deep,
Actionable wisdom we shall reap,
Better guidance for tasks to keep! 📋✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: enhancing the tip generation prompt with more detailed guidance and structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
evolve/llm/tips/prompts/generate_tips.jinja2 (2)

48-51: Extraneous trailing newlines.

The template ends with 3 blank lines after {% endif %}. This adds unnecessary whitespace to the rendered prompt.

Remove extra newlines
 Generate tips now. Return ONLY the JSON, no other text.
 {% endif %}
-
-
-
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@evolve/llm/tips/prompts/generate_tips.jinja2` around lines 48 - 51, The
Jinja2 template ends with three extraneous blank lines after the `{% endif %}`
which add unwanted whitespace to rendered prompts; remove the extra newline
characters so the file ends immediately after the `{% endif %}` (ensure the
trailing newline is exactly one or none per project style) in the
generate_tips.jinja2 template to prevent extra whitespace in outputs.

20-20: Minor terminology inconsistency: "trigger condition" vs "trigger".

Line 20 says "A trigger condition" but the JSON example on line 41 uses "trigger" as the field name. While likely not a blocking issue, aligning the wording prevents ambiguity.

Suggested wording alignment
-   - A trigger condition (when to apply this tip)
+   - A trigger (when to apply this tip)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@evolve/llm/tips/prompts/generate_tips.jinja2` at line 20, Update the wording
to match the JSON field name: replace the phrase "A trigger condition (when to
apply this tip)" with "A trigger (when to apply this tip)" in the
generate_tips.jinja2 template so it aligns with the "trigger" field used in the
JSON example; ensure any other occurrences in the same template use "trigger"
for consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@evolve/llm/tips/prompts/generate_tips.jinja2`:
- Around line 22-23: The template guidance refers to task success/failure but
the template is always rendered with "Status: UNKNOWN" because
evolve/llm/tips/tips.py (around the render function at lines 106-125) does not
pass the task outcome; fix by adding a boolean (e.g., task_succeeded) or outcome
string to the context when calling the Jinja2 render in the function that
renders generate_tips.jinja2 and update line 5 in generate_tips.jinja2 to use
that variable (e.g., "**Status:** {{ 'SUCCEEDED' if task_succeeded else 'FAILED'
}}") so the conditional guidance is meaningful, or if you prefer not to change
call sites, remove/rephrase the conditional lines 5-6 in generate_tips.jinja2 to
avoid referencing task success/failure.
- Around line 15-20: The template asks for "implementation_steps" but the Tip
Pydantic model lacks that field, causing validation failures in tips.py; fix by
either removing the "Specific steps to implement the tip" line from
generate_tips.jinja2 or by adding implementation_steps: list[str] to the Tip
model (class Tip) and then update any consumers (the JSON example in the
template and the clustering logic in clustering.py) and ensure tips.py
validation accepts the new field; reference symbols: Tip, implementation_steps,
generate_tips.jinja2, tips.py, clustering.py.

---

Nitpick comments:
In `@evolve/llm/tips/prompts/generate_tips.jinja2`:
- Around line 48-51: The Jinja2 template ends with three extraneous blank lines
after the `{% endif %}` which add unwanted whitespace to rendered prompts;
remove the extra newline characters so the file ends immediately after the `{%
endif %}` (ensure the trailing newline is exactly one or none per project style)
in the generate_tips.jinja2 template to prevent extra whitespace in outputs.
- Line 20: Update the wording to match the JSON field name: replace the phrase
"A trigger condition (when to apply this tip)" with "A trigger (when to apply
this tip)" in the generate_tips.jinja2 template so it aligns with the "trigger"
field used in the JSON example; ensure any other occurrences in the same
template use "trigger" for consistency.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 419fa8fe-8b10-488f-9af0-6c9679f136f5

📥 Commits

Reviewing files that changed from the base of the PR and between 6945ce1 and 253c1a4.

📒 Files selected for processing (1)
  • evolve/llm/tips/prompts/generate_tips.jinja2

Comment on lines +15 to +20
4. Each tip should have:
- A clear, concise description (content)
- The purpose/benefit of following it
- The category: "strategy", "recovery", or "optimization"
- Specific steps to implement the tip
- A trigger condition (when to apply this tip)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Schema mismatch: implementation_steps field does not exist in the Tip model.

The instructions ask the LLM to include "Specific steps to implement the tip" (line 19), but the Tip Pydantic model in evolve/schema/tips.py only defines 4 fields: content, rationale, category, and trigger. If the LLM emits an implementation_steps field, it will either cause a ValidationError (returning an empty tips list per evolve/llm/tips/tips.py:154-162) or be silently discarded.

Either remove the instruction for implementation steps, or update the Tip schema to include the new field.

Option A: Remove the mismatched instruction
 4. Each tip should have:
    - A clear, concise description (content)
    - The purpose/benefit of following it
    - The category: "strategy", "recovery", or "optimization"
-   - Specific steps to implement the tip
    - A trigger condition (when to apply this tip)
Option B: Update the Tip schema (in evolve/schema/tips.py)
class Tip(BaseModel):
    content: str = Field(description="Clear, actionable tip")
    rationale: str = Field(description="Why this tip helps")
    category: Literal["strategy", "recovery", "optimization"]
    implementation_steps: list[str] = Field(description="Specific steps to implement this tip")
    trigger: str = Field(description="When to apply this tip")

If you choose Option B, also update the JSON example in this template (lines 35-44) and the clustering code in evolve/llm/tips/clustering.py.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
4. Each tip should have:
- A clear, concise description (content)
- The purpose/benefit of following it
- The category: "strategy", "recovery", or "optimization"
- Specific steps to implement the tip
- A trigger condition (when to apply this tip)
4. Each tip should have:
- A clear, concise description (content)
- The purpose/benefit of following it
- The category: "strategy", "recovery", or "optimization"
- A trigger condition (when to apply this tip)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@evolve/llm/tips/prompts/generate_tips.jinja2` around lines 15 - 20, The
template asks for "implementation_steps" but the Tip Pydantic model lacks that
field, causing validation failures in tips.py; fix by either removing the
"Specific steps to implement the tip" line from generate_tips.jinja2 or by
adding implementation_steps: list[str] to the Tip model (class Tip) and then
update any consumers (the JSON example in the template and the clustering logic
in clustering.py) and ensure tips.py validation accepts the new field; reference
symbols: Tip, implementation_steps, generate_tips.jinja2, tips.py,
clustering.py.

Comment on lines +22 to +23
5. If the task succeeded, focus on the successful strategies used
6. If the task failed, focus on what went wrong and how to prevent/recover from it
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Guidance references task success/failure, but status is always "UNKNOWN".

Lines 22-23 instruct the LLM to focus on successful strategies if the task succeeded, or on failure modes if it failed. However, line 5 shows **Status:** UNKNOWN, and the rendering code in evolve/llm/tips/tips.py:106-125 does not pass a task_succeeded or similar variable to the template.

The LLM cannot follow this conditional guidance without knowing the actual outcome. Either:

  1. Pass the task outcome to the template and update line 5, or
  2. Remove/rephrase this guidance to avoid confusing the LLM.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@evolve/llm/tips/prompts/generate_tips.jinja2` around lines 22 - 23, The
template guidance refers to task success/failure but the template is always
rendered with "Status: UNKNOWN" because evolve/llm/tips/tips.py (around the
render function at lines 106-125) does not pass the task outcome; fix by adding
a boolean (e.g., task_succeeded) or outcome string to the context when calling
the Jinja2 render in the function that renders generate_tips.jinja2 and update
line 5 in generate_tips.jinja2 to use that variable (e.g., "**Status:** {{
'SUCCEEDED' if task_succeeded else 'FAILED' }}") so the conditional guidance is
meaningful, or if you prefer not to change call sites, remove/rephrase the
conditional lines 5-6 in generate_tips.jinja2 to avoid referencing task
success/failure.

@visahak
Copy link
Copy Markdown
Collaborator

visahak commented Apr 1, 2026

@jayaramkr Can you address the code rabbit's comments, or mark them as irrelevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants