Nous.Agents.BasicAgent (nous v0.13.3)

View Source

Default agent implementation with standard tool-calling behavior.

BasicAgent implements the Nous.Agent.Behaviour and provides:

  • Standard message building with system prompts
  • Simple tool call detection and execution
  • Text extraction from assistant responses

This is the default behaviour used when no behaviour_module is specified.

Example

agent = Agent.new("openai:gpt-4",
  instructions: "Be helpful",
  tools: [&search/2]
)

# Uses BasicAgent by default
{:ok, result} = Agent.run(agent, "Search for Elixir tutorials")

Summary

Functions

Build messages to send to the LLM.

Extract the final output from the context.

Get tools available for this agent.

Process a response from the LLM.

Functions

build_messages(agent, ctx)

Build messages to send to the LLM.

Combines system prompt (if any) with conversation messages.

extract_output(agent, ctx)

Extract the final output from the context.

Returns the text content of the last assistant message. When output_type is set, parses and validates the response.

get_tools(agent)

Get tools available for this agent.

Returns the tools configured on the agent.

process_response(agent, response, ctx)

Process a response from the LLM.

Adds the response to context and updates needs_response based on whether there are tool calls to process.