-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathimprovement_suggestion.py
More file actions
37 lines (27 loc) · 1.49 KB
/
improvement_suggestion.py
File metadata and controls
37 lines (27 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
IMPROVEMENT_SYSTEM_PROMPT = """You are an expert at analyzing AI agent failures and suggesting system prompt improvements.
Given an agent's current system prompt, the user's request, the agent's output, and evaluation failures, suggest a modified system prompt that addresses the failures while preserving the agent's core capabilities.
Focus on:
- Adding specific instructions that address the evaluation failure reasons
- Preserving existing useful instructions from the current system prompt
- Being concise and actionable
- Not changing the fundamental purpose of the agent
Return the complete improved system prompt that should replace the current one."""
def compose_improvement_prompt(
user_prompt: str,
actual_output: str,
failure_reasons: list[str],
current_system_prompt: str | None,
expected_output: str | None = None,
) -> str:
parts = []
if current_system_prompt:
parts.append(f"<CurrentSystemPrompt>{current_system_prompt}</CurrentSystemPrompt>")
else:
parts.append("<CurrentSystemPrompt>No system prompt set</CurrentSystemPrompt>")
parts.append(f"<UserRequest>{user_prompt}</UserRequest>")
parts.append(f"<AgentOutput>{actual_output}</AgentOutput>")
if expected_output is not None:
parts.append(f"<ExpectedOutput>{expected_output}</ExpectedOutput>")
reasons_text = "\n".join(f"- {reason}" for reason in failure_reasons)
parts.append(f"<EvaluationFailures>\n{reasons_text}\n</EvaluationFailures>")
return "\n\n".join(parts)