# `Mojentic.Agents.BaseLLMAgent`
[🔗](https://github.com/svetzal/mojentic-ex/blob/v1.2.0/lib/mojentic/agents/base_llm_agent.ex#L1)

A basic LLM agent with behaviour, tools, and broker.

This agent encapsulates an LLM broker, a set of tools, and behavioural
instructions, providing a complete agent that can be used standalone or
wrapped as a tool for delegation patterns.

## Examples

    alias Mojentic.Agents.BaseLLMAgent
    alias Mojentic.LLM.Broker

    broker = Broker.new("qwen3:7b", Mojentic.LLM.Gateways.Ollama)

    agent = BaseLLMAgent.new(
      broker: broker,
      behaviour: "You are a helpful historian specializing in ancient civilizations.",
      tools: [DateResolver]
    )

    {:ok, response} = BaseLLMAgent.generate_response(agent, "When was Rome founded?")

# `t`

```elixir
@type t() :: %Mojentic.Agents.BaseLLMAgent{
  behaviour: String.t(),
  broker: Mojentic.LLM.Broker.t(),
  tools: [module()] | nil
}
```

# `create_initial_messages`

Creates initial messages from the agent's behaviour.

Returns a list containing the system message with the agent's behaviour.

## Examples

    iex> agent = BaseLLMAgent.new(broker: broker, behaviour: "You are helpful.")
    iex> BaseLLMAgent.create_initial_messages(agent)
    [%Message{role: :system, content: "You are helpful."}]

# `generate_response`

Generates a response from the agent for the given input.

Creates initial messages from the agent's behaviour, appends the user input,
and calls the broker to generate a response using the agent's tools.

## Parameters

- `agent`: The BaseLLMAgent instance
- `content`: The user input string

## Returns

- `{:ok, response}` on success
- `{:error, reason}` on failure

## Examples

    {:ok, response} = BaseLLMAgent.generate_response(agent, "What is 2+2?")

# `new`

Creates a new BaseLLMAgent.

## Parameters

- `opts`: Keyword list with:
  - `:broker` - LLM broker instance (required)
  - `:behaviour` - System message defining agent's personality and role (required)
  - `:tools` - List of tool modules (optional, default: nil)

## Examples

    broker = Broker.new("qwen3:32b", Ollama)

    agent = BaseLLMAgent.new(
      broker: broker,
      behaviour: "You are a helpful assistant.",
      tools: [WeatherTool]
    )

---

*Consult [api-reference.md](api-reference.md) for complete listing*
