Normandy.DSL.Agent (normandy v0.2.0)

View Source

DSL for defining AI agents with a clean, declarative syntax.

Provides macros to simplify agent creation with sensible defaults and expressive configuration options.

Examples

defmodule MyResearchAgent do
  use Normandy.DSL.Agent

  agent do
    name "Research Agent"
    description "Conducts research and analysis"

    model "claude-3-5-sonnet-20241022"
    temperature 0.7
    max_tokens 4096

    system_prompt """
    You are a helpful research assistant.
    Provide thorough, well-researched answers.
    """

    # Optional: Define tools
    tool CalculatorTool
    tool SearchTool
  end
end

# Create an instance
{:ok, agent} = MyResearchAgent.new(client: my_client)

# Run the agent
{updated_agent, response} = MyResearchAgent.run(agent, "Research quantum computing")

Without DSL (for comparison)

config = %{
  client: my_client,
  model: "claude-3-5-sonnet-20241022",
  temperature: 0.7,
  max_tokens: 4096
}

agent = Normandy.Agents.BaseAgent.init(config)
# ... configure system prompt, tools, etc.

Features

  • Clean, declarative syntax
  • Sensible defaults
  • Compile-time validation
  • Generated helper functions
  • Tool registration support
  • Memory management helpers

Summary

Functions

Defines an agent configuration block.

Sets the background context.

Sets the agent description.

Sets the maximum number of messages in memory.

Sets the max tokens.

Sets the LLM model.

Sets the agent name.

Sets the output instructions.

Sets the internal steps.

Sets the system prompt.

Sets the temperature.

Registers a tool module.

Functions

agent(list)

(macro)

Defines an agent configuration block.

Available Options

  • name - Agent name (optional)
  • description - Agent description (optional)
  • model - LLM model to use (required)
  • temperature - Sampling temperature 0.0-1.0 (default: 0.7)
  • max_tokens - Maximum tokens in response (default: 4096)
  • system_prompt - System prompt text (optional)
  • background - Background context for prompt (optional)
  • steps - Internal reasoning steps (optional)
  • output_instructions - Output formatting instructions (optional)
  • tool - Register a tool module (can be called multiple times)
  • max_messages - Maximum messages in memory (optional)

Examples

agent do
  name "My Agent"
  model "claude-3-5-sonnet-20241022"
  temperature 0.8

  system_prompt "You are helpful."
end

background(value)

(macro)

Sets the background context.

description(value)

(macro)

Sets the agent description.

max_messages(value)

(macro)

Sets the maximum number of messages in memory.

max_tokens(value)

(macro)

Sets the max tokens.

model(value)

(macro)

Sets the LLM model.

name(value)

(macro)

Sets the agent name.

output_instructions(value)

(macro)

Sets the output instructions.

steps(value)

(macro)

Sets the internal steps.

system_prompt(value)

(macro)

Sets the system prompt.

temperature(value)

(macro)

Sets the temperature.

tool(module)

(macro)

Registers a tool module.