Integration notes for coding agents

View Source

Read only what the task needs

AccessEntry
Lowest context (recommended)Start here (agents.md), then load usage-rules.md and only the matching skill/contract sheet below.
Select pages & module indexMarkdown index
Fetch one module or guideUse the page's .md sibling, e.g. ExAgent.Server.md or Getting started Markdown.
Optional single-fetch bundleExAgent 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 dependencyRun 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 supportpriv/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 contractKnown 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).

TaskStableCandidateSkillContract
Run once, stream or continue message historyExAgent.new/1, ExAgent.run/3, ExAgent.run_stream/3Per-call :usage_limitsexagent-run-agentRuntime · Getting started
Call a tool, validate typed output, restrict effectsTool.new/1, Tools.deftool/3, Permissions.new!/1, output:, output_mode:Argument predicates, Tool.CodeMode, Sandbox.tools/2exagent-toolsTools · Tools and output
Attach host instructions or runtime skillsinstructions:, capabilities:, Skill.new/1, Skills.from_dir!/2Candidate capability integrations retain their tierexagent-toolsTools · Skills
Connect a model, fail over, manage quota and spendModel.resolve/2, Models.ReqLLM.new/1, Models.Fallback.new/1, UsageLimits, UsageLimits.Budget, RateLimiter:spend_budget, Compaction, mix exagent.qualifyexagent-modelsTools · Models and limits
Supervise chat, admit a turn, consume eventsConversations, Server.chat/3, Server.send_message/3, Server.receipt/3, Chat.Reader, Server.attach/3, Server.events_since/3, Server.ack_events/4Server.steer_run/3, :observabilityexagent-serverRuntime · Runtime and events
Review, supply or resume a persisted runContinuation.pending/2, Continuation.decide/4, Continuation.supply_result/4, Server.resume/3, ExAgent.resume/3Input and timer deferral variants, delegated Frame3 pause pathsexagent-store, exagent-serverRuntime · Durability and approvals
Snapshot, restore, migrate, reconcileStore.ETS, Store.Postgres, Store.scoped/2, Store.namespace/1, Catalog.cast/1, Continuation.reconcile_tool/4, Migration.up/1, Migration.down/1mix exagent.upgrade, Continuation.get/3 with timeline: trueexagent-storeRuntime · Migration
Background agents and toolsJobs.background/2, Jobs.agent_tool/1, Jobs.tools/2, ExAgent.Jobs.Durable.recovery/2ExAgent.Jobs.Durable.definition/1, ExAgent.Jobs.Durable.delivery_queue/2exagent-jobsRuntime · Continuation jobs
Delegate, transfer or orchestrate multiple stepsCoordination.delegation_tool/2, ExAgent.run_child/4Handoff, Coordination.Composition, Coordination.Flowexagent-coordinationRuntime · Coordination
Drive participants with shared stateSession.take_turn/4, Session.chat/4, Session.SharedState, Session.StateCodecModel-directed Handoff for a supported Sessionexagent-sessionRuntime · Coordination
Test model/tool behavior and replay casesModels.Test, Fixture, Eval.run/3, mix exagent.evalEval.Suite.capture/1, mix exagent.eval.captureexagent-testRuntime · Testing
Import, serve or rebind MCP toolsMCP.Client.tools/1, MCP.Client.call_tool/3, MCP.Server.handle/4pinned:, on_drift:, connect_on_start:, tasks:, input forms, protected resourcesexagent-mcpTools · MCP
Diagnose, trace, bound export and grade terminalsTelemetry, Observability.OpenTelemetry, Observability.BoundedProcessor, Eval.Online, mix exagent.doctorObservability.ReqLLM, :metrics, Eval.Online.Durableexagent-observabilityRuntime · Observability
Read memory or integrate retrievalMemory.tool/2, Memory.preload/3 with a host store, or a host ToolAdditional per-call accounting and retrieval adaptersexagent-tools, exagent-storeTools · Memory · External retrieval

Results, streams, events and errors

BoundaryObservable formCaller 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 formExAgent.run!/3 returns accepted output, or raises the RunError or RunPausedPrefer tagged results where a pause is expected.
ConfigurationArgumentError for invalid configuration at construction or public call admissionFix 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 consumedEnumerate once with a catch-all. Close a suspended continuation on disconnect. Deltas and :output_partial are drafts.
Server/Session subscriptionPubSub 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 elementData keys
:run_startedrun_id, root_run_id, parent_run_id, attempt_id
:run_step_started / :run_step_finishedstep, plus outcome on finish (:continued, :retry, :succeeded, :paused or :failed)
:text_delta, :commentary_delta, :thinking_deltastep, text. Guarded text or commentary can carry stream_checked?: true.
:tool_call_delta / :output_partialstep and index, tool, fragment with tool_call_deltas: true, or step and draft output
:model_responsestep, accepted response
:tool_call_started / :tool_call_finishedstep, tool, call_ref. Start carries call and args_source. Finish carries return, duration_ms and duration_measured.
:tool_datastep, call_ref, tool, part_id, name, data, transient
:approval_requestedcontinuation, pending
:guardrail_trippedstep, name, stage
:run_handoff, :context_compacted, :steering_appliedCandidate 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/1 before 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

ErrorCorrect 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 unconditionallyMatch %ExAgent.Result{status: :succeeded}. Route :paused to the approval/deferral workflow.
Resume the original pause after approvalMatch {: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 checkpointReconcile 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 outputScript the tool response and a second final_result tool call in :tool mode.
Hard-code API struct internals or infer provider support from a nameUse 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 subscriptionMatch 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 accessDerive 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.