Hey @leoreche I ran into similar issues for a client build a month ago.
Here is a two-part solution to enforce consistent formatting for both numbered lists and mathematical equations.
Part 1: Fix Inconsistent List Numbering
The root cause of a numbered list restarting (e.g., 1, 2, 3, 1, 2) is typically the AI model losing track of the sequence across multiple generation steps. We can enforce this with a direct rule in your system prompt.
The Solution: Add a Formatting Mandate to Your System Prompt
Add the following XML block inside the <Rules> section of your main system prompt. This creates a critical reminder for the AI to maintain list integrity in every single response.
<rule>
**Numbered List Integrity:** When generating a numbered list, you MUST ensure the numbering is sequential and continuous. Never restart the numbering mid-list. Before outputting your final response, double-check all numbered lists to verify their sequence is correct.
</rule>
As a complementary step, using a more advanced model (like GPT-4 Turbo or Claude 3 Opus) can improve the model’s ability to follow these kinds of complex instructions over longer conversations.
Part 2: Fix Unrendered LaTeX Math & Code Blocks
To solve the issue of raw LaTeX or code appearing in the output, the correct architecture is to use the Code Interpreter action. This forces the AI to process the code/math and render it correctly before delivering the final text to the user.
Step 1: Connect the Code Interpreter Action
If you haven’t already, go to the Actions tab in your Pickaxe editor, search for the “Code Interpreter” action, and connect it.
Step 2: Set the Trigger Prompt for the Code Interpreter Action
In the “Trigger prompt” field for the Code Interpreter action, paste the following instructions. This prompt is engineered to be very specific about when and how the action should be used.
Trigger this action when your planned response contains mathematical formulas, LaTeX syntax (e.g., text enclosed in $$...$$ or $...$), or any block of code.
Your primary function is to act as a self-contained Python environment. You must:
1. **Process Calculations:** Execute any mathematical computations. Autonomously import any necessary Python libraries (e.g., NumPy, SciPy) to handle the request.
2. **Render Text:** Convert all raw LaTeX or code into a properly formatted response that the Pickaxe markdown renderer can display correctly.
3. **Generate Visuals:** If the user's request requires a visual output like a chart or graph, use libraries such as Matplotlib or Seaborn to generate the visual and output it as a complete PNG image file.
Step 3: Synchronize Your Main System Prompt
This is the most critical step. You must inform your primary agent that it now has this tool and is required to use it. Add the following rule to the <Rules> section of your main system prompt.
`<rule>
**Code & Mathematical Rendering Mandate:** When your response requires mathematical equations or code blocks, you MUST use the appropriate format (e.g., LaTeX, Python) and call the connected Code Interpreter action to render it. You are forbidden from outputting raw, unrendered LaTeX or code directly in your response.
</rule>`
By implementing these structured rules, you are moving from simple prompting to more robust prompt engineering, which should significantly reduce the formatting inconsistencies you are experiencing.
Let me know how it goes!