1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Recursive-language-model (RLM) runtime: a driver model writes code cells
//! executed in a sandboxed interpreter whose only host surface is capability
//! calls back into the [`CapabilityRegistry`](crate::registry::CapabilityRegistry)
//! — sub-LLM queries, tools, and sub-agent delegation. Scripts can therefore
//! *recursively* call language models, which is what turns a code sandbox
//! into an RLM.
//!
//! ## The three layers
//!
//! 1. **[`RlmInterpreter`]** — the pluggable execution API ("the interpreter
//! exposed as an API"). Built-ins: the embedded Rhai engine (hermetic
//! sandbox, the default) and external Python / JavaScript processes
//! (binary + args are configuration; they speak a line-delimited JSON
//! wire protocol, see [`interpreter::external`]).
//! 2. **[`RlmSession`]** — one interpreter bound to one [`RlmHost`], with
//! every [`RlmPolicy`] limit enforced fail-closed per cell. Drive it
//! directly when embedding your own loop.
//! 3. **[`RlmRunner`]** — the model-driven loop: render a template into a
//! system prompt, let the driver model emit fenced code cells, execute,
//! feed observations back, stop on `final_answer(...)`.
//!
//! Everything a run needs is describable as one serde document
//! ([`RlmConfig`]), so external harnesses can define RLM behaviors as
//! configuration rather than code.
//!
//! ```no_run
//! use std::sync::Arc;
//! use tinyagents::registry::CapabilityRegistry;
//! use tinyagents::rlm::{RlmConfig, RlmRunner};
//!
//! # async fn demo() -> tinyagents::Result<()> {
//! let mut registry: CapabilityRegistry<()> = CapabilityRegistry::new();
//! // registry.register_model("openai", Arc::new(model))?; …
//! let config = RlmConfig::from_json(
//! r#"{ "interpreter": {"kind": "rhai"}, "template": "general" }"#,
//! )?;
//! let mut runner = RlmRunner::from_config(config, Arc::new(registry), Arc::new(()))?;
//! let outcome = runner.run("How many primes are there below 1000?").await?;
//! println!("{:?}", outcome.answer);
//! # Ok(()) }
//! ```
pub use ;
pub use ;
pub use ;
pub use RlmSession;
pub use ;