Raxol.Agent.Backend.Native (Raxol Agent v2.6.0)

Copy Markdown View Source

Generic Raxol.Agent.AIBackend runtime for native CLI harnesses.

Spawns a Raxol.Agent.NativeHarness driver's CLI via a Port, streams its normalized events, and adapts them to the AIBackend stream shape ({:chunk, text} / {:done, response}). Because the CLI owns its own agent loop, backends built here report handles_tools_internally? == true, and the agent's tools are injected into the CLI over MCP (see Raxol.Agent.Harness.McpToolConfig).

Define a per-vendor backend with the __using__/1 macro:

defmodule Raxol.Agent.Backend.ClaudeCode do
  use Raxol.Agent.Backend.Native, driver: Raxol.Agent.Harness.ClaudeCode
end

Backend options

  • :model -- model id (or omit for the CLI default).
  • :system_prompt -- appended system prompt.
  • :cwd -- working directory for the CLI.
  • :timeout -- per-run timeout in ms (default 120s).
  • :actions -- Action modules to expose to the CLI as MCP tools.
  • :mcp_server_command / :mcp_server_args -- the MCP server launcher; tools are injected only when this is set (and :actions is non-empty).
  • :extra_args -- raw argv appended to the CLI invocation.

Summary

Functions

Run one turn and return the final response (drains the stream).

Run one turn and return {:ok, stream} of AIBackend stream events.

Functions

complete(driver, messages, opts)

@spec complete(module(), [map()], keyword()) :: {:ok, map()} | {:error, term()}

Run one turn and return the final response (drains the stream).

stream(driver, messages, opts)

@spec stream(module(), [map()], keyword()) :: {:ok, Enumerable.t()} | {:error, term()}

Run one turn and return {:ok, stream} of AIBackend stream events.