Diagnose an integration

View Source

When something goes wrong in an agent system, start by naming the exact boundary that failed: construction, model admission, tool validation, effect execution, persistence or export. ExAgent is designed so every failure tells you what already happened without tempting you to blindly replay uncertain work.

What ExAgent gives you for fast diagnosis:

  • mix exagent.doctor — offline health check for models, JSON/Decimal setup, PostgreSQL schemas, Recovery indexes, catalog locks, quotas and Jobs.
  • mix exagent.qualify (candidate) — live protocol probe against any cloud or local model endpoint (tools, parallel calls, streaming, typed output, truncation safety and cancellation).
  • Clear symptom-to-action map — jump straight from any error tuple or unexpected UI behavior to the right fix.

Inspect an installation

Run mix exagent.doctor from your Mix project to inspect a model profile and installed optional integrations without making any network requests:

mix exagent.doctor --model openai:gpt-4o --profile auto
mix exagent.doctor --model test --json

Doctor checks:

  • Model profile & lifecycle: resolved wire protocol, tool/streaming/native support, unverified model IDs, and deprecation/retirement notices.
  • Required json.jason_decimal: verifies Jason decodes Decimal cleanly (if reported missing, compile decimal then run mix deps.compile jason --force).
  • Host services (optional): share your descriptors in config so Doctor can validate PostgreSQL migrations, run headers, recovery/timer indexes, catalog locks, shared quotas and durable Jobs in one pass:
config :my_app, :exagent_doctor,
  model: "openai:gpt-4o",
  store: {ExAgent.Store.Postgres, {MyApp.Repo, table: "exagent_snapshots"}},
  conversations: MyApp.Agents.Conversations,
  mcp_finch: [name: MyApp.MCPFinch, pools: %{default: [protocols: [:http1]]}]

Then run the checks relevant to your deployment:

mix exagent.doctor --check-store --check-recovery --check-catalog-lock
mix exagent.doctor --check-run-headers --check-catalog --json
  • --check-store verifies unified ExAgent migration 1 (snapshot schema, run headers, keyed admissions, recovery and timer indexes) without reading conversation bodies.
  • --check-recovery (candidate) checks the recovery sweeper index and active lease projections.
  • --check-catalog-lock verifies priv/exagent/catalog.lock against your compiled durable agent definitions (Deployment steps).
  • --check-quota and --check-jobs verify quota_repo: and jobs_repo: schemas inside a running host (Mix.Tasks.Exagent.Doctor.run(["--check-quota", "--json"])).
  • In CI, mix exagent.doctor --json outputs a version 1 report and exits nonzero on any missing required check (see Runtime & ops contracts for exact check IDs and JSON fields).

Qualify a model endpoint

Before trusting a new cloud gateway, fine-tune or local Ollama/vLLM server in production, run the candidate mix exagent.qualify probe:

# Local Ollama server on loopback (no API key sent):
mix exagent.qualify --model ollama:llama3.3

# Cloud provider (reads OPENAI_API_KEY and asks for interactive confirmation):
mix exagent.qualify --model openai:gpt-4o-mini

Passing --base-url sends that provider's configured credentials to the custom URL (use HTTPS outside loopback), and --yes suppresses the interactive confirmation prompt — only pass --base-url with credentials meant for that exact destination.

After interactive confirmation (or --yes), Qualify runs up to 10 synthetic model requests with local marker tools and checks:

  1. Single tool round-trip with envelope validation.
  2. Parallel duplicate tool calls with distinct IDs in one turn.
  3. Streamed tool round-trip.
  4. Typed output (:native, :tool or :prompted based on profile).
  5. Truncated tool-argument safety (verifies zero tool execution on cut-off JSON).
  6. Stream cancellation (stops on first delta with zero tool execution).
  7. Optional qualified token usage reporting.

Qualify runs with zero tool/output retries so endpoint envelope issues surface immediately (invalid_tool_arguments or parallel_calls_collapsed). Pass --json for a machine-readable report including observed HTTP attempt count and estimated cost ceiling (unknown for custom --base-url endpoints). Use mix exagent.qualify for wire protocol compliance and Testing and evaluations for application answer quality.

Common symptoms

SymptomWhat to inspectNext action
Provider resolves, but tools or streaming are rejectedResolved profile and capabilities via mix exagent.doctor.Use a qualified profile in Models and limits; catalogue listing alone is not tool qualification.
invalid_tool_arguments before tool executionArgument JSON, retry budget (max_retries / output_retries) and continuation frame.Complete objects with wrong shape auto-retry when retry budget > 0; truncated/invalid JSON stays fatal with zero effects. See Tool argument envelope.
:tool_execution_failed where history only says "The tool failed."RunError.reason holds the tool's {:error, reason}.Return {:tool_error, msg} for outcomes the model should see; keep {:error, reason} for host outages.
Output validation failsEcto changeset errors, output_mode: and output_retries:.Tighten the prompt/schema or increase output_retries:; deliver output only on :succeeded.
Server returns :busy or :queue_fullExAgent.Server.health/1 (pending, pending_bytes).Apply UI/caller backpressure; the Server queue is intentionally bounded and volatile.
Events appear in the wrong LiveViewnamespace, agent_id and request_id on %ExAgent.Event{}.Subscribe to the authenticated conversation topic and match all three fields (Receive example).
Calls return :checkpoint_pendingCheckpointError and health/1 persistence status (:unconfirmed).Call ExAgent.Server.checkpoint/2 to retry saving the exact state — never re-send the user prompt.
{:rate_limiter_migration_required, 1}Quota Repo search path and Doctor's quota.postgres row.Run quota migration 1.
:unavailable, {:delivery_unconfirmed, id}, or :result_unconfirmedWhether the target process existed and current state/job ID.:unavailable was never sent (safe to retry); for unconfirmed delivery/results, check state before repeating (Vocabulary).
start_link raises ArgumentErrorThe option key named in the message.Fix the invalid option ({:restore_failed, reason} is reserved strictly for Store load/decode errors).
Restore rejects stored snapshot or recordFormat version, ID, policy and model/tool bindings.Follow Migration; never silently discard persisted state.
Resumed continuation reports :uncertain or active claimCurrent record via ExAgent.Continuation.get/2 and external effect evidence.Reconcile or recover explicitly instead of starting a competing fresh run.
MCP tool times outRequest deadline, Finch pool size and remote state.Treat remote effects as potentially completed; reconnecting never means replaying.
Parent and child trace spans show different token totalsInclusive subtree totals, provenance and completeness.Read totals on the root span once; never add inclusive parent spans to child spans.

Langfuse or Opik shows empty input/output

With ExAgent's privacy-first default (content: false), Input null and Output undefined are expected — they do not mean the run was empty. Inspect the span attributes for run/root/parent IDs, request/tool counts, status, usage completeness and estimated cents.

Historical error spans are intentionally kept even after a successful recovery or checkpoint retry so you can audit the causal timeline. Read Observability before opting into content capture and always configure redaction before export.

Distinguish test results

An excluded ExUnit test never ran (provider and PostgreSQL tests require explicit env/tags), and a passing Models.Test run proves your local Elixir logic — not live provider wire compliance. See Testing and evaluations for matching each test layer to the guarantee you need.

Report a reproducible problem

When opening an issue, include:

  • ExAgent version, Elixir/OTP versions and model/profile name.
  • A minimal public-API snippet (prefer ExAgent.Models.Test if reproducible offline; attach sanitized real-provider evidence separately if backend-specific).
  • The sanitized error reason and relevant partial counters/status.

Check the privacy guidance before sharing logs, and never attach raw live results, .env files, API keys or unredacted customer payloads.

API: ExAgent.RunError, ExAgent.Server.health/1, ExAgent.Continuation.