Appearance
YAML configuration API
Field lists for YAML configuration. The import path is elsai.config. For when to use each block, see YAML configuration.
Installation
bash
pip install --upgrade --extra-index-url https://elsai-agents.elsai.ai/root/ "elsai-yaml==0.4.3"Loaders
| Function | Signature | Returns |
|---|---|---|
yaml_to_agent | (path, entry, *, memory_run_id=None, on_agent_built=None) | An Agent |
yaml_to_knowledge | (path, entry) | A knowledge base |
yaml_to_graph | (path, entry, *, on_agent_built=None) | A graph |
yaml_to_workflow | (path, entry, *, on_agent_built=None) | A WorkflowPipeline |
yaml_to_mcp | (path, entry) | An unstarted MCPClient |
yaml_to_http | (path, entry) | One HTTP agent tool |
path is a YAML file of named blocks. entry is the block name. A missing file raises FileNotFoundError. A missing block, a wrong type, or an unknown key raises ValueError.
memory_run_id overrides MemoryConfig.run_id. It requires a memory field on the agent.
on_agent_built is an optional (entry, agent) hook on yaml_to_agent, yaml_to_graph, and yaml_to_workflow. It runs after each Agent block in that build is constructed, including a specialist, and before that agent is wrapped as a tool. A cached block is not reported again.
${name} inserts a whole named block. ${name.field} is rejected. {{$ENV_VAR:default}} reads an environment variable while the file loads. Secret fields and live clients (boto_session, client, API key fields) are rejected.
Agent block
type: Agent is required.
| Key | Form |
|---|---|
name, description | String |
system_prompt | String |
model | ${block}, an inline {type: <Model>, ...} map, or a Bedrock model id string |
tools | List of elsai_tools.* modules, ./file.py paths, or AgentAsTool maps |
http | List of HTTPTool maps or ${block} refs. See HTTP |
structured_output | module:Class pointing at a Pydantic BaseModel |
structured_output_prompt | String |
guardrails | Map or ${block} |
memory | Map or ${block} |
knowledge | Map. See Knowledge |
mcp | List of MCPClient maps or ${block} refs |
plugins | List of plugin maps or ${block} refs. See Plugins |
sandbox_mode | sandbox or local_dev |
execution_backend | Backend map or ${block} |
workspace_root | Host directory for the direct sandbox path |
workspace_sync_policy | exclude_patterns and sync_include_patterns |
sandbox_manager | {ttl_seconds} |
sandbox | type: Sandbox map or ${block} |
sandbox_attach_mode | read_write or read_only |
sandbox_output_offload | Offload policy. See Sandbox |
Model type values: BedrockModel, AnthropicModel, AnthropicBedrockModel, OpenAIModel, OpenAIResponsesModel, AzureOpenAIModel, GeminiModel, LiteLLMModel, MistralModel, OllamaModel, LlamaCppModel, LlamaAPIModel, SageMakerAIModel, WriterModel.
AgentAsTool
| Key | Meaning |
|---|---|
type | AgentAsTool |
agent | ${block} of an Agent |
mode | queue, reject, or spawn |
preserve_context | Whether the specialist sees the supervisor's context |
name, description | Tool name and description shown to the supervisor |
HTTP
type: HTTPTool. Attach with http: on an Agent block. yaml_to_http(path, entry) builds one tool and no agent. Needs elsai-agents 0.4.1 or later. agent.cleanup() closes clients the loader created.
| Key | Required | Meaning |
|---|---|---|
name | yes | Letters, digits, _, -, at most 64 characters |
description | yes | Non-empty string |
endpoint | yes | Absolute http or https URL |
method | yes | GET, POST, PUT, PATCH, or DELETE |
parameters | Map of name to a JSON Schema object | |
required | List of parameter names declared in parameters | |
defaults | Map of parameter name to a value | |
headers | String map | |
send | body or query. Omit it and POST, PUT, and PATCH use a JSON body. GET and DELETE use query parameters | |
timeout_seconds | Number greater than 0. Default 30 | |
credential | String. Use {{$ENV_VAR:}} | |
credential_in | header, query, or body | |
credential_name | Non-empty string | |
credential_template | String. {} is the credential value. Used for a header | |
output_schema | JSON Schema object. The response is not validated against it |
client is rejected. The same ${block} may be listed once per agent.
Memory
A named leaf requires type: MemoryConfig. An inline map may omit type.
| Key | Required | Meaning |
|---|---|---|
run_id | yes | Conversation id. Session key is {run_id}:{role} |
pipeline | yes | Non-empty list of steps |
role | Defaults to default | |
persistence | elsai_file or elsai_json | |
file_store_dir | Folder for elsai_file | |
elsai_store_dir | Folder for elsai_json | |
summarizer_llm | Model leaf for ElsaiSummarizationStep | |
similarity | Turn recall. See below | |
semantic | Fact recall | |
semantic_llm | Model used while extracting facts | |
semantic_strategy | How facts are stored |
metadata_filter and multiagent_mode on the memory map are rejected. window_size on the map is rejected.
| Step | Store | Fields |
|---|---|---|
ElsaiSlidingStep | elsai_file | window_size, should_truncate_results |
ElsaiSummarizingStep | elsai_file | preserve_recent_messages, summary_ratio |
ElsaiTrimmingStep | elsai_json | max_messages, max_tokens, preserve_recent, preserve_system |
ElsaiSummarizationStep | elsai_json | trigger_count, preserve_system. Requires summarizer_llm |
ElsaiLRUStep | elsai_json | max_messages, preserve_system, preserve_recent |
ElsaiTTLStep | elsai_json | ttl_seconds, preserve_system, preserve_recent, use_last_accessed |
ElsaiSimilarityStep | elsai_json | No step fields. Requires sibling similarity |
At most one shaping step (ElsaiTrimmingStep, ElsaiSummarizationStep, ElsaiLRUStep, ElsaiTTLStep). Native steps and shaping steps cannot share a pipeline. ElsaiSimilarityStep cannot sit beside either. Use similarity: next to a shaping step instead.
similarity
| Key | Meaning |
|---|---|
embedding | ${block} or inline EmbeddingBackend. Required |
vector | ${block} or inline VectorBackend. Required |
top_k | Matches to inject |
injection_mode | system_append or user_preamble |
metadata_filter | Filter on stored message metadata |
semantic and semantic_strategy
semantic keys: user_id_key, injection_mode, query_from_last_user_message.
semantic_strategy keys: embedding, vector, llm, trigger_count, collection_name, namespace, top_k, similarity_threshold.
EmbeddingBackend and VectorBackend
| Provider | Keys |
|---|---|
bedrock | model_name, aws_region. Optional: aws_access_key_id, aws_secret_access_key, aws_session_token |
azure | model, azure_endpoint, azure_api_version, azure_deployment. Optional: azure_api_key |
chroma | collection_name, persist_directory |
pinecone | index_name, namespace, dimension. Optional: pinecone_api_key |
weaviate | collection_name, connection_type, host, port or cluster_url, schema, use_default_vectorizer, distance. Optional: auth_credentials |
A present credential must be a non-empty string. Omit it and the client still reads the environment variable.
Knowledge
type: KnowledgeBaseConfig. Required: chunking, embedding, vector, retrieval.
| Key | Meaning |
|---|---|
name, description | Labels |
chunking | strategy (characters or tokens, default characters), chunk_size, chunk_overlap |
embedding, vector | Backend leaves |
retrieval | strategy (hybrid or dense, default hybrid), top_k (at least 1, default 5), metadata_filter |
model | Model leaf. Required for a written answer and for agentic attach |
system_prompt | Instruction for the written answer |
structured_output | module:Class. Requires model |
structured_output_prompt | Extra instruction for that schema |
parser | type: DocumentParse. Required for PDF |
elsai_kb_store_dir | Sidecar directory. Required for Pinecone and Weaviate |
parser keys: num_workers, verbose, auto_routing, provider, model, include_detailed_structure, optional api_key. A present api_key must be a non-empty string. Omit it and Docloom reads DOCUMENT_EXTRACTOR_API_KEY.
Agent knowledge: keys:
| Key | Meaning |
|---|---|
base | ${block} of a KnowledgeBaseConfig. Required |
mode | basic or agentic |
injection_mode | system_append or user_preamble |
agentic.max_rounds | Required when mode is agentic, and at least 1 |
Guardrails
type: GuardrailSystem on a named leaf.
| Key | Meaning |
|---|---|
input_checks, output_checks | Check the user prompt, and assistant prose |
check_toxicity, check_sensitive_data, check_semantic | Which classifiers run |
check_off_topic, check_sql_syntax | Topic and SQL checks |
toxicity_threshold | Toxicity cutoff |
block_toxic, block_sensitive_data, block_off_topic | Block when that check fails |
allowed_topics | Topics kept when off-topic checking is on |
sql_dialect | Dialect for the SQL check |
tool_authorization | Role rules. See below |
tool_authorization
| Key | Meaning |
|---|---|
enabled | Turn authorization on |
denied_tools | Blocked for every role. Tool names, not import paths |
sensitive_tools | Need invocation_state["guardrail_metadata"] |
roles.<name>.allowed_tools | Tools that role may call |
default_role | Used when the call has no user_role |
Graph
type: Graph. nodes is a non-empty map of node id to an Agent ${block}. edges is a list of {from, to}.
| Key | Meaning |
|---|---|
name, graph_id | Labels |
entry_points | Node ids where a run can start |
max_node_executions | Cap on node runs |
execution_timeout, node_timeout | Time limits |
reset_on_revisit | Whether a revisited node resets |
condition on an edge is rejected. session_manager, hooks, hook_providers, and plugins are rejected.
Call the graph with graph(prompt).
Workflow
type: Workflow. steps is a non-empty list. An item is an Agent ${block}, or parallel: with a list of Agent refs.
| Key | Meaning |
|---|---|
name | Label |
prompt_template | Prompt for each sequential step. Placeholders: input, previous_output, step_index |
merge_template | Text after a parallel group. Placeholders: input, step_0…, parallel_0… |
pipeline(task) returns the final text. pipeline.run_traced(task) returns (final_text, traces).
MCP
type: MCPClient. transport defaults to stdio.
| Key | Transports | Meaning |
|---|---|---|
command | stdio | Required. Executable |
args, env, cwd | stdio | Process arguments, environment, working directory |
server_url | sse, streamable_http | Required. http or https |
headers | sse, streamable_http | String map |
timeout, sse_read_timeout | sse, streamable_http | Positive numbers |
terminate_on_close | streamable_http | Boolean |
startup_timeout | all | Positive number |
prefix | all | Prepended to tool names. Letters, digits, _, -, at most 62 characters |
tool_filters | all | allowed and rejected lists of tool names |
use_cache, cache_dir | all | Tool-list cache |
tasks_config | all | ttl and poll_timeout as durations |
elicitation_callback, auth, transport_callable, and client are rejected.
Plugins
plugins: is a list of inline maps or ${block} refs. One of each type per agent. A Graph or Workflow block rejects plugins:.
AgentSkills
| Key | Required | Meaning |
|---|---|---|
skills | yes | A path, an https:// URL, or a list of those |
strict | Boolean. Default false. true raises on a bad source and needs elsai-agents 0.4.2 | |
state_key | Non-empty string. Default agent_skills | |
max_resource_files | Positive integer. Default 20 |
AgentsMdPlugin
| Key | Meaning |
|---|---|
path | One AGENTS.md file. Hierarchy keys are ignored |
start_path | Where the upward walk starts. When path and start_path are both omitted, discovery starts at the YAML file directory |
root | Upper boundary. An ancestor of start_path |
merge_hierarchy | Boolean. Default true |
max_files | Positive integer or null. Default 3 |
on_exceed | warn (default) or error |
state_key | Non-empty string. Default agents_md |
LLMSteeringHandler
| Key | Required | Meaning |
|---|---|---|
system_prompt | yes | Non-empty string |
model | Model block, same forms as an Agent model | |
context_providers | List of {type: LedgerProvider}. Omit for the ledger. [] turns it off |
A second LedgerProvider is rejected. Resume an interrupt on the same agent with interruptResponse.
SandboxPlugin
| Key | Meaning |
|---|---|
type | SandboxPlugin. No other keys |
type: GuardrailsPlugin is rejected. Set guardrails: on the Agent block.
Sandbox
A direct sandbox (sandbox_mode plus execution_backend) and a shared sandbox (sandbox) cannot be combined. Either one requires type: SandboxPlugin. sandbox_mode: off is rejected. local_dev requires LocalSandboxBackend.
A shared Sandbox is not started while the file loads. The first run starts it. That needs elsai-agents 0.4.2. Inside one yaml_to_graph or yaml_to_workflow build, agents that reference the same named block share one sandbox.
Sandbox
| Key | Required | Meaning |
|---|---|---|
workspace_id | yes | Non-empty string |
backend | yes | A backend map or ${block} |
ttl_seconds | yes | Positive number |
seed_from, sync_dest | Filesystem paths | |
seed_exclude | List of strings | |
sync_policy | exclude_patterns and sync_include_patterns |
Backends
type | Required | Other keys |
|---|---|---|
LocalSandboxBackend | workspace_root | timeout, max_output_bytes (positive integers), inherit_env (boolean), env (string map) |
AgentCoreSandboxTemplate | region, identifier, session_timeout_seconds. Extra agent-core-code-interpreter | |
DaytonaSandboxTemplate | api_key, api_url, target, default_timeout, sync_polling_interval. Extra sandbox-daytona |
Leave api_key unset and set DAYTONA_API_KEY in the environment.
sandbox_output_offload
Requires a direct or shared sandbox. preview_tokens must be lower than max_result_tokens.
| Key | Default | Meaning |
|---|---|---|
storage | required | InMemoryStorage, FileStorage (artifact_dir, default artifacts), or S3Storage (bucket, optional prefix, region_name) |
max_result_tokens | 2500 | Positive integer |
preview_tokens | 1000 | Non-negative integer |
include_retrieval_tool | Boolean | |
tool_names | Non-empty list drawn from execute, read_file, write_file, list_dir |