NOMOS provides flexible configuration options through both Python API and YAML files, supporting a spectrum from no-code to full-code development.

Python API Configuration

Basic Agent Setup

from nomos import Agent, AgentConfig
from nomos.models.agent import Step, Route
from nomos.models.flow import FlowConfig
from nomos.llms import LLMConfig
from math import sqrt, pow

def get_time():
    """Get the current time.

    Returns:
        str: The current time in string format.
    """
    from datetime import datetime
    return f"Current time: {datetime.now()}"

steps = [
    Step(
        step_id="start",
        description="Greet and offer to tell the time or perform calculations.",
        available_tools=["get_time", "sqrt"],
        routes=[Route(target="calculation", condition="User wants to do math"),
                Route(target="end", condition="User is done")],
    ),
    Step(
        step_id="calculation",
        description="Perform mathematical calculations for the user.",
        available_tools=["sqrt", "pow"],
        routes=[Route(target="end", condition="Calculation is complete")],
    ),
    Step(
        step_id="end",
        description="Say goodbye.",
    ),
]

# Define flows for better organization
flows = [
    FlowConfig(
        flow_id="math_workflow",
        description="Handle mathematical calculations",
        enters=["calculation"],
        exits=["end"],
        components={
            "memory": {
                "llm": {"provider": "openai", "model": "gpt-4o-mini"},
                "retriever": {"method": "embedding", "kwargs": {"k": 3}}
            }
        }
    )
]

config = AgentConfig(
    name="clockbot",
    llm=LLMConfig(provider="openai", model="gpt-4o-mini"),
    steps=steps,
    flows=flows,
    start_step_id="start",
    persona="You are a friendly assistant that can tell time and perform calculations.",
    max_errors=3,
    max_iter=10,
)

agent = Agent.from_config(config, tools=[get_time, sqrt, pow])
session = agent.create_session()
# ... interact with session.next(user_input)

YAML Configuration

Basic YAML Config

name: utility-bot
persona: You are a helpful utility bot that can perform various calculations and data operations.
steps:
  - step_id: start
    description: Handle user requests for mathematical operations or data processing.
    available_tools:
      - sqrt
      - load_json
      - combinations
    routes:
      - target: end
        condition: User is done with calculations
  - step_id: end
    description: Say goodbye to the user.
start_step_id: start
max_errors: 3  # Maximum consecutive errors before stopping
max_iter: 10  # Maximum iterations per interaction

Advanced YAML Configuration

Barista Agent Example

See a comprehensive configuration example

LLM Configuration

Supported Providers

from nomos.llms import LLMConfig
llm = LLMConfig(provider="openai", model="gpt-4o-mini")

YAML LLM Configuration

llm:
  provider: openai
  model: gpt-4o-mini

Generate YAML Schema

Create a JSON schema for your configuration to enable editor validation and autocompletion:

nomos schema --output agent.schema.json

Include the schema in your YAML file:

# yaml-language-server: $schema=./agent.schema.json

Tool Configuration

New in v0.2.4: You can now specify tools directly in your agent configuration file

name: my-agent
persona: A helpful assistant
steps:
  - step_id: start
    # ... step configuration
start_step_id: start

# Tool configuration - NEW in v0.2.4
tools:
  tool_files:
    - "barista_tools.py"    # Python module
    - "tools.my_tools"      # File path
  external_tools:
    - tag: "@pkg/itertools.combinations"
      name: "combinations"
    - tag: "@crewai/FileReadTool"
      name: "file_read_tool"
    - tag: "@langchain/google_search"
      name: "google_search"
  tool_arg_descriptions:
    add_to_cart:
      coffee_type: "Coffee type (e.g., Espresso, Latte, Cappuccino)"
      size: "Size of the coffee (Small, Medium, Large)"

Custom Tool Files

You can organize your own tools in Python modules:

# tools/my_tools.py
def greet(name: str) -> str:
    """Return a simple greeting."""
    return f"Hello {name}!"

tools = [greet]

Tool Loading Options

Step Examples

You can provide decision examples for any step. Each example contains the user context and the expected decision. NOMOS retrieves relevant examples using embeddings and includes them in the system prompt to guide the model.

steps:
  - step_id: start
    description: Initial step
    examples:
      - context: "User asks for the time"
        decision: "Answer with the current time."
        visibility: always
      - context: "sqrt 4"
        decision: "Call sqrt tool"
        visibility: dynamic

Use the max_examples and threshold settings in AgentConfig to control how many examples are displayed and the minimum similarity required.

Error Handling Configuration

name: my-agent
# ... other config
max_errors: 3  # Maximum consecutive errors before stopping
max_iter: 10   # Maximum iterations per interaction

Environment Variables

Common environment variables for NOMOS agents:

VariableDescriptionRequired
OPENAI_API_KEYOpenAI API keyIf using OpenAI
MISTRAL_API_KEYMistral API keyIf using Mistral
GOOGLE_API_KEYGoogle API keyIf using Gemini
HUGGINGFACE_API_TOKENHuggingFace tokenIf using HuggingFace
ANTHROPIC_API_KEYAnthropic API keyIf using Anthropic

Configuration Examples

More configuration examples are available in the cookbook: