ReqManagedAgents (ReqManagedAgents v0.1.0)

Copy Markdown View Source

Provider-agnostic Elixir client for managed agent runtimes.

The provider runs the agent loop server-side; your custom tools execute locally, so your data and code never leave your node. The provider only ever sees each tool's name, description, input schema, and the text result you return.

Two backends ship behind the same ReqManagedAgents.Provider behaviour:

Whichever backend, ReqManagedAgents.Session.run/2 returns the same ReqManagedAgents.SessionResult — terminal, text, tool uses, token usage.

See ReqManagedAgents.Client for the Anthropic control plane, ReqManagedAgents.Session for the batteries-included loop, and the README and examples/ for runnable, commented walkthroughs.

Summary

Functions

Build a control-plane client. See ReqManagedAgents.Client.new/1.

Provision (create-or-reuse) a provider's agent resource for spec, returning a durable handle you splat into ReqManagedAgents.Session.run/2 opts. Cached in-process by {provider, spec}.

Run a managed-agent session synchronously to completion, returning {:ok, %ReqManagedAgents.SessionResult{}} (terminal, stop_reason, text, tool uses, usage, events) or {:error, reason} (incl. {:error, :timeout}).

Start a live managed-agent session (Claude Managed Agents). See ReqManagedAgents.Session.start_link/2.

Tear down a provisioned resource and evict it from the provision cache.

Functions

new(opts \\ [])

Build a control-plane client. See ReqManagedAgents.Client.new/1.

provision(provider, spec, opts \\ [])

@spec provision(module(), ReqManagedAgents.Provider.spec(), keyword()) ::
  {:ok, ReqManagedAgents.Provider.handle()} | {:error, term()}

Provision (create-or-reuse) a provider's agent resource for spec, returning a durable handle you splat into ReqManagedAgents.Session.run/2 opts. Cached in-process by {provider, spec}.

run_to_completion(opts)

Run a managed-agent session synchronously to completion, returning {:ok, %ReqManagedAgents.SessionResult{}} (terminal, stop_reason, text, tool uses, usage, events) or {:error, reason} (incl. {:error, :timeout}).

Runs synchronously and blocks until a terminal event or the :timeout. The session is started unlinked and monitored, and it traps exits, so an open failure or an unexpected stream/consumer crash is surfaced to you as {:error, reason} rather than killing the caller; handled stream errors are likewise returned as {:error, reason}. For a supervised, reconnecting loop use ReqManagedAgents.Session.start_link/2 instead.

This is the Claude convenience form of ReqManagedAgents.Session.run/2 — i.e. Session.run(ReqManagedAgents.Providers.ClaudeManagedAgents, opts).

start_session(opts)

Start a live managed-agent session (Claude Managed Agents). See ReqManagedAgents.Session.start_link/2.

teardown(provider, handle, opts \\ [])

@spec teardown(module(), ReqManagedAgents.Provider.handle(), keyword()) ::
  :ok | {:error, term()}

Tear down a provisioned resource and evict it from the provision cache.