Résumé IA
Cet article présente un cadre complet pour créer des agents intelligents autonomes (agentic AI) de prochaine génération. Il définit des plans cognitifs structurés pour l'identité, les objectifs, la planification, la mémoire, la validation et l'accès aux outils. Ces agents peuvent non seulement répondre, mais aussi planifier, exécuter, valider et améliorer systématiquement leurs sorties. Le même moteur d'exécution peut soutenir plusieurs personnalités et comportements d'agent grâce à la portabilité des plans, rendant ainsi le design modulaire, étendu et pratique pour l'expérimentation de l'agentic AI avancée.
Impact France/UECet article propose un cadre pour construire des agents d'IA autonomes, potentiellement influençant les secteurs de l'automatisation et de l'intelligence artificielle en France et dans l'UE, en améliorant l'efficacité des systèmes basés sur l'IA, tout en respectant les réglementations comme le RGPD et l'AI Act.
In this tutorial, we build a complete cognitive blueprint and runtime agent framework. We define structured blueprints for identity, goals, planning, memory, validation, and tool access, and use them to create agents that not only respond but also plan, execute, validate, and systematically improve their outputs. Along the tutorial, we show how the same runtime engine can support multiple agent personalities and behaviors through blueprint portability, making the overall design modular, extensible, and practical for advanced agentic AI experimentation. Copy Code Copied Use a different Browser import json, yaml, time, math, textwrap, datetime, getpass, os from typing import Any, Callable, Dict, List, Optional from dataclasses import dataclass, field from enum import Enum from openai import OpenAI from pydantic import BaseModel from rich.console import Console from rich.panel import Panel from rich.table import Table from rich.tree import Tree try: from google.colab import userdata OPENAI_API_KEY = userdata.get('OPENAI_API_KEY') except Exception: OPENAI_API_KEY = getpass.getpass(" Enter your OpenAI API key: ") os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY client = OpenAI(api_key=OPENAI_API_KEY) console = Console() class PlanningStrategy(str, Enum): SEQUENTIAL = "sequential" HIERARCHICAL = "hierarchical" REACTIVE = "reactive" class MemoryType(str, Enum): SHORT_TERM = "short_term" EPISODIC = "episodic" PERSISTENT = "persistent" class BlueprintIdentity(BaseModel): name: str version: str = "1.0.0" description: str author: str = "unknown" class BlueprintMemory(BaseModel): type: MemoryType = MemoryType.SHORT_TERM window_size: int = 10 summarize_after: int = 20 class BlueprintPlanning(BaseModel): strategy: PlanningStrategy = PlanningStrategy.SEQUENTIAL max_steps: int = 8 max_retries: int = 2 think_before_acting: bool = True class BlueprintValidation(BaseModel): require_reasoning: bool = True min_response_length: int = 10 forbidden_phrases: List[str] = [] class CognitiveBlueprint(BaseModel): identity: BlueprintIdentity goals: List[str] constraints: List[str] = [] tools: List[str] = [] memory: BlueprintMemory = BlueprintMemory() planning: BlueprintPlanning = BlueprintPlanning() validation: BlueprintValidation = BlueprintValidation() system_prompt_extra: str = "" def load_blueprint_from_yaml(yaml_str: str) -> CognitiveBlueprint: return CognitiveBlueprint(**yaml.safe_load(yaml_str)) RESEARCH_AGENT_YAML = """ identity: name: ResearchBot version: 1.2.0 description: Answers research questions using calculation and reasoning author: Auton Framework Demo goals: - Answer user questions accurately using available tools - Show step-by-step reasoning for all answers - Cite the method used for each calculation constraints: - Never fabricate numbers or statistics - Always validate mathematical results before reporting - Do not answer questions outside your tool capabilities tools: - calculator - unit_converter - date_calculator - search_wikipedia_stub memory: type: episodic window_size: 12 summarize_after: 30 planning: strategy: sequential max_steps: 6 max_retries: 2 think_before_acting: true validation: require_reasoning: true min_response_length: 20 forbidden_phrases: - "I don't know" - "I cannot determine" """ DATA_ANALYST_YAML = """ identity: name: DataAnalystBot version: 2.0.0 description: Performs statistical analysis and data summarization author: Auton Framework Demo goals: - Compute descriptive statistics for given data - Identify trends and anomalies - Present findings clearly with numbers constraints: - Only work with numerical data - Always report uncertainty when sample size is small (< 5 items) tools: - calculator - statistics_engine - list_sorter memory: type: short_term window_size: 6 planning: strategy: hierarchical max_steps: 10 max_retries: 3 think_before_acting: true validation: require_reasoning: true min_response_length: 30 forbidden_phrases: [] """ We set up the core environment and define the cognitive blueprint, which structures how an agent thinks and behaves. We create strongly typed models for identity, memory configuration, planning strategy, and validation rules using Pydantic and enums. We also define two YAML-based blueprints, allowing us to configure different agent personalities and capabilities without changing the underlying runtime system. Copy Code Copied Use a different Browser @dataclass class ToolSpec: name: str description: str parameters: Dict[str, str] function: Callable returns: str class ToolRegistry: def __init__(self): self._tools: Dict[str, ToolSpec] = {} def register(self, name: str, description: str, parameters: Dict[str, str], returns: str): def decorator(fn: Callable) -> Callable: self._tools[name] = ToolSpec(name, description, parameters, fn, returns) return fn return decorator def get(self, name: str) -> Optional[ToolSpec]: return self._tools.get(name) def call(self, name: str, **kwargs) -> Any: spec = self._tools.get(name) if not spec: raise ValueError(f"Tool '{name}' not fou