Skip to main content

Connect Your Agent

Paste this prompt into your coding agent (Claude Code, Cursor, or any agent with shell access) and it performs the whole setup, from finding the endpoint to running the first suite:
The steps below are the same setup by hand, and what to check when the prompt’s run needs a correction.

1. Expose an endpoint LangWatch can reach

Scenario runs call your agent from the LangWatch backend, so the agent needs a URL that backend can reach. A staging deployment is the recommended target: it exercises the real system without touching production data. Any reachable URL works. For the agent running on your own machine, langwatch agent dev opens a tunnel to a local port and points the registered agent at it for the session. See Local development. The endpoint receives one HTTP request per conversation turn and returns the agent’s reply. It does not need to know anything about LangWatch: you configure the request body and the response parsing on the LangWatch side, in step 3.

2. Authenticate the scenario traffic

Your endpoint’s existing authentication passes through the HTTP agent’s header rows and its auth block (bearer, api_key, or basic). Store the credential as a project secret and reference it as {{ secrets.NAME }}, so it stays encrypted at rest instead of readable in the agent’s configuration. When the normal authentication is built for human users (sessions, OAuth redirects), add a dedicated API key for scenario traffic instead: your server reads the expected key from an environment variable and checks it on each request, and the HTTP agent sends it from a secret. A dedicated key is also the one you revoke to close the testing path.
Also check: Testing agents behind authentication lists exactly which fields resolve secret references, and covers OAuth2 client-credentials exchange with a code agent.

3. Define the request and the response contract

The body template renders as a Liquid template on every turn, and outputPath is a JSONPath expression that picks the reply text out of the response.
Body template
The URL and the header values render the same variables. For the response, set outputPath to where the reply text lives. If the endpoint answers {"reply": "It ships on Tuesday."}, set outputPath to $.reply. The platform reads the reply text at that path; the response needs nothing else.

4. Adopt the trace context

The platform sends a W3C traceparent header on every call, one trace per conversation turn. When your server adopts it, the spans your agent produces land in that same trace, and the judge reads them before its verdict: tool calls, database writes, retrievals. A criterion like “the agent looked up the order before answering” then passes on evidence instead of on the reply’s wording. With standard OpenTelemetry HTTP auto-instrumentation, adoption already happens and you change nothing. Without it, extract the context from the request headers and open your handler’s root span inside it:
The agent must report its traces to the same LangWatch project that runs the scenarios. Traces sent to another project, or to another observability backend only, are invisible to the judge.
Also check: Remote traces explains what the judge sees, how long it waits for traces, and what happens when they do not arrive.

5. Register the agent and run the first scenario

In the platform, create the agent on the Agents page: type HTTP, then the URL, authentication, body template and output path from the steps above. The same registration is available as POST /api/agents. With the CLI:
Then create a scenario, pair it with the agent in a suite, and run it:

6. Verify the run

Open the run in the Simulations section of your project. A connected setup shows:
  • The conversation transcript, with the reply text your outputPath extracted.
  • A trace link on each turn in the run detail, opening the agent’s own spans for that turn.
  • Judge reasoning that cites spans, naming the tool call or lookup that satisfied a criterion.
A trace-dependent criterion that comes back inconclusive means the traces did not arrive; see the failures below.

Common failures