Skip to content

YAML configuration ​

YAML configuration builds a live agent from a file of named blocks. The file describes the model, tools, and the features you turn on. yaml_to_agent reads one named block and returns an Agentkit agent.

The loader lives in elsai-yaml. The agent loop still lives in elsai-agents. Import the loader from elsai.config, not from elsai.

Beta

YAML configuration is in beta. The pages here cover what the package can build today. Later releases will add to this file shape.

Keep secrets out of the file

Live clients stay out of the file. Do not put boto_session, client, or keys other than the knowledge credential fields in the YAML. A value can be read from the environment with {{$ENV_VAR:default}}.

These knowledge fields may be set on the block: embedding azure_api_key, aws_access_key_id, aws_secret_access_key, and aws_session_token; vector pinecone_api_key and Weaviate auth_credentials; DocumentParse api_key. A present value must be a non-empty string. Omit the field and the client still reads the environment variable. See RAG.


Installation ​

bash
pip install --upgrade --extra-index-url https://elsai-agents.elsai.ai/root/ "elsai-agents==0.4.4"
pip install --upgrade --extra-index-url https://elsai-agents.elsai.ai/root/ "elsai-yaml==0.4.3"
pip install --extra-index-url https://core-packages.elsai.ai/root/elsai-model/ "elsai-model[openai]==2.1.5"

Install only the extras you use. Each feature page lists its extra.


A basic agent ​

Save this as agent.yaml. It is one model block and one agent that only talks.

yaml
openai:
  type: OpenAIModel
  model_id: "{{$OPENAI_MODEL:gpt-4o-mini}}"

assistant:
  type: Agent
  name: Assistant
  system_prompt: You are a concise assistant.
  model: ${openai}
  tools: []
python
from elsai.config import yaml_to_agent

agent = yaml_to_agent("agent.yaml", entry="assistant")
print(agent("What is the capital of India?"))

Set OPENAI_API_KEY before running. entry is the name of the Agent block. One file can hold several agents.

Add tools, a schema, memory, and the other features from What you can add.


A file of named blocks ​

The file is a map. Each key is a block name. ${block_name} means “use that whole block.” Dotted references such as ${block.field} are rejected.

Several agents can share one model block. Each agent keeps its own system_prompt, tools, and features.

yaml
shared_model:
  type: BedrockModel
  model_id: anthropic.claude-3-5-sonnet-20240620-v1:0
  region_name: us-east-1

support:
  type: Agent
  name: Support
  model: ${shared_model}
  system_prompt: You are customer support.
  tools: []

analyst:
  type: Agent
  name: Analyst
  model: ${shared_model}
  system_prompt: You are a data analyst.
  tools: []

${block_name} inserts that whole block. It is not a path: ${shared_model.model_id} is rejected. {{$ENV_VAR:default}} is separate. The loader replaces it with the environment variable while the file is read, and uses the text after the colon when the variable is unset. Config.fromfile logs those substitutions, so do not put a secret in the default.

An unknown key on a block raises ValueError at build time. A missing file raises FileNotFoundError. A missing entry name raises ValueError.


Other loaders ​

yaml_to_agent builds the agent in A basic agent. These loaders build one piece of the file without building the whole agent:

LoaderBlock it reads
yaml_to_agenttype: Agent
yaml_to_knowledgetype: KnowledgeBaseConfig
yaml_to_graphtype: Graph
yaml_to_workflowtype: Workflow
yaml_to_mcptype: MCPClient
yaml_to_httptype: HTTPTool

What you can add ​

  • Agent — the Agent block
  • Model — which provider the agent calls
  • Tools — prebuilt tools and your own @tool files
  • HTTP tools — an endpoint declared as a tool
  • Structured output — a Pydantic class the answer fills
  • Memory — a conversation window, turn recall, and facts
  • RAG — a document index attached to the agent
  • Guardrails — content checks and tool roles
  • Multi-agent — a graph, a workflow, or an agent used as a tool
  • MCP — tools from an MCP server
  • Plugins — skills, project context, and steering
  • Sandbox — a workspace for shell and file tools

Known limits ​

An Agent block accepts name, description, system_prompt, model, tools, http, structured_output, structured_output_prompt, guardrails, memory, knowledge, mcp, plugins, and the sandbox keys on Sandbox. Hooks and a session manager are not keys on that block. Set those in Python after the agent is built.

system_prompt is a plain string.


Copyright © 2026 elsai foundry.