Mini-project: Production-ready research & briefing agent

Combine tools, schema, caching, execution caps, and guardrails

Put the flagship Agents course together in one clean script: an agent equipped with a custom data tool, CachingConfig, ExecutionConfig budget cap, strict Pydantic validation, and a deterministic guardrail.

Example

from pydantic import BaseModel
from praisonai import Agent, CachingConfig, ExecutionConfig

METRICS = {'checkout': {'p95_ms': 142, 'error_rate': 0.002}}

def fetch_service_metrics(service: str) -> str:
    """Return latency and error rate for an internal service."""
    return f'{service}: {METRICS.get(service, "unknown")}'

class ServiceBrief(BaseModel):
    service: str
    healthy: bool
    summary: str

ops_agent = Agent(
    name='ServiceBriefAgent',
    instructions='Call fetch_service_metrics and return a ServiceBrief summary.',
    tools=[fetch_service_metrics],
    caching=CachingConfig(enabled=True, prompt_caching=True),
    execution=ExecutionConfig(max_iter=4, max_budget=0.05, context_compaction=True),
    output='silent',
)
brief = ops_agent.chat('Check checkout service health (healthy if error_rate < 0.01)', output_pydantic=ServiceBrief)
print('Verified brief:', brief.model_dump())

Try it Yourself

Example explained

  • fetch_service_metrics — Grounds the agent in exact operational numbers rather than guessing.
  • ServiceBrief.model_validate_json(…) — Guarantees typed output ready for Slack alerts or monitoring dashboards.
  • CachingConfig + ExecutionConfig — Pairs cost optimization with hard iteration and $0.05 budget caps.

Where to go next

You now master the core PraisonAI Agent class. Head to Specialized agents next for Vision, OCR, Audio, Video, DeepResearch, and AutoAgents — or AgentFlow to wire multi-step graphs.

Reference: documentation