Integration notes for coding agents
View SourceRead only what the task needs
| Access | Entry |
|---|---|
| Lowest context (recommended) | Start here (agents.md), then load usage-rules.md and only the matching skill/contract sheet below. |
| Select pages & module index | Markdown index |
| Fetch one module or guide | Use the page's .md sibling, e.g. ExAgent.Server.md or Getting started Markdown. |
| Optional single-fetch bundle | ExAgent 3.0.0 LLM reference bundle (manual + rules + 11 skills + detailed contracts + support/limits; fetch <Module>.md for per-function specs and guides for full tutorials). |
| Installed dependency | Run mix run --no-start -e 'IO.puts(Path.expand(Map.fetch!(Mix.Project.deps_paths(), :exagent)))'. Load usage-rules.md and usage-rules/skills/<skill>/SKILL.md there. Sync a configured host with mix usage_rules.sync. |
| API tier and backend support | priv/api-stability.exs lists Stable modules and their member/option tiers; check module docs for Candidate modules (such as ExAgent.Coordination.Flow) and Supported features and limits. |
| Limits of the contract | Known limits |
Stable means strict SemVer. Public Candidate modules, functions, options and variants can change in a minor release. A stable module can contain candidate members. Confirm the installed version and tier before copying a call.
API map
Contract keys Tools and Runtime identify the two detailed contract pages:
Tools and models contracts and
Runtime and operations contracts
(in the dependency: docs/guides/llm/tools-and-models-contracts.md and
docs/guides/llm/runtime-and-ops-contracts.md).
| Task | Stable | Candidate | Skill | Contract |
|---|---|---|---|---|
| Run once, stream or continue message history | ExAgent.new/1, ExAgent.run/3, ExAgent.run_stream/3 | Per-call :usage_limits | exagent-run-agent | Runtime · Getting started |
| Call a tool, validate typed output, restrict effects | Tool.new/1, Tools.deftool/3, Permissions.new!/1, output:, output_mode: | Argument predicates, Tool.CodeMode, Sandbox.tools/2 | exagent-tools | Tools · Tools and output |
| Attach host instructions or runtime skills | instructions:, capabilities:, Skill.new/1, Skills.from_dir!/2 | Candidate capability integrations retain their tier | exagent-tools | Tools · Skills |
| Connect a model, fail over, manage quota and spend | Model.resolve/2, Models.ReqLLM.new/1, Models.Fallback.new/1, UsageLimits, UsageLimits.Budget, RateLimiter | :spend_budget, Compaction, mix exagent.qualify | exagent-models | Tools · Models and limits |
| Supervise chat, admit a turn, consume events | Conversations, Server.chat/3, Server.send_message/3, Server.receipt/3, Chat.Reader, Server.attach/3, Server.events_since/3, Server.ack_events/4 | Server.steer_run/3, :observability | exagent-server | Runtime · Runtime and events |
| Review, supply or resume a persisted run | Continuation.pending/2, Continuation.decide/4, Continuation.supply_result/4, Server.resume/3, ExAgent.resume/3 | Input and timer deferral variants, delegated Frame3 pause paths | exagent-store, exagent-server | Runtime · Durability and approvals |
| Snapshot, restore, migrate, reconcile | Store.ETS, Store.Postgres, Store.scoped/2, Store.namespace/1, Catalog.cast/1, Continuation.reconcile_tool/4, Migration.up/1, Migration.down/1 | mix exagent.upgrade, Continuation.get/3 with timeline: true | exagent-store | Runtime · Migration |
| Background agents and tools | Jobs.background/2, Jobs.agent_tool/1, Jobs.tools/2, ExAgent.Jobs.Durable.recovery/2 | ExAgent.Jobs.Durable.definition/1, ExAgent.Jobs.Durable.delivery_queue/2 | exagent-jobs | Runtime · Continuation jobs |
| Delegate, transfer or orchestrate multiple steps | Coordination.delegation_tool/2, ExAgent.run_child/4 | Handoff, Coordination.Composition, Coordination.Flow | exagent-coordination | Runtime · Coordination |
| Drive participants with shared state | Session.take_turn/4, Session.chat/4, Session.SharedState, Session.StateCodec | Model-directed Handoff for a supported Session | exagent-session | Runtime · Coordination |
| Test model/tool behavior and replay cases | Models.Test, Fixture, Eval.run/3, mix exagent.eval | Eval.Suite.capture/1, mix exagent.eval.capture | exagent-test | Runtime · Testing |
| Import, serve or rebind MCP tools | MCP.Client.tools/1, MCP.Client.call_tool/3, MCP.Server.handle/4 | pinned:, on_drift:, connect_on_start:, tasks:, input forms, protected resources | exagent-mcp | Tools · MCP |
| Diagnose, trace, bound export and grade terminals | Telemetry, Observability.OpenTelemetry, Observability.BoundedProcessor, Eval.Online, mix exagent.doctor | Observability.ReqLLM, :metrics, Eval.Online.Durable | exagent-observability | Runtime · Observability |
| Read memory or integrate retrieval | Memory.tool/2, Memory.preload/3 with a host store, or a host Tool | Additional per-call accounting and retrieval adapters | exagent-tools, exagent-store | Tools · Memory · External retrieval |
Results, streams, events and errors
| Boundary | Observable form | Caller action |
|---|---|---|
| Accepted run terminal | {:ok, %ExAgent.Result{status: :succeeded, output: output}} | Deliver the validated answer. |
| Persisted pause | {:ok, %ExAgent.Result{status: :paused, continuation: ref}} | Store the reference and project pending review. A decision or deferred result supplies a new reference if ready. |
| Execution failure | {:error, %ExAgent.RunError{reason: reason, partial: partial}} | Inspect confirmed progress. The partial status is :failed or :cancelled. pending_response is diagnostic and can contain incomplete provider content. |
| Bang form | ExAgent.run!/3 returns accepted output, or raises the RunError or RunPaused | Prefer tagged results where a pause is expected. |
| Configuration | ArgumentError for invalid configuration at construction or public call admission | Fix the definition or options before dispatch. Check the boundary's documented returned errors for invalid operational input. |
| Model adapter | {:error, %ExAgent.RequestError{}} at dispatch. In a run, usually RunError.reason = {:model_request_failed, request_error} | Inspect provider, reason, status, transport and retry_after_ms where populated. A confirmed incomplete terminal uses {:incomplete_response, finish_reason} as the run reason. The partial owns live model state. |
| State checkpoint | {:error, %ExAgent.CheckpointError{operation: op, reason: reason, result: outcome, revision: revision}} | Keep the live owner and retry its save. An unconfirmed save may already have committed. |
| OTP boundary | :busy, :continuation_pending, :checkpoint_pending, :unavailable, {:delivery_unconfirmed, request_id} or :result_unconfirmed, inside {:error, ...} | Identify the original operation and classify confirmed refusal versus missing acknowledgement. Query its receipt, journal or correlated events. |
| One-shot stream | {type, data}, optional {:child, lineage, element} with child_events: :all, then one {:result, result} or {:error, %ExAgent.RunError{}} when fully consumed | Enumerate once with a catch-all. Close a suspended continuation on disconnect. Deltas and :output_partial are drafts. |
| Server/Session subscription | PubSub messages {:exagent_event, %ExAgent.Event{version: 2, source: source, type: type, payload: payload}}. Server demand delivery uses {:exagent_events_ready, server_pid, notice}. | Match owner and namespace, then run and request IDs. Apply a batch before ACK. Keep the cursor opaque. Rebuild from an authorized history page on expiry. |
| Stream element | Data keys |
|---|---|
:run_started | run_id, root_run_id, parent_run_id, attempt_id |
:run_step_started / :run_step_finished | step, plus outcome on finish (:continued, :retry, :succeeded, :paused or :failed) |
:text_delta, :commentary_delta, :thinking_delta | step, text. Guarded text or commentary can carry stream_checked?: true. |
:tool_call_delta / :output_partial | step and index, tool, fragment with tool_call_deltas: true, or step and draft output |
:model_response | step, accepted response |
:tool_call_started / :tool_call_finished | step, tool, call_ref. Start carries call and args_source. Finish carries return, duration_ms and duration_measured. |
:tool_data | step, call_ref, tool, part_id, name, data, transient |
:approval_requested | continuation, pending |
:guardrail_tripped | step, name, stage |
:run_handoff, :context_compacted, :steering_applied | Candidate integrations can add progress events. Use the catch-all for consumers that do not implement them. |
Event v2 adds id, emitter_id, seq, occurred_at, scoped runtime IDs,
run lineage and JSON payload/metadata. seq is local to an emitter.
Run terminals delivered this way are :run_finished, :run_paused and
:run_failed. They include payload.persistence. On
:server_request_cancelled, read payload.status
(:cancelled_before_start, :cancelled or :uncertain) and the persistence
state before offering it to Eval. Reconcile an uncertain cancellation.
Preserve these contracts
- Durability. A snapshot restores state. A C7 journal fences admitted effects and binds exact revisions. ETS survives owner replacement within the VM. Use PostgreSQL with a pinned unified migration when the VM must restart. Commit a save before treating its state transition as acknowledged.
- Reconciliation. An external write can succeed while its receipt is lost. Read the authorized journal. Use a declared read-only reconciler or explicit evidence before another effect is admitted. An authorized retry binds the exact stored intent. A confirmed result is replayed as data.
- Mandatory tool argument envelope. Stock ReqLLM wire calls carry a unique
"arguments"object field. Invalid envelopes block the entire batch. Correct complete object shapes only within the allowed budget. Reject incomplete, unparseable or non-object payloads and stock argument errors. Duplicate-key rejection needs the original JSON from the adapter. Persist and replay accepted history with the per-call codec intact. - Authority. Host auth supplies namespace, actor and policy. Use a versioned catalogue, Store scope and matching topic. Children inherit ancestor budgets and permissions. A Session state codec is selected by the host on every start.
- Accounting. Requests and tool dispatches are host counts. Provider token dimensions and cost carry their coverage/quality. Parent totals include descendants once. Preserve unknown separately from measured zero.
- Observability. Events can carry content within the host. Apply
Event.strip_content/1before export. Telemetry and OTel omit content by default. Bound queue, batch, exporter wait and retries. The host owns SDK and exporter lifetime. Spans and exporter callbacks are operational evidence.
Common anti-patterns
| Error | Correct call or handling |
|---|---|
Tool.new(callable: fn args -> ... end) | Use call: fn %{"sku" => sku} -> ... end with takes_ctx: false and an object schema. Pure tools declare effect: :read. |
Match {:ok, result} and publish output unconditionally | Match %ExAgent.Result{status: :succeeded}. Route :paused to the approval/deferral workflow. |
| Resume the original pause after approval | Match {:ok, %{continuation: ref}} from the confirmed current decision. Resume only when ref is actionable and use it unchanged. |
| Retry a failed/uncertain write, lost admission or lost checkpoint | Reconcile the journal, read the original admission key, or retry the save at the affected boundary. |
| Use one TestModel item for a tool followed by typed output | Script the tool response and a second final_result tool call in :tool mode. |
| Hard-code API struct internals or infer provider support from a name | Use public constructors and accessors. Read the model's profile and qualify the exact backend and mode separately. |
| Infer completion from a draft, admitted receipt or a repaired subscription | Match a confirmed terminal. Rebuild the UI from its authorized history projection when a cursor expires. |
| Trust a prompt or a persisted config map to grant access | Derive scope, actor and definition from the host. Use the saved reference to select exact trusted bindings. |
Verify the relevant boundary
- Script the public sequence offline with
%ExAgent.Models.Test{}. Assert terminal status, matched tool returns and host side effects. - In persistence tests, assert exact revision, committed receipt and behavior after duplicate delivery, owner replacement or lost ACK.
- Check the application's installed API tier and run its tests. Real-provider and backend qualification require explicit opt-in and separate evidence.
- When upgrading, use the Migration guide.