Skip to content

Commit 5243567

Browse files
Initial documentation changes
1 parent 6d7d558 commit 5243567

File tree

2 files changed

+96
-106
lines changed

2 files changed

+96
-106
lines changed

typescript-sdk/integrations/adk-middleware/README.md

Lines changed: 94 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,90 @@
11
# ADK Middleware for AG-UI Protocol
22

3-
This Python middleware enables Google ADK agents to be used with the AG-UI Protocol, providing a seamless bridge between the two frameworks.
3+
This Python middleware enables [Google ADK](https://google.github.io/adk-docs/) agents to be used with the AG-UI Protocol, providing a bridge between the two frameworks.
44

5-
## Features
5+
## Prerequisites
66

7-
- ⚠️ Full event translation between AG-UI and ADK (partial - full support coming soon)
8-
- ✅ Automatic session management with configurable timeouts
9-
- ✅ Automatic session memory option - expired sessions automatically preserved in ADK memory service
10-
- ✅ Support for multiple agents with centralized registry
11-
- ❌ State synchronization between protocols (coming soon)
12-
-**Complete bidirectional tool support** - Enable AG-UI Protocol tools within Google ADK agents
13-
- ✅ Streaming responses with SSE
14-
- ✅ Multi-user support with session isolation
7+
The examples use ADK Agents using various Gemini models along with the AG-UI Dojo.
158

16-
## Installation
9+
- A [Gemini API Key](https://makersuite.google.com/app/apikey). The examples assume that this is exported via the GOOGLE_API_KEY environment variable.
10+
11+
## Quick Start
12+
13+
To use this integration you need to:
14+
15+
1. Clone the [AG-UI repository](https://github.com/ag-ui-protocol/ag-ui).
16+
17+
```bash
18+
git clone https://github.com/ag-ui-protocol/ag-ui.git
19+
```
20+
21+
2. Change to the `typescript-sdk/integrations/adk-middleware` directory.
22+
23+
```bash
24+
cd typescript-sdk/integrations/adk-middleware
25+
26+
3. Install the `adk-middleware` package from the local directory. For example,
27+
28+
```bash
29+
pip install .
30+
```
31+
32+
or
33+
34+
```bash
35+
uv pip install .
36+
```
37+
38+
4. Install the requirements for the `examples`, for example:
39+
40+
```bash
41+
pip install -r requirements.txt
42+
```
43+
44+
or:
45+
46+
```bash
47+
uv pip install -r requirements.txt
48+
```
49+
50+
5. Run the example fast_api server.
51+
52+
```bash
53+
export GOOGLE_API_KEY=<My API Key>
54+
python -m examples.fastapi_server
55+
```
56+
57+
or
58+
59+
```bash
60+
export GOOGLE_API_KEY=<My API Key>
61+
uv python -m examples.fastapi_server
62+
```
63+
64+
6. Open another terminal in the root directory of the ag-ui repository clone.
65+
66+
7. Start the integration ag-ui dojo:
67+
68+
```bash
69+
cd typescript-sdk
70+
pnpm install && pnpm run dev
71+
```
72+
73+
8. Visit [http://localhost:3000/adk-middleware](http://localhost:3000/adk-middleware).
74+
75+
9. Select View `ADK Middleware` from the sidebar.
1776

1877
### Development Setup
1978

79+
If you want to contribute to ADK Middleware development, you'll need to take some additional steps. You can either use the following script of the manual development setup.
80+
2081
```bash
2182
# From the adk-middleware directory
2283
chmod +x setup_dev.sh
2384
./setup_dev.sh
2485
```
2586
26-
### Manual Setup
87+
### Manual Development Setup
2788
2889
```bash
2990
# Create virtual environment
@@ -41,11 +102,22 @@ pip install -r requirements-dev.txt
41102
42103
This installs the ADK middleware in editable mode for development.
43104
44-
## Directory Structure Note
105+
## Testing
45106
46-
Although this is a Python integration, it lives in `typescript-sdk/integrations/` following the ag-ui-protocol repository conventions where all integrations are centralized regardless of implementation language.
107+
```bash
108+
# Run tests
109+
pytest
47110
48-
## Quick Start
111+
# With coverage
112+
pytest --cov=src/adk_middleware
113+
114+
# Specific test file
115+
pytest tests/test_adk_agent.py
116+
```
117+
118+
## Usage instructions
119+
120+
For instructions on using the ADK Middleware outside of the Dojo environment, see [Usage](./USAGE.md).
49121
50122
### Option 1: Direct Usage
51123
```python
@@ -71,6 +143,7 @@ async for event in agent.run(input_data):
71143
```
72144
73145
### Option 2: FastAPI Server
146+
74147
```python
75148
from fastapi import FastAPI
76149
from adk_middleware import ADKAgent, AgentRegistry, add_adk_fastapi_endpoint
@@ -171,7 +244,7 @@ agent = ADKAgent(
171244
app_name="my_app",
172245
user_id="user123",
173246
artifact_service=GCSArtifactService(),
174-
memory_service=VertexAIMemoryService(), # Enables automatic session memory!
247+
memory_service=VertexAIMemoryService(),
175248
credential_service=SecretManagerService(),
176249
use_in_memory_services=False
177250
)
@@ -198,11 +271,6 @@ agent = ADKAgent(
198271
# 3. Available for retrieval and context in future conversations
199272
```
200273

201-
**Benefits:**
202-
- **Zero-config**: Works automatically when a memory service is provided
203-
- **Comprehensive**: Applies to all session deletions (timeout, user limits, manual)
204-
- **Performance**: Preserves conversation history without manual intervention
205-
206274
### Memory Tools Integration
207275

208276
To enable memory functionality in your ADK agents, you need to add Google ADK's memory tools to your agents (not to the ADKAgent middleware):
@@ -223,7 +291,7 @@ my_agent = Agent(
223291
registry = AgentRegistry.get_instance()
224292
registry.set_default_agent(my_agent)
225293
226-
# Create middleware WITHOUT tools parameter - THIS IS CORRECT
294+
# Create middleware WITHOUT tools parameter
227295
adk_agent = ADKAgent(
228296
app_name="my_app",
229297
user_id="user123",
@@ -233,37 +301,12 @@ adk_agent = ADKAgent(
233301
234302
**⚠️ Important**: The `tools` parameter belongs to the ADK agent (like `Agent` or `LlmAgent`), **not** to the `ADKAgent` middleware. The middleware automatically handles any tools defined on the registered agents.
235303
236-
### Memory Testing Configuration
237-
238-
For testing memory functionality across sessions, you may want to shorten the default session timeouts:
239-
240-
```python
241-
# Normal production settings (default)
242-
adk_agent = ADKAgent(
243-
app_name="my_app",
244-
user_id="user123",
245-
memory_service=shared_memory_service
246-
# session_timeout_seconds=1200, # 20 minutes (default)
247-
# cleanup_interval_seconds=300 # 5 minutes (default)
248-
)
249-
250-
# Short timeouts for memory testing
251-
adk_agent = ADKAgent(
252-
app_name="my_app",
253-
user_id="user123",
254-
memory_service=shared_memory_service,
255-
session_timeout_seconds=60, # 1 minute for quick testing
256-
cleanup_interval_seconds=30 # 30 seconds cleanup for quick testing
257-
)
258-
```
259-
260304
**Testing Memory Workflow:**
305+
261306
1. Start a conversation and provide information (e.g., "My name is John")
262307
2. Wait for session timeout + cleanup interval (up to 90 seconds with testing config: 60s timeout + up to 30s for next cleanup cycle)
263-
3. Start a new conversation and ask about the information ("What's my name?")
264-
4. The agent should remember the information from the previous session
265-
266-
**⚠️ Note**: Always revert to production timeouts (defaults) for actual deployments.
308+
3. Start a new conversation and ask about the information ("What's my name?").
309+
4. The agent should remember the information from the previous session.
267310
268311
## Tool Support
269312
@@ -326,26 +369,6 @@ result = await proxy_tool.run_async(args, context) # Returns None immediately
326369
# Client provides result via ToolMessage in subsequent run
327370
```
328371
329-
#### Blocking Tools (`is_long_running=False`)
330-
**For immediate results with timeout protection**
331-
332-
- **Blocking pattern**: Waits for tool result with configurable timeout
333-
- **Timeout applied**: Default 300 seconds, configurable per tool
334-
- **Ideal for**: API calls, calculations, data retrieval
335-
- **Error handling**: TimeoutError raised if no result within timeout
336-
337-
```python
338-
# Blocking tool example
339-
calculator_tool = Tool(
340-
name="calculate",
341-
description="Perform mathematical calculations",
342-
parameters={"type": "object", "properties": {"expression": {"type": "string"}}}
343-
)
344-
345-
# Tool execution waits for result
346-
result = await proxy_tool.run_async(args, context) # Waits and returns result
347-
```
348-
349372
### Per-Tool Configuration
350373
351374
The `ClientProxyToolset` supports mixed execution modes within the same toolset:
@@ -372,7 +395,6 @@ toolset = ClientProxyToolset(
372395
- **`is_long_running`**: Default execution mode for all tools in the toolset
373396
- **`tool_long_running_config`**: Dict mapping tool names to specific `is_long_running` values
374397
- **Per-tool overrides**: Specific tools can override the default behavior
375-
- **Flexible mixing**: Same toolset can contain both long-running and blocking tools
376398
377399
### Tool Configuration
378400
@@ -734,36 +756,4 @@ RunAgentInput ──────> ADKAgent.run() ──────> Runner.run_
734756
│ EventTranslator │
735757
│ │ │
736758
BaseEvent[] <──────── translate events <──────── Event[]
737-
```
738-
739-
## Advanced Features
740-
741-
### Multi-User Support
742-
- Session isolation per user
743-
- Configurable session limits
744-
- Automatic resource cleanup
745-
746-
## Testing
747-
748-
```bash
749-
# Run tests
750-
pytest
751-
752-
# With coverage
753-
pytest --cov=src/adk_middleware
754-
755-
# Specific test file
756-
pytest tests/test_adk_agent.py
757-
```
758-
759-
## Contributing
760-
761-
1. Fork the repository
762-
2. Create a feature branch
763-
3. Make your changes
764-
4. Add tests
765-
5. Submit a pull request
766-
767-
## License
768-
769-
This project is part of the AG-UI Protocol and follows the same license terms.
759+
```

typescript-sdk/integrations/adk-middleware/quickstart.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ echo ""
3636
echo "Starting server..."
3737
echo ""
3838

39-
# Run the complete setup example
39+
# Run the fastapi example
4040
cd examples
41-
python complete_setup.py
41+
python fastapi_server.py

0 commit comments

Comments
 (0)