On a task
Attach short_enough
Pass the function as guardrails on the Task. The team runs the agent, then the function checks the result.
The same pair decides whether the task result stands.
Example
from praisonai import Agent, Task, AgentTeam
def short_enough(output):
text = output.raw
if len(text) <= 400:
return (True, output)
return (False, "Too long")
agent = Agent(instructions="Answer in one sentence.")
task = Task(
description="What is an agent?",
expected_output="One sentence",
agent=agent,
guardrails=short_enough,
)
print(AgentTeam(agents=[agent], tasks=[task]).start())Example explained
- guardrails — The function Task should call with the result.
Reference: documentation