> For the complete documentation index, see [llms.txt](https://docs.bluerock.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bluerock.io/agent-frameworks-integration/agent-frameworks-integration.md).

# Agent Frameworks Integration

The BlueRock runtime provides native telemetry tracing for multiple agent ecosystems, including **LangChain**, **CrewAI**, **Anthropic**, **Google Agent Development Kit (ADK)**, **OpenAI**, and **LiteLLM**. By embedding the `bluerock` sensor directly into the execution space, the BlueRock runtime automatically hooks into internal orchestration and lifecycle engines. The integration requires no architectural changes to the codebase and no manual analytics callbacks.

{% hint style="success" icon="lightbulb-exclamation-on" %}
I**mportant:**

The telemetry tracing feature is supported only on the BlueRock Ubuntu or AL2023 Virtual Machine (VM). The system does not support this feature on a generic Ubuntu Linux VM.
{% endhint %}

## Core Architecture

<div align="left"><figure><img src="https://1983702018-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCNnVnPvaRpvlLmPT6IAN%2Fuploads%2Fm8A6jPVDWnc9ladxowP4%2Fimage.png?alt=media&amp;token=c3ca61c2-0e7e-4faf-bf1b-8ec847fcde23" alt=""><figcaption></figcaption></figure></div>

The architecture remains consistent across all BlueRock agent integrations:

1. Agent Execution Space: The environment where the specific agent program runs alongside the `bluerock` sensor. The environment must operate within a BlueRock Ubuntu or AL2023 VM.
2. Event Collector: The component capturing telemetry from the execution space.
3. bluerockd: The BlueRock Control Plane processing intercepted execution tasks and intents.
4. CloudWatch or External Event Collector: The final destination for aggregated telemetry and logs.

## Environment Setup

### Prerequisites

* [Python version 3.13](https://www.python.org/downloads/release/python-3130/) or above.
* Package Manager: Install `uv` for dependency management and execution.

### Framework Configuration Reference

Different frameworks require specific primary packages and example scripts. The project name parameter can be any string (for example, `search_agent` or `file_agent`); enter the desired project name when substituting the `<Enter_Project_Name_Here>` placeholder. Reference the table below when substituting the remaining placeholder values in the subsequent setup steps.

<table data-header-hidden data-search="false"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Framework</strong></td><td><strong><code>&#x3C;Package_Name></code></strong></td><td><strong>Example Scripts</strong></td></tr><tr><td>LangChain</td><td><code>langchain</code></td><td><a href="/pages/zdGpFBMqwmb1I0sMU3FE#chat_agent.py"><code>chat_agent.py</code></a></td></tr><tr><td>CrewAI</td><td><code>crewai</code></td><td><a href="/pages/zdGpFBMqwmb1I0sMU3FE#example_chat_agent.py"><code>help_agent_crewai.py</code></a></td></tr><tr><td>Anthropic</td><td><code>anthropic</code></td><td><a href="/pages/zdGpFBMqwmb1I0sMU3FE#search_agent.py"><code>search_agent.py</code></a></td></tr><tr><td>Google ADK</td><td><code>google_adk</code></td><td><a href="/pages/zdGpFBMqwmb1I0sMU3FE#search_agent_gemini.py"><code>search_agent_gemini.py</code></a></td></tr><tr><td>OpenAI</td><td><code>openai</code></td><td><a href="/glossary/appendix.md"><code>hello_world_oai.py</code></a></td></tr><tr><td>LiteLLM</td><td><code>litellm</code></td><td><a href="/glossary/appendix.md"><code>search_agent_litellm.py</code></a></td></tr></tbody></table>

{% hint style="info" icon="notes-sticky" %}
Note:

The `<Package_Name>` represents the primary framework entry point. Additional packages and adapters required by custom implementations (for example: `langchain_ollama`, `mcp`, or `fastmcp`) can be dynamically appended to the dependency installation command.
{% endhint %}

### Install the `uv` Package Manager

Run the installation script to install the package manager.

```shellscript
$ curl -LsSf https://astral.sh/uv/install.sh | sh
```

### Provision the Isolated Project Environment

Initialize the local project workspace using Python 3.13 (or above) and establish project dependencies using the target framework details from the reference table.

```shellscript
$ uv init --python python3.13 <Enter_Project_Name_Here>
$ cd <Enter_Project_Name_Here>
$ uv venv --python python3.13
$ source .venv/bin/activate
$ uv add <Package_Name> [Additional_Packages...]
```

### Inject and Register BlueRock Sensors

Deploy the custom BlueRock telemetry sensor library directly within the activated workspace context. Activate runtime sensor hooks using the installation flag.

```shellscript
$ uv pip install /opt/bluerock/python-dist/bluerock-0.0.1-py3-none-any.whl
$ python -m bluerock --install
```

### Stage the Agent Script

Add the script based on the selected agent framework. If required, use the example scripts from BlueRock.

## Agent Execution Block

{% hint style="success" icon="lightbulb-exclamation-on" %}
**Important:**

* Bind appropriate authorization environment variables to the parent terminal session to initiate runtime actions.&#x20;
* The **Anthropic**, **LiteLLM**, **LangChain**, and **CrewAI** scripts use the `OPENAI_API_KEY` environment variable as a standard label, whereas accept native Large Language Model (LLM) API keys for authentication.
  {% endhint %}

### Execution Variable Reference

Reference the table below when substituting placeholder values in the execution commands.

<table data-header-hidden data-search="false"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>Framework</strong></td><td><strong><code>&#x3C;API_Key_Variable></code></strong></td></tr><tr><td>LangChain</td><td><code>OPENAI_API_KEY</code></td></tr><tr><td>CrewAI</td><td><code>OPENAI_API_KEY</code></td></tr><tr><td>Anthropic</td><td><code>OPENAI_API_KEY</code></td></tr><tr><td>Google ADK</td><td><code>GOOGLE_API_KEY</code></td></tr><tr><td>OpenAI</td><td><code>OPENAI_API_KEY</code></td></tr><tr><td>LiteLLM</td><td><code>OPENAI_API_KEY</code></td></tr></tbody></table>

### Local Execution

Set the required environment variable and execute the primary workspace script using the package manager.

```shellscript
$ export <API_Key_Variable>=<api_key>
$ uv run <Example_Script>
```

### Containerized Execution

Run the target agent as a Docker application. Securely mount the BlueRock socket into the container.

<pre class="language-shellscript"><code class="lang-shellscript"><strong>$ docker run -d --name &#x3C;Container_Name> \
</strong>  --rm \
  -e &#x3C;API_Key_Variable>=&#x3C;api_key> \
  -v /run/bluerock:/run/bluerock \
  &#x3C;Image_Name>
</code></pre>

{% hint style="info" icon="notes-sticky" %}
**Note:**

`<Container_Name>` can be any arbitrary name assigned to the container. `<Image_Name>` must match the exact tag assigned when building or pulling the Docker image. Run `docker images` in the terminal to list all locally available images and corresponding tags.
{% endhint %}

## Sensor Configuration and Telemetry Events

The sensors are governed by the `bru_policy.json` configuration file, located in the `/opt/bluerock/trex/` directory on a BlueRock instance or VM. The policy defines separate configuration blocks to activate interception hooks for fundamental LLM calls versus higher-level agentic orchestration.

Depending on the active ecosystem, the sensor automatically captures distinct execution and lifecycle events.

### **LLM Sensors**

The `llm` block controls the tracing of direct interactions with foundational models. Activating specific vendor flags within this block allows the sensor to capture raw generation requests, tokens, and response latencies.

{% code title="bru\_policy.json" lineNumbers="true" %}

```json
"llm": {
    "enable": true,
    "gemini": true,
    "openai": true,
    "anthropic": true,
    "litellm": true
}
```

{% endcode %}

### **Agentic Sensors**

The Agentic configuration blocks (such as `crewai` and `langchain`) hook into multi-step reasoning, tool execution, memory retrieval, and agent delegation. These are enabled independently of the base LLM sensors.

{% code title="bru\_policy.json" lineNumbers="true" %}

```json
"crewai": {
    "enable": true
},
"langchain": {
    "enable": true
}
```

{% endcode %}

### Standardized Sample Events by Sensor Type

#### LLM Sensors

* OpenAI

  ```json
  {
    "body": {
      "context": { "process": { "pid": "<MASKED_PID>" } },
      "entity_id": "<MASKED_ENTITY_ID>",
      "event": "chat_completion_start",
      "model": "gpt-4o",
      "messages": [
        { "role": "user", "content": "Why is the sky blue?" }
      ],
      "run_id": "<MASKED_RUN_ID>"
    },
    "severity_number": 0,
    "severity_text": "INFO",
    "attributes": {
      "domain": "gyro",
      "event_name": "python_openai_event",
      "origin": "bluepython",
      "sensor_id": 0000
    },
    "scope": { "name": "bluerockd" },
    "resource": { "service.name": "bluerock" }
  }
  ```
* Anthropic

  ```json
  {
    "body": {
      "context": { "process": { "pid": "<MASKED_PID>" } },
      "entity_id": "<MASKED_ENTITY_ID>",
      "event": "message_create_start",
      "model": "claude-3-5-sonnet-20241022",
      "messages": [
        { "role": "user", "content": "Hello, Claude. Why is the sky blue?" }
      ],
      "max_tokens": 1024,
      "run_id": "<MASKED_RUN_ID>"
    },
    "severity_number": 0,
    "severity_text": "INFO",
    "attributes": {
      "domain": "gyro",
      "event_name": "python_anthropic_event",
      "origin": "bluepython",
      "sensor_id": 0000
    },
    "scope": { "name": "bluerockd" },
    "resource": { "service.name": "bluerock" }
  }
  ```
* LiteLLM

  ```json
  {
    "body": {
      "context": { "process": { "pid": "<MASKED_PID>" } },
      "entity_id": "<MASKED_ENTITY_ID>",
      "event": "completion_start",
      "model": "claude-sonnet-4-5-20250929",
      "messages": [
        { "role": "user", "content": "Hello, what is a rainbow?" }
      ],
      "run_id": "<MASKED_RUN_ID>"
    },
    "severity_number": 0,
    "severity_text": "INFO",
    "attributes": {
      "domain": "gyro",
      "event_name": "python_litellm_event",
      "origin": "bluepython",
      "sensor_id": 0000
    },
    "scope": { "name": "bluerockd" },
    "resource": { "service.name": "bluerock" }
  }
  ```

#### Agentic Sensors

* LangChain

  ```json
  {
    "body": {
      "chain_type": "AgentExecutor",
      "context": { "process": { "pid": "<MASKED_PID>" } },
      "entity_id": "<MASKED_ENTITY_ID>",
      "event": "chain_start",
      "inputs": {
        "question": "What files do I have in the folder?"
      },
      "run_id": "<MASKED_RUN_ID>"
    },
    "severity_number": 0,
    "severity_text": "INFO",
    "attributes": {
      "domain": "gyro",
      "event_name": "python_langchain_event",
      "origin": "bluepython",
      "sensor_id": 0000
    },
    "scope": { "name": "bluerockd" },
    "resource": { "service.name": "bluerock" }
  }
  ```
* CrewAI

  ```json
  {
    "body": {
      "context": { "process": { "pid": "<MASKED_PID>" } },
      "entity_id": "<MASKED_ENTITY_ID>",
      "event": "crew_kickoff_started",
      "crew_name": "AssistantCrew",
      "tasks": ["task_one"],
      "agents": ["Helpful assistant"],
      "run_id": "<MASKED_RUN_ID>"
    },
    "severity_number": 0,
    "severity_text": "INFO",
    "attributes": {
      "domain": "gyro",
      "event_name": "python_crewai_event",
      "origin": "bluepython",
      "sensor_id": 0000
    },
    "scope": { "name": "bluerockd" },
    "resource": { "service.name": "bluerock" }
  }
  ```
* Google Gemini

  ```json
  {
    "body": {
      "context": { "process": { "pid": "<MASKED_PID>" } },
      "entity_id": "<MASKED_ENTITY_ID>",
      "event": "agent_run_start",
      "agent_name": "search_agent",
      "model": "gemini-2.5-flash",
      "query": "why is the sky blue?",
      "run_id": "<MASKED_RUN_ID>"
    },
    "severity_number": 0,
    "severity_text": "INFO",
    "attributes": {
      "domain": "gyro",
      "event_name": "python_google_adk_event",
      "origin": "bluepython",
      "sensor_id": 0000
    },
    "scope": { "name": "bluerockd" },
    "resource": { "service.name": "bluerock" }
  }
  ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.bluerock.io/agent-frameworks-integration/agent-frameworks-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
