Normandy.DSL.Agent (normandy v0.2.0)
View SourceDSL 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
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
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.