What are agents?
Agents in Marvin are configurable AI entities, each with its own identity, capabilities, and even personality. They act as the “workers” in your AI workflows, responsible for executing tasks and making decisions based on their assigned instructions and available tools. You can think of each agent as a portable LLM configuration. When you assign an agent to a task, they will work to complete it according to the instructions and tools you provide.Creating agents
To create an agent, use theAgent
class:
Agent properties
Name
An agent’s name is an identifier that is visible to other agents in the workflow. It is used to distinguish between agents and for logging and debugging purposes. If no name is provided, one will be randomly chosen from a list of famous AI characters.Description
A description is a brief summary of the agent’s role or specialization. This information is visible to other agents, and helps them understand the agent’s capabilities and expertise.Instructions
Instructions are specific instructions or guidelines for the agent to follow during task execution. These instructions are private and not shared with other agents.Tools
Tools are Python functions that the agent can call to perform specific actions or computations. They are defined as a list of functions when creating an agent, and can be used to enhance the agent’s capabilities. The agent will have access to these tools in every task they are assigned to. If a task defines additional tools, the agent will have access to those as well.Model
Each agent has a model, which is the LLM that powers the agent responses. This allows you to choose the most suitable model for your needs, based on factors such as performance, latency, and cost. Marvin supports any model that is compatible with Pydantic AI. You can specify models using a string format like “openai:gpt-4” or by providing a Model instance:Model Settings
You can customize the behavior of an agent’s model using themodel_settings
parameter. This allows you to configure settings like temperature, top_p, etc:
Memories
Agents can be configured with memories that provide additional context or knowledge. These memories persist across tasks and can be used to store and retrieve relevant information:Delegates
Agents can be configured with a list of other agents that they can delegate work to. This is particularly useful when working with teams of agents:Assigning agents to tasks
Agents must be assigned to tasks in order to work on them. You can assign agents by passing them to theagents
parameter when creating a task:
say
method for simple conversational interactions: