> ## Documentation Index
> Fetch the complete documentation index at: https://doc.agent-l.integria.app/llms.txt
> Use this file to discover all available pages before exploring further.

# API Python

> Imports publics du Core pour intégrer AGENT-L dans un hôte ou un service Python.

Le paquet expose ses primitives stables depuis `agentl`.

```python theme={"theme":{"light":"github-light","dark":"vesper"}}
from agentl import (
    Analyzer,
    Host,
    MockLLM,
    Runtime,
    parse_file,
    verify,
)
```

## Parser et analyser

```python theme={"theme":{"light":"github-light","dark":"vesper"}}
from agentl import Analyzer, parse_file, parse_source

program = parse_file("agent.agent")
agent = program.agents[0]
diagnostics = Analyzer(agent).run()

inline = parse_source("AGENT EMPTY { GOAL done { ACHIEVE ok == yes } }")
```

Pour un programme multi-agents, `check_program(program)` complète les diagnostics propres à chaque agent par les contrôles transverses.

## Exécuter

```python theme={"theme":{"light":"github-light","dark":"vesper"}}
from agentl import Host, MockLLM, Runtime, Symbol, parse_file

agent = parse_file("service_guard.agent").agents[0]
host = Host()

host.sensors["service.status"] = lambda: Symbol("healthy")

runtime = Runtime(agent, host, MockLLM())
runtime.run(max_ticks=4)
trace = runtime.trace
```

`Runtime` conserve son `state`, son moteur `policy` et sa trace. Les phases sont aussi disponibles séparément pour les inspections contrôlées.

## Vérifier

```python theme={"theme":{"light":"github-light","dark":"vesper"}}
from agentl import parse_file, verify

agent = parse_file("agent.agent").agents[0]
report = verify(agent)

for theorem in report.theorems:
    print(theorem)
```

La bibliothèque accepte un agent construit en mémoire. Contrairement à la CLI, elle ne force pas automatiquement `check` avant `verify`; l’appelant doit conserver cet ordre lorsqu’il publie un verdict utilisateur.

## Politiques

```python theme={"theme":{"light":"github-light","dark":"vesper"}}
from agentl import ActionRequest, PolicyEngine
```

`PolicyEngine` évalue les requêtes contre l’état. `ActionRequest` porte notamment le nom de l’outil, les arguments, l’origine et la confiance.

## Inférence et planification

```python theme={"theme":{"light":"github-light","dark":"vesper"}}
from agentl import Inference, Planner, infer, reachable_range
```

* `infer` calcule le postérieur d’une hypothèse sur un état ;
* `reachable_range` calcule l’intervalle atteignable ;
* `Planner.synthesize(state)` cherche une route compatible avec les opérateurs et la politique.

## Sociétés

```python theme={"theme":{"light":"github-light","dark":"vesper"}}
from agentl import MockLLM, Society

society = Society(
    program.agents,
    hosts={"analyst": analyst_host, "responder": responder_host},
    llms={"analyst": MockLLM(), "responder": MockLLM()},
)
society.run(max_ticks=6)
```

## Enregistrer et rejouer

```python theme={"theme":{"light":"github-light","dark":"vesper"}}
from agentl import (
    Journal,
    RecordingHost,
    RecordingLLM,
    ReplayHost,
    ReplayLLM,
    verify_trace,
)
```

Les wrappers enregistrent ou rejouent les lectures, outils, approbations et réponses LLM. `ReplayDivergence` signale un appel qui ne correspond plus au journal.

## Objets publics

<AccordionGroup>
  <Accordion title="Programme et état">
    `Agent`, `Program`, `State`, `Belief`, `Evaluator`, `Symbol`, `UNDEFINED`.
  </Accordion>

  <Accordion title="Analyse et preuve">
    `Analyzer`, `Diagnostic`, `Verifier`, `Report`, `Theorem`, `entails`, `satisfiable`.
  </Accordion>

  <Accordion title="Runtime">
    `Host`, `LLM`, `MockLLM`, `AnthropicLLM`, `Runtime`, `Trace`, `Society`.
  </Accordion>

  <Accordion title="Erreurs">
    `AgentLError`, `ParseError`, `ReplayError`, `ReplayDivergence`.
  </Accordion>
</AccordionGroup>

<Warning>
  `AnthropicLLM` nécessite l’option `anthropic`. Le Core et `MockLLM` n’ont aucune dépendance externe.
</Warning>
