Skip to main content
Use this workflow when your Agent runs on your computer or does not support the request format that Vijil expects. You will place a small proxy in front of the Agent and expose that proxy through an ngrok tunnel.
TL;DR: Start an Agent locally, expose it through an authenticated ngrok tunnel, then run a behavioral or Red Team Evaluation with the Python SDK. Vijil services send requests to the local proxy through the public tunnel, so keep the proxy and tunnel running until the Evaluation completes.
A proxy changes Vijil requests into a format your Agent understands. It then changes the Agent’s response into a format Vijil can process. The tunnel makes the proxy reachable at a public HTTPS URL while it runs. This guide uses a restricted version of the Market Researcher from the Anthropic financial services examples. You can use the same pattern with another Agent by changing the function that calls Claude Code.
Evaluation Probes are adversarial. Use test data and test credentials. Disable write and destructive tools. If the Agent can access files or external systems, run it in a sandbox. Do not give it access to production resources.The tunnel URL is public, but the example protects /v1/chat/completions with a random API key. Run the proxy only while you test the Agent. Enterprise deployments can also restrict tunnel traffic to Vijil.

Understand How Requests Move

Vijil sends each Probe to the public tunnel URL. The tunnel forwards the request to the proxy on your computer. The proxy calls the Agent under test and returns its response to Vijil. You do not need to send Probes one at a time. After you register the proxy URL, you start the Evaluation in the same way as any other SDK Evaluation. Vijil sends the Probes, collects the responses, and records the results.

Install the Tools

Create a Python 3.12 virtual environment and install the packages used by the proxy:

Set Up the Agent Under Test

This example uses Claude Code to run Market Researcher. Install Claude Code, then confirm that the claude command is available:
Clone the financial services examples from Anthropic and save the absolute path to the Market Researcher plugin:
The example reads Market Researcher’s system prompt and loads its sector-overview Skill. It creates a temporary Agent definition that has no runtime tools. The Agent cannot read, write, or edit files, run shell commands, invoke more Skills, or use MCP connectors. Claude Code still reads the plugin prompt and Skill during startup. The --no-session-persistence flag prevents it from saving the conversation for later use.

Configure Credentials

Export the values used by the example:
Keep these values in the terminal where you run the proxy. Do not put them in the Python file or commit them to source control. Claude Code uses ANTHROPIC_API_KEY to run Market Researcher. The key stays on your computer. The script generates a separate key to protect the proxy.

Create the Proxy

The integration has three parts. The complete file at the end of this section puts them together.

Call the Agent

run_market_researcher() is the Agent-specific part. Replace this function when you use another Agent.
The complete script includes the flags that load the Skill and remove runtime file, shell, Skill, and MCP tools.

Add the Vijil Endpoint

The proxy accepts an OpenAI-compatible request and returns the Agent response in choices[0].message.content. It rejects requests that do not contain the generated API key.

Run the Evaluation

Start the proxy, open the tunnel, and register the generated proxy key with Console. Keep the tunnel open until client.evaluate() returns.
The proxy converts each role and text value into a labelled section of one Claude Code prompt. It does not preserve native message-role semantics, and it ignores temperature and max_tokens. The example starts with a limit of five requests per minute. Increase rate_limit_requests_per_minute only after you confirm that the Agent and its model provider can handle more traffic.

Run the Complete Example

Save the complete script as local_agent_evaluation.py. Run it from the terminal where you exported the credentials:
Keep the process running until the Evaluation finishes. The script:
  1. Fetches your tunnel credentials from Vijil.
  2. Starts the proxy on your computer.
  3. Opens the public ngrok tunnel.
  4. Registers the tunnel URL and generated proxy key in Vijil Console.
  5. Starts a security Evaluation and polls until it finishes.
  6. Closes the tunnel.
The sample_size=5 setting selects five test prompts for each Probe in the security Harness. This small sample helps you check the connection. It does not provide a complete security assessment. client.evaluate() polls until the Evaluation finishes and returns the final result. The script prints the Agent ID, Evaluation ID, status, Trust Score, Security score, and the Console results URL.

Run Adaptive Red Teaming

Because the tunnel provides a public endpoint, this workflow supports Red Team Evaluations. The SDK’s separate no-tunnel --local mode supports behavioral Evaluations only. To run adaptive Red Teaming against the same Agent, add this code inside the existing try block, after the standard Evaluation and before finally:
client.evaluate(..., type="redteam") polls until the Red Team Evaluation finishes. Keep the proxy and tunnel running for the entire Evaluation. Adaptive Red Teaming can take longer than a standard Evaluation because it runs successive waves of attacks. Use this standalone version when you want to run adaptive Red Teaming instead of the standard Evaluation:

Reuse the Agent

The script closes the ngrok connection after each run. The public binding becomes unreachable when the tunnel closes. It does not revoke your tunnel credentials or archive the Agent in Console. You can run an Evaluation for this local Agent in Console only while its proxy and user-specific tunnel are running. client.agent_tunnel.get() returns the same tunnel credentials on later runs, so you can open the same binding again. Keep the Agent ID if you want to compare future Evaluations. If you rerun the full script, it registers another Agent record.
Last modified on November 3, 2026