Skip to content

Commit 20af97f

Browse files
authored
Merge pull request #8 from redpanda-data/example
otel: support tracing
2 parents a382eb9 + 8c9434e commit 20af97f

34 files changed

+1022
-489
lines changed

Taskfile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,5 @@ tasks:
8080
--mypy_out={{.OUT_DIR}} \
8181
--grpc_python_out={{.OUT_DIR}} \
8282
--mypy_grpc_out={{.OUT_DIR}} \
83-
-I proto
83+
-I proto \
8484
proto/redpanda/runtime/proto/runtime.proto

docs/06_rpkmcpendpoint_.md

Lines changed: 0 additions & 134 deletions
This file was deleted.

docs/index.md

Lines changed: 87 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,103 @@
1-
# Welcome to MkDocs
1+
# Redpanda Agents
22

3-
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
3+
The [Redpanda Agent SDK](https://github.com/redpanda-data/agent) allows you to build agentic [Redpanda Connect](https://www.redpanda.com/connect) pipelines.
44

5-
## Commands
5+
You can use [`rpk`](https://docs.redpanda.com/current/get-started/intro-to-rpk/) to generate the initial boilerplate for an agentic pipeline.
66

7-
* `mkdocs new [dir-name]` - Create a new project.
8-
* `mkdocs serve` - Start the live-reloading docs server.
9-
* `mkdocs build` - Build the documentation site.
10-
* `mkdocs -h` - Print help message and exit.
7+
```bash
8+
$ rpk connect agent init my_first_agent
119

12-
## Project layout
10+
$ ls --tree ./my_first_agent
11+
my_first_agent
12+
├── agents
13+
│ └── weather.py
14+
├── mcp
15+
│ └── resources
16+
│ └── processors
17+
│ └── check_weather_tool.yaml
18+
├── pyproject.toml
19+
├── README.md
20+
├── redpanda_agents.yaml
21+
└── uv.lock
22+
```
1323

14-
mkdocs.yml # The configuration file.
15-
docs/
16-
index.md # The documentation homepage.
17-
... # Other markdown pages, images and other files.
24+
## Project Structure
1825

26+
The project structure is as follows:
1927

20-
**This project** provides a flexible system where an *Agent* can answer questions and use specialized *Tools* to tackle tasks.
21-
The Agent can also connect to external services through different **MCPEndpoints**, letting it integrate with remote or local resources.
28+
### `redpanda_agents.yaml`
2229

23-
A **RuntimeServer** exposes the Agent over gRPC, so outside applications can interact with it.
24-
The project includes *hooks* to track key events (like before or after a tool is called) and a *ToolResponse* structure for sending back text or images neatly.
30+
The main entry point for the agent pipeline. The file looks like the following:
2531

26-
The **RPKMCPEndpoint** even simplifies testing by running a local command to simulate a server inside your development folder.
32+
```yaml
33+
# Each agent is an entry under `agents` - there can be multiple for multi-agent flows.
34+
agents:
35+
# The name of the agent determines what python file is executed for the agent.
36+
<agent_name>:
37+
# Any Redpanda Connect input is valid here
38+
# See them all at: https://docs.redpanda.com/redpanda-connect/components/inputs/about/
39+
input:
40+
<input>
41+
# Any tool labels defined in the `mcp` directory, see notes below for more.
42+
tools:
43+
- <tool label>
44+
# Any Redpanda Connect output is valid here
45+
# See them all at https://docs.redpanda.com/redpanda-connect/components/outputs/about/
46+
output:
47+
<output>
48+
# See options here: https://docs.redpanda.com/redpanda-connect/components/tracer/about/
49+
tracer:
50+
<tracer>
51+
```
2752
53+
### `agents/*.py`
2854

55+
Each agent recieves input from `input` and sends it's output to `output`. You can create an agent
56+
by importing from `redpanda.agents`. Creating an `Agent` looks like:
2957

30-
## Chapters
58+
```python
59+
my_agent = Agent(
60+
name="my_first_agent",
61+
model="openai/gpt-4o",
62+
instructions="These are your instructions - good luck!",
63+
)
64+
```
3165

32-
1. [Agent
33-
](01_agent_.md)
34-
2. [Tool
35-
](02_tool_.md)
36-
3. [ToolResponse
37-
](03_toolresponse_.md)
38-
4. [AgentHooks
39-
](04_agenthooks_.md)
40-
5. [MCPEndpoint
41-
](05_mcpendpoint_.md)
42-
6. [RPKMCPEndpoint
43-
](06_rpkmcpendpoint_.md)
44-
7. [mcp_client
45-
](07_mcp_client_.md)
46-
8. [RuntimeServer
47-
](08_runtimeserver_.md)
66+
Once you've created the agent, you pass it off to the runtime to handle messages in the pipeline like so:
4867

68+
```python
69+
asyncio.run(redpanda.runtime.serve(my_agent))
70+
```
4971

50-
---
72+
### `mcp/resources/processors/*.yaml`
73+
74+
In order to give tools to your agent, you need to first define them as yaml files with the following structure:
75+
76+
```yaml
77+
label: '<label>'
78+
processors:
79+
- <processors>
80+
meta:
81+
mcp:
82+
enabled: true
83+
description: '<description>'
84+
```
85+
86+
The `<label>` is what must be provided under the list of `tools` in the agent YAML file, while the
87+
processors can be any [Redpanda Connect processor](https://docs.redpanda.com/redpanda-connect/components/processors/about/).
88+
89+
<!--
90+
TODO
91+
92+
### `mcp/resources/caches/*.yaml`
93+
94+
### `mcp/o11y/tracer.yaml`
95+
96+
### `mcp/o11y/metrics.yaml`
97+
98+
-->
99+
100+
## Running
101+
102+
To run our agent, we can do that with `rpk connect agent run my_first_agent`
51103

52-
Generated by [AI Codebase Knowledge Builder](https://github.com/The-Pocket/Tutorial-Codebase-Knowledge)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ For example:
1212
• You can connect via standard input/output (like launching a program and talking with it).
1313
• You can connect via Server-Sent Events (SSE).
1414
• You can connect via WebSocket.
15-
• Or you can do something more specialized like RPKMCPEndpoint (we’ll see that in [Chapter 6: RPKMCPEndpoint](06_rpkmcpendpoint_.md)).
1615

1716
Think of MCPEndpoint as the base blueprint. Different subclasses (e.g., StdioMCPEndpoint, SSEMCPEndpoint, WebsocketMCPEndpoint) each handle one style of communication.
1817

@@ -149,4 +148,4 @@ Explanation:
149148
• Different subclasses handle different connection methods: Stdio, SSE, WebSocket, etc.
150149
• You gain the flexibility of calling local or remote Tools in a uniform way.
151150

152-
Now that you’ve seen the basic Endpoint, let’s explore a special variation that launches a local process for you: the [RPKMCPEndpoint](06_rpkmcpendpoint_.md). This can be handy when you want to bundle the server’s logic right with your Agent without hosting externally. Get ready for the next step!
151+
Next time, we’ll look more closely at [mcp_client](07_mcp_client_.md), which is the library helper that actually does most of the handshake and messaging between your Python code and the server. You’ll see how it all fits together behind the scenes!
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Chapter 7: mcp_client
1+
# Chapter 6: mcp_client
22

3-
In the previous chapter, [RPKMCPEndpoint](06_rpkmcpendpoint_.md), we saw how an Agent can spin up a local MCP process using the “rpk connect mcp-server” command. Now, let's explore the core function that actually sets up the conversation with any MCP server—whether it’s local, remote, using Standard I/O, SSE, or WebSocket:
3+
In the [previous chapter: MCPEndpoint](05_mcpendpoint_.md), you learned how an Agent can communicate with external servers or local processes using different connection methods. Now, let's explore the core function that actually sets up the conversation with any MCP server—whether it’s local, remote, using Standard I/O, SSE, or WebSocket:
44

55
• The function name: `mcp_client`
66
• Purpose: Creates a temporary communication channel to an MCP server.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Chapter 8: RuntimeServer
1+
# Chapter 7: RuntimeServer
22

3-
In [Chapter 7: mcp_client](07_mcp_client_.md), we learned how to tap into an existing server that hosts tools or services. But what if you want others to tap into your Agent in the same way—via a simple, well-defined interface? That’s exactly where “RuntimeServer” shines.
3+
In [Chapter 6: mcp_client](07_mcp_client_.md), we learned how to tap into an existing server that hosts tools or services. But what if you want others to tap into your Agent in the same way—via a simple, well-defined interface? That’s exactly where “RuntimeServer” shines.
44

55
Imagine you have an Agent with all sorts of logic or tooling behind it, and you want to let an external system send requests. The external system might not speak Python, or it might be on a totally different tech stack. By using RuntimeServer, you can expose your Agent as a gRPC service—letting outside callers invoke it in real time, just like a translator who relays messages back and forth.
66

0 commit comments

Comments
 (0)