ag_ui_strands 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ag_ui_strands-0.1.0/.gitignore +134 -0
- ag_ui_strands-0.1.0/PKG-INFO +8 -0
- ag_ui_strands-0.1.0/README.md +58 -0
- ag_ui_strands-0.1.0/examples/.gitignore +98 -0
- ag_ui_strands-0.1.0/examples/README.md +82 -0
- ag_ui_strands-0.1.0/examples/poetry.lock +2931 -0
- ag_ui_strands-0.1.0/examples/pyproject.toml +23 -0
- ag_ui_strands-0.1.0/examples/server/__init__.py +74 -0
- ag_ui_strands-0.1.0/examples/server/__main__.py +7 -0
- ag_ui_strands-0.1.0/examples/server/api/__init__.py +15 -0
- ag_ui_strands-0.1.0/examples/server/api/agentic_chat.py +70 -0
- ag_ui_strands-0.1.0/examples/server/api/agentic_generative_ui.py +290 -0
- ag_ui_strands-0.1.0/examples/server/api/backend_tool_rendering.py +94 -0
- ag_ui_strands-0.1.0/examples/server/api/human_in_the_loop.py +116 -0
- ag_ui_strands-0.1.0/examples/server/api/shared_state.py +176 -0
- ag_ui_strands-0.1.0/poetry.lock +1419 -0
- ag_ui_strands-0.1.0/pyproject.toml +22 -0
- ag_ui_strands-0.1.0/src/ag_ui_strands/__init__.py +27 -0
- ag_ui_strands-0.1.0/src/ag_ui_strands/agent.py +657 -0
- ag_ui_strands-0.1.0/src/ag_ui_strands/config.py +104 -0
- ag_ui_strands-0.1.0/src/ag_ui_strands/endpoint.py +40 -0
- ag_ui_strands-0.1.0/src/ag_ui_strands/types.py +33 -0
- ag_ui_strands-0.1.0/src/ag_ui_strands/utils.py +24 -0
- ag_ui_strands-0.1.0/uv.lock +813 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
*.manifest
|
|
31
|
+
*.spec
|
|
32
|
+
|
|
33
|
+
# Installer logs
|
|
34
|
+
pip-log.txt
|
|
35
|
+
pip-delete-this-directory.txt
|
|
36
|
+
|
|
37
|
+
# Unit test / coverage reports
|
|
38
|
+
htmlcov/
|
|
39
|
+
.tox/
|
|
40
|
+
.nox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
.cache
|
|
44
|
+
nosetests.xml
|
|
45
|
+
coverage.xml
|
|
46
|
+
*.cover
|
|
47
|
+
*.py,cover
|
|
48
|
+
.hypothesis/
|
|
49
|
+
.pytest_cache/
|
|
50
|
+
cover/
|
|
51
|
+
|
|
52
|
+
# pyenv
|
|
53
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
54
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
55
|
+
# .python-version
|
|
56
|
+
|
|
57
|
+
# pipenv
|
|
58
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
59
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
60
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
61
|
+
# install all needed dependencies.
|
|
62
|
+
# Pipfile.lock
|
|
63
|
+
|
|
64
|
+
# UV
|
|
65
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
66
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
67
|
+
# commonly ignored for libraries.
|
|
68
|
+
# uv.lock
|
|
69
|
+
|
|
70
|
+
# poetry
|
|
71
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
72
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
73
|
+
# commonly ignored for libraries.
|
|
74
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
75
|
+
# poetry.lock
|
|
76
|
+
# poetry.toml
|
|
77
|
+
|
|
78
|
+
# pdm
|
|
79
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
80
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
81
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
82
|
+
# pdm.lock
|
|
83
|
+
# pdm.toml
|
|
84
|
+
.pdm-python
|
|
85
|
+
.pdm-build/
|
|
86
|
+
|
|
87
|
+
# pixi
|
|
88
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
89
|
+
# pixi.lock
|
|
90
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
91
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
92
|
+
.pixi
|
|
93
|
+
|
|
94
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
95
|
+
__pypackages__/
|
|
96
|
+
|
|
97
|
+
# Environments
|
|
98
|
+
.env
|
|
99
|
+
.envrc
|
|
100
|
+
.venv
|
|
101
|
+
env/
|
|
102
|
+
venv/
|
|
103
|
+
ENV/
|
|
104
|
+
env.bak/
|
|
105
|
+
venv.bak/
|
|
106
|
+
|
|
107
|
+
# Spyder project settings
|
|
108
|
+
.spyderproject
|
|
109
|
+
.spyproject
|
|
110
|
+
|
|
111
|
+
# Rope project settings
|
|
112
|
+
.ropeproject
|
|
113
|
+
|
|
114
|
+
# mypy
|
|
115
|
+
.mypy_cache/
|
|
116
|
+
.dmypy.json
|
|
117
|
+
dmypy.json
|
|
118
|
+
|
|
119
|
+
# Ruff
|
|
120
|
+
.ruff_cache/
|
|
121
|
+
|
|
122
|
+
# PyPI configuration file
|
|
123
|
+
.pypirc
|
|
124
|
+
|
|
125
|
+
# IDE
|
|
126
|
+
.vscode/
|
|
127
|
+
.idea/
|
|
128
|
+
*.swp
|
|
129
|
+
*.swo
|
|
130
|
+
*~
|
|
131
|
+
|
|
132
|
+
# OS
|
|
133
|
+
.DS_Store
|
|
134
|
+
Thumbs.db
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# AWS Strands Integration for AG-UI
|
|
2
|
+
|
|
3
|
+
This package exposes a lightweight wrapper that lets any `strands.Agent` speak the AG-UI protocol. It mirrors the developer experience of the other integrations: give us a Strands agent instance, plug it into `StrandsAgent`, and wire it to FastAPI via `create_strands_app` (or `add_strands_fastapi_endpoint`).
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Python 3.10+
|
|
8
|
+
- `poetry` (recommended) or `pip`
|
|
9
|
+
- A Strands-compatible model key (e.g., `GOOGLE_API_KEY` for Gemini)
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
The `examples/server/__main__.py` module mounts all demo routes behind a single FastAPI app. Run:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
cd integrations/aws-strands/python/examples
|
|
18
|
+
poetry install
|
|
19
|
+
poetry run python -m server
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
It exposes:
|
|
23
|
+
|
|
24
|
+
| Route | Description |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `/agentic-chat` | Frontend tool demo |
|
|
27
|
+
| `/backend-tool-rendering` | Backend tool rendering demo |
|
|
28
|
+
| `/shared-state` | Shared recipe state |
|
|
29
|
+
| `/agentic-generative-ui` | Agentic UI with PredictState |
|
|
30
|
+
|
|
31
|
+
This is the easiest way to test multiple flows locally. Each route still follows the pattern described below (Strands agent → wrapper → FastAPI).
|
|
32
|
+
|
|
33
|
+
## Architecture Overview
|
|
34
|
+
|
|
35
|
+
The integration has three main layers:
|
|
36
|
+
|
|
37
|
+
- **StrandsAgent** – wraps `strands.Agent.stream_async`. It translates Strands events into AG-UI events (text chunks, tool calls, PredictState, snapshots, etc.).
|
|
38
|
+
- **Configuration** – `StrandsAgentConfig` + `ToolBehavior` + `PredictStateMapping` let you describe tool-specific quirks declaratively (skip message snapshots, emit state, stream args, send confirm actions, etc.).
|
|
39
|
+
- **Transport helpers** – `create_strands_app` and `add_strands_fastapi_endpoint` expose the agent via SSE. They are thin shells over the shared `ag_ui.encoder.EventEncoder`.
|
|
40
|
+
|
|
41
|
+
See [ARCHITECTURE.md](ARCHITECTURE.md) for diagrams and a deeper dive.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Key Files
|
|
45
|
+
|
|
46
|
+
| File | Description |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `src/ag_ui_strands/agent.py` | Core wrapper translating Strands streams into AG-UI events |
|
|
49
|
+
| `src/ag_ui_strands/config.py` | Config primitives (`StrandsAgentConfig`, `ToolBehavior`, `PredictStateMapping`) |
|
|
50
|
+
| `src/ag_ui_strands/endpoint.py` | FastAPI endpoint helper |
|
|
51
|
+
| `examples/server/api/*.py` | Ready-to-run demo apps |
|
|
52
|
+
|
|
53
|
+
## Next Steps
|
|
54
|
+
|
|
55
|
+
- Wire Strands’ callback handler into the wrapper to expose multi-agent metadata.
|
|
56
|
+
- Add an event queue layer (like the ADK middleware) for resumable streams and non-HTTP transports.
|
|
57
|
+
- Expand the test suite as new behaviors land.
|
|
58
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Installer logs
|
|
35
|
+
pip-log.txt
|
|
36
|
+
pip-delete-this-directory.txt
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.nox/
|
|
42
|
+
.coverage
|
|
43
|
+
.coverage.*
|
|
44
|
+
.cache
|
|
45
|
+
nosetests.xml
|
|
46
|
+
coverage.xml
|
|
47
|
+
*.cover
|
|
48
|
+
*.py,cover
|
|
49
|
+
.hypothesis/
|
|
50
|
+
.pytest_cache/
|
|
51
|
+
|
|
52
|
+
# pyenv
|
|
53
|
+
.python-version
|
|
54
|
+
|
|
55
|
+
# pipenv
|
|
56
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
57
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
58
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
59
|
+
# install all needed dependencies.
|
|
60
|
+
#Pipfile.lock
|
|
61
|
+
|
|
62
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
63
|
+
__pypackages__/
|
|
64
|
+
|
|
65
|
+
# Environments
|
|
66
|
+
.env
|
|
67
|
+
.venv
|
|
68
|
+
env/
|
|
69
|
+
venv/
|
|
70
|
+
ENV/
|
|
71
|
+
env.bak/
|
|
72
|
+
venv.bak/
|
|
73
|
+
|
|
74
|
+
# Spyder project settings
|
|
75
|
+
.spyderproject
|
|
76
|
+
.spyproject
|
|
77
|
+
|
|
78
|
+
# Rope project settings
|
|
79
|
+
.ropeproject
|
|
80
|
+
|
|
81
|
+
# mypy
|
|
82
|
+
.mypy_cache/
|
|
83
|
+
.dmypy.json
|
|
84
|
+
dmypy.json
|
|
85
|
+
|
|
86
|
+
# Ruff
|
|
87
|
+
.ruff_cache/
|
|
88
|
+
|
|
89
|
+
# IDE
|
|
90
|
+
.vscode/
|
|
91
|
+
.idea/
|
|
92
|
+
*.swp
|
|
93
|
+
*.swo
|
|
94
|
+
*~
|
|
95
|
+
|
|
96
|
+
# OS
|
|
97
|
+
.DS_Store
|
|
98
|
+
Thumbs.db
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# AWS Strands Example Server
|
|
2
|
+
|
|
3
|
+
Demo FastAPI server that wires the Strands Agents SDK (Gemini models) into the
|
|
4
|
+
AG-UI protocol. Each route mounts a ready-made agent that showcases different UI
|
|
5
|
+
patterns (vanilla chat, backend tool rendering, shared state, and generative UI).
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Python 3.12 or 3.13 (the project is pinned to `<3.14`)
|
|
10
|
+
- Poetry 1.8+ (ships with the repo via `curl -sSL https://install.python-poetry.org | python3 -`)
|
|
11
|
+
- Google API key with access to Gemini 2.5 Flash (set as `GOOGLE_API_KEY`)
|
|
12
|
+
- (Optional) AG-UI repo running locally so you can point the Dojo at these routes
|
|
13
|
+
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
cd integrations/aws-strands/python/examples
|
|
18
|
+
|
|
19
|
+
# pick a supported interpreter if your global default is 3.14
|
|
20
|
+
poetry env use python3.13
|
|
21
|
+
|
|
22
|
+
poetry install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Create a `.env` file in this folder (same dir as `pyproject.toml`) so every
|
|
26
|
+
example can load credentials automatically:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
GOOGLE_API_KEY=your-gemini-key
|
|
30
|
+
# Optional overrides
|
|
31
|
+
PORT=8000 # FastAPI listen port
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
> The sample agents default to `gemini-2.5-flash` and already set sensible
|
|
35
|
+
> temperature/token parameters; override only if you need a different tier.
|
|
36
|
+
|
|
37
|
+
## Running the demo server
|
|
38
|
+
|
|
39
|
+
Either command exposes all mounted apps on `http://localhost:${PORT:-8000}`:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
poetry run dev # uses the Poetry script entry point (server:main)
|
|
43
|
+
# or
|
|
44
|
+
poetry run python -m server
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The root route lists the available demos:
|
|
48
|
+
|
|
49
|
+
| Route | Description |
|
|
50
|
+
| --- | --- |
|
|
51
|
+
| `/agentic-chat` | Simple chat agent with a frontend-only `change_background` tool |
|
|
52
|
+
| `/backend-tool-rendering` | Backend-executed tools (charts, faux weather) rendered in AG-UI |
|
|
53
|
+
| `/agentic-generative-ui` | Demonstrates `PredictState` + delta streaming for plan tracking |
|
|
54
|
+
| `/shared-state` | Recipe builder showing shared JSON state + tool arguments |
|
|
55
|
+
|
|
56
|
+
Point the AG-UI Dojo (or any AG-UI client) at these SSE endpoints to see the
|
|
57
|
+
Strands wrapper translate Gemini events into protocol-native messages.
|
|
58
|
+
|
|
59
|
+
## Environment reference
|
|
60
|
+
|
|
61
|
+
| Variable | Required | Purpose |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| `GOOGLE_API_KEY` | Yes | Auth for the Gemini SDK (`strands.models.gemini.GeminiModel`) |
|
|
64
|
+
| `PORT` | No | Overrides the default `8000` uvicorn port |
|
|
65
|
+
|
|
66
|
+
All OpenTelemetry exporters are disabled by default in code (`OTEL_SDK_DISABLED`
|
|
67
|
+
and `OTEL_PYTHON_DISABLED_INSTRUMENTATIONS`), so you do not need to set those
|
|
68
|
+
manually.
|
|
69
|
+
|
|
70
|
+
## How it works
|
|
71
|
+
|
|
72
|
+
- Each `server/api/*.py` file constructs a Strands `Agent`, registers any tools,
|
|
73
|
+
and wraps it with `ag_ui_strands.StrandsAgent`.
|
|
74
|
+
- `server/__init__.py` mounts the four FastAPI apps under a single router and
|
|
75
|
+
exposes the `main()` entrypoint that `poetry run dev` calls.
|
|
76
|
+
- The project depends on `ag_ui_strands` via a path dependency (`..`) so you can
|
|
77
|
+
develop the integration and server side-by-side without publishing a wheel.
|
|
78
|
+
- Want a different Gemini tier? Update the `model_id` argument in the agent
|
|
79
|
+
definitions inside `server/api/*.py`.
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|