Builtins API Reference
SelfReference
Constructor
Key Methods
| Method | Description |
|---|---|
bind_history(key, history) | Bind a conversation history to a memory key |
get_history(key) | Get the current history for a key |
get_experiences(key) | Get stored experiences for a key |
Memory Key Isolation
Each key has independent state:- History (conversation transcript)
- Experiences (durable facts)
- Summary state (compaction checkpoints)
- Fork handles (child agent state)
Usage with @llm_chat
Runtime Primitives (via PyRepl)
When SelfRef is active, these are available inexecute_code:
PyRepl
Constructor
| Parameter | Default | Description |
|---|---|---|
working_directory | None (cwd) | Working directory for the REPL process |
Properties
| Property | Type | Description |
|---|---|---|
.toolset | List[Tool] | The two tools: execute_code + reset_repl |
Methods
| Method | Description |
|---|---|
install_primitive_pack(pack) | Register a PrimitivePack in this REPL |
get_runtime_backend(name) | Get an installed backend by pack namespace |
reset() | Clear REPL variables (preserves backends) |
Tools Provided
execute_code
execute_code returns a natural-language summary. If code outputs images through display(Image(...)), an image-rich last expression, or ImgPath(...) / ImgUrl(...), the tool result becomes multimodal so the model can inspect the image.
reset_repl
Example
Custom Events
| Event Name | Data | Description |
|---|---|---|
kernel_stdout | {"text": str} | Real-time stdout line |
kernel_stderr | {"text": str} | Real-time stderr line |
Execution Limits
| Setting | Default |
|---|---|
| Execution timeout | 600 seconds |
| Input idle timeout | 300 seconds |
| Output truncation | ~20,000 tokens → temp file |
FileToolset
Constructor
workspace. Path traversal above workspace is rejected.
Properties
| Property | Type | Description |
|---|---|---|
.toolset | List[Tool] | The 5 file tools |
Tools Provided
read_file
<lineno> | <content>.
read_image
grep
path_pattern scopes which files to search.
sed
echo_into
Stale-Write Protection
FileToolset tracks file hashes on read. If a file was modified externally between read and write,sed and echo_into will reject the write and ask the agent to re-read.