Synthèse
Two options exist for producing revised instructions: write the changes directly or use an AI assistant to analyze and rewrite them. Write the changes directly. If the trace analysis points to a small number of clear issues (a missing stopping criterion, a redundant query instruction, a field name typo), edit the system prompt directly. Small, targeted changes are easy to review and understand. They're also easier to isolate as the cause if something regresses. Use an AI assistant to analyze a
Two options exist for producing revised instructions: write the changes directly or use an AI assistant to analyze and rewrite them. Write the changes directly. If the trace analysis points to a small number of clear issues (a missing stopping criterion, a redundant query instruction, a field name typo), edit the system prompt directly. Small, targeted changes are easy to review and understand. They're also easier to isolate as the cause if something regresses.
Use an AI assistant to analyze and rewrite. For agents with more complex issues, or where the trace suggests several overlapping problems, pairing with an AI coding assistant can produce a more thorough revision. What matters most is giving the assistant the right inputs: the current instructions, a compact conversation summary, and the optimization guidelines. The compact summary doesn't need to be the full raw conversation JSON. Extract the number of LLM calls, the tool names and call counts, the approximate payload size of each result, any error messages, and short excerpts from the agent's reasoning steps where those are visible.
This keeps the assistant's context small and focused on behavioral patterns rather than raw data. Here's the analyzer prompt template we use at Elastic InfoSec, adapted for any AI coding assistant or chat interface: You are analyzing an AI agent's system prompt and recent conversation behavior to identify inefficiencies and produce a revised version of the instructions. You will receive: 1. The agent's current instructions 2. A compact conversation summary (LLM calls, tool calls, payload sizes, errors, reasoning excerpts) Your task: Identify inefficiencies based on the patterns below, then output a full revised version of the agent's instructions.
Output only the revised instructions: no issue list, no commentary, no wrapper text. The output should be ready to replace the current instructions. --- Optimization patterns to apply: 1.