Skip to content

Commit cdc3811

Browse files
authored
feat: add-succes_criteria-to-agent (#3234)
## Summary Describe key changes, mention related issues or motivation for the changes. (If applicable, issue number: #____) ## Type of change - [ ] Bug fix - [x] New feature - [ ] Breaking change - [ ] Improvement - [ ] Model update - [ ] Other: --- ## Checklist - [ ] Code complies with style guidelines - [ ] Ran format/validation scripts (`./scripts/format.sh` and `./scripts/validate.sh`) - [ ] Self-review completed - [ ] Documentation updated (comments, docstrings) - [ ] Examples and guides: Relevant cookbook examples have been included or updated (if applicable) - [ ] Tested in clean environment - [ ] Tests added/updated (if applicable) --- ## Additional Notes Add any important context (deployment instructions, screenshots, security considerations, etc.)
1 parent d7ba633 commit cdc3811

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from agno.agent import Agent
2+
from agno.models.google import Gemini
3+
from agno.tools.thinking import ThinkingTools
4+
5+
puzzle_master = Agent(
6+
model=Gemini(id="gemini-2.0-flash"),
7+
tools=[ThinkingTools(add_instructions=True)],
8+
instructions="You are a puzzle master for small logic puzzles.",
9+
show_tool_calls=False,
10+
markdown=False,
11+
stream_intermediate_steps=False,
12+
success_criteria="The puzzle has been solved correctly with all drinks uniquely assigned.",
13+
)
14+
15+
16+
prompt = """
17+
Create a small logic puzzle:
18+
Three friends—Alice, Bob, and Carol—each choose a different drink from tea, coffee, and milk.
19+
Clues:
20+
1. Alice does not drink tea.
21+
2. The person who drinks coffee is not Carol.
22+
Ask: Who drinks which beverage?
23+
"""
24+
25+
puzzle_master.print_response(prompt, stream=True, show_reasoning=True)

libs/agno/agno/agent/agent.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class Agent:
209209
# Use these for few-shot learning or to provide additional context to the Model.
210210
# Note: these are not retained in memory, they are added directly to the messages sent to the model.
211211
add_messages: Optional[List[Union[Dict, Message]]] = None
212-
212+
success_criteria: Optional[str] = None
213213
# --- User message settings ---
214214
# Provide the user message as a string, list, dict, or function
215215
# Note: this will ignore the message sent to the run function
@@ -328,6 +328,7 @@ def __init__(
328328
create_default_system_message: bool = True,
329329
description: Optional[str] = None,
330330
goal: Optional[str] = None,
331+
success_criteria: Optional[str] = None,
331332
instructions: Optional[Union[str, List[str], Callable]] = None,
332333
expected_output: Optional[str] = None,
333334
additional_context: Optional[str] = None,
@@ -419,6 +420,7 @@ def __init__(
419420

420421
self.description = description
421422
self.goal = goal
423+
self.success_criteria = success_criteria
422424
self.instructions = instructions
423425
self.expected_output = expected_output
424426
self.additional_context = additional_context
@@ -2928,6 +2930,12 @@ def get_system_message(self, session_id: str, user_id: Optional[str] = None) ->
29282930
system_message_content += (
29292931
f"<transfer_instructions>\n{self.get_transfer_instructions().strip()}\n</transfer_instructions>\n\n"
29302932
)
2933+
if self.success_criteria:
2934+
system_message_content += "Your task is successful when the following criteria is met:\n"
2935+
system_message_content += "<success_criteria>\n"
2936+
system_message_content += f"{self.success_criteria}\n"
2937+
system_message_content += "</success_criteria>\n"
2938+
system_message_content += "Stop running when the success_criteria is met.\n\n"
29312939
# 3.3.10 Then add memories to the system prompt
29322940
if self.memory:
29332941
if isinstance(self.memory, AgentMemory) and self.memory.create_user_memories:

0 commit comments

Comments
 (0)