debug-agent-py 0.2.2__tar.gz → 0.4.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.
Files changed (45) hide show
  1. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/PKG-INFO +140 -5
  2. debug_agent_py-0.4.0/README.md +270 -0
  3. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/pyproject.toml +5 -1
  4. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/inspectors/__init__.py +13 -0
  5. debug_agent_py-0.4.0/src/debug_agent/inspectors/cache_inspector.py +224 -0
  6. debug_agent_py-0.4.0/src/debug_agent/inspectors/celery.py +231 -0
  7. debug_agent_py-0.4.0/src/debug_agent/inspectors/django.py +278 -0
  8. debug_agent_py-0.4.0/src/debug_agent/inspectors/fastapi_ext.py +226 -0
  9. debug_agent_py-0.4.0/src/debug_agent/inspectors/fd_inspector.py +150 -0
  10. debug_agent_py-0.4.0/src/debug_agent/inspectors/flask_ext.py +171 -0
  11. debug_agent_py-0.4.0/src/debug_agent/inspectors/http_client_inspector.py +230 -0
  12. debug_agent_py-0.4.0/src/debug_agent/inspectors/jinja2.py +214 -0
  13. debug_agent_py-0.4.0/src/debug_agent/inspectors/logging_inspector.py +194 -0
  14. debug_agent_py-0.4.0/src/debug_agent/inspectors/metrics_inspector.py +102 -0
  15. debug_agent_py-0.4.0/src/debug_agent/inspectors/redis.py +285 -0
  16. debug_agent_py-0.4.0/src/debug_agent/inspectors/signals.py +115 -0
  17. debug_agent_py-0.4.0/src/debug_agent/inspectors/warnings_inspector.py +85 -0
  18. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent_py.egg-info/PKG-INFO +140 -5
  19. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent_py.egg-info/SOURCES.txt +13 -0
  20. debug_agent_py-0.4.0/src/debug_agent_py.egg-info/requires.txt +36 -0
  21. debug_agent_py-0.2.2/README.md +0 -149
  22. debug_agent_py-0.2.2/src/debug_agent_py.egg-info/requires.txt +0 -18
  23. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/setup.cfg +0 -0
  24. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/__init__.py +0 -0
  25. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/chat_session.py +0 -0
  26. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/config.py +0 -0
  27. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/context_compressor.py +0 -0
  28. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/engine.py +0 -0
  29. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/inspectors/async_tasks.py +0 -0
  30. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/inspectors/database.py +0 -0
  31. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/inspectors/framework.py +0 -0
  32. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/inspectors/http_tracker.py +0 -0
  33. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/inspectors/memory.py +0 -0
  34. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/inspectors/modules.py +0 -0
  35. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/inspectors/runtime.py +0 -0
  36. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/inspectors/system.py +0 -0
  37. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/inspectors/threads.py +0 -0
  38. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/llm_client.py +0 -0
  39. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/middleware.py +0 -0
  40. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/system_prompt_builder.py +0 -0
  41. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/tool_registry.py +0 -0
  42. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/web/__init__.py +0 -0
  43. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent/web/chat_page.py +0 -0
  44. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent_py.egg-info/dependency_links.txt +0 -0
  45. {debug_agent_py-0.2.2 → debug_agent_py-0.4.0}/src/debug_agent_py.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: debug-agent-py
3
- Version: 0.2.2
3
+ Version: 0.4.0
4
4
  Summary: AI-powered runtime debugging agent for Python web applications
5
5
  Author-email: ggcode <noreply@ggcode.dev>
6
6
  License: MIT
@@ -29,6 +29,20 @@ Provides-Extra: flask
29
29
  Requires-Dist: flask>=2.3; extra == "flask"
30
30
  Provides-Extra: django
31
31
  Requires-Dist: django>=4.2; extra == "django"
32
+ Provides-Extra: sqlalchemy
33
+ Requires-Dist: sqlalchemy>=2.0; extra == "sqlalchemy"
34
+ Requires-Dist: flask-sqlalchemy>=3.0; extra == "sqlalchemy"
35
+ Provides-Extra: redis
36
+ Requires-Dist: redis>=5.0; extra == "redis"
37
+ Provides-Extra: celery
38
+ Requires-Dist: celery>=5.3; extra == "celery"
39
+ Provides-Extra: demo
40
+ Requires-Dist: flask>=2.3; extra == "demo"
41
+ Requires-Dist: sqlalchemy>=2.0; extra == "demo"
42
+ Requires-Dist: flask-sqlalchemy>=3.0; extra == "demo"
43
+ Requires-Dist: redis>=5.0; extra == "demo"
44
+ Requires-Dist: celery>=5.3; extra == "demo"
45
+ Requires-Dist: gunicorn>=21.2; extra == "demo"
32
46
  Provides-Extra: dev
33
47
  Requires-Dist: fastapi; extra == "dev"
34
48
  Requires-Dist: uvicorn; extra == "dev"
@@ -37,7 +51,11 @@ Requires-Dist: pytest; extra == "dev"
37
51
 
38
52
  # Python Debug Agent
39
53
 
40
- An AI-powered runtime debugging agent that embeds directly into your Python web application. Add one dependency, configure an LLM key, and chat with your live app at `/agent` to inspect memory, threads, GC, modules, database connections, routes, HTTP requests, and more.
54
+ [![debug-agent-py](https://img.shields.io/pypi/v/debug-agent-py.svg)](https://pypi.org/project/debug-agent-py/)
55
+ ![Tools](https://img.shields.io/badge/tools-68-blue)
56
+ ![Inspectors](https://img.shields.io/badge/inspectors-24-green)
57
+
58
+ An AI-powered runtime debugging agent that embeds directly into your Python web application. Add one dependency, configure an LLM key, and chat with your live app at `/agent` to inspect memory, threads, GC, modules, database connections, Redis, Django models/URLs, Celery tasks, Flask extensions, Jinja2 templates, signals, routes, HTTP requests, and more — **68 diagnostic tools across 24 inspectors**.
41
59
 
42
60
  ## Quick Start
43
61
 
@@ -81,10 +99,11 @@ http://localhost:8000/agent
81
99
  - **Context compression** — automatically summarizes old conversation when token limit is approached
82
100
  - **Dark-themed chat UI** with full markdown rendering (tables, code blocks, lists)
83
101
  - **Max tool rounds** (25) with forced final summary when limit is reached
84
- - **34 diagnostic tools** across 10 inspectors
102
+ - **68 diagnostic tools** across **24 inspectors**
85
103
  - Works with Flask, FastAPI, and Django
104
+ - Zero external dependencies (no Datadog, no Grafana, no APM)
86
105
 
87
- ## Inspectors & Tools (34)
106
+ ## Inspectors & Tools (68)
88
107
 
89
108
  ### Memory Inspector
90
109
  | Tool | Description |
@@ -101,12 +120,14 @@ http://localhost:8000/agent
101
120
  | `get_thread_info` | List all threads with name, daemon, alive status |
102
121
  | `get_thread_count` | Active thread count |
103
122
  | `get_thread_summary` | Thread state distribution |
123
+ | `get_thread_stacks` | Current frame/stack for all threads |
104
124
 
105
125
  ### Database Inspector
106
126
  | Tool | Description |
107
127
  |------|-------------|
108
128
  | `get_sqlalchemy_engines` | Find SQLAlchemy engines and pool status |
109
129
  | `get_db_connections` | Inspect database connection pools |
130
+ | `get_db_pool_config` | Pool configuration: size, timeout, recycle settings |
110
131
 
111
132
  ### Modules Inspector
112
133
  | Tool | Description |
@@ -120,6 +141,7 @@ http://localhost:8000/agent
120
141
  |------|-------------|
121
142
  | `get_async_tasks` | List pending asyncio tasks |
122
143
  | `get_event_loop_info` | Event loop details: type, running state |
144
+ | `get_pending_callbacks` | List scheduled callbacks on the event loop |
123
145
 
124
146
  ### Runtime Inspector
125
147
  | Tool | Description |
@@ -127,13 +149,14 @@ http://localhost:8000/agent
127
149
  | `get_memory_info` | Process memory info (RSS, VMS, shared) |
128
150
  | `get_cpu_usage` | CPU usage percentage |
129
151
  | `get_python_info` | Python version, implementation, executable path |
152
+ | `get_open_fds` | Open file descriptor count and limits |
130
153
 
131
154
  ### System Inspector
132
155
  | Tool | Description |
133
156
  |------|-------------|
134
157
  | `get_system_info` | Hostname, platform, CPU cores, disk |
135
158
  | `get_environment_variables` | Environment variables (masked secrets) |
136
- | `get_disk_usage` | Disk usage for working directory |
159
+ | `get_disk_usage` | Disk usage for the working directory |
137
160
 
138
161
  ### Framework Inspector
139
162
  | Tool | Description |
@@ -149,6 +172,98 @@ http://localhost:8000/agent
149
172
  | `get_error_requests` | Error requests (4xx/5xx) |
150
173
  | `get_request_stats` | P50/P95/P99 latency, error rate |
151
174
 
175
+ ### Redis Inspector
176
+ | Tool | Description |
177
+ |------|-------------|
178
+ | `get_redis_info` | Redis server info: memory, clients, persistence |
179
+ | `get_redis_keys` | Scan Redis keyspace with pattern matching |
180
+ | `get_redis_config` | Redis runtime configuration (CONFIG GET) |
181
+ | `get_redis_slowlog` | Redis slow query log entries |
182
+
183
+ ### Django Inspector
184
+ | Tool | Description |
185
+ |------|-------------|
186
+ | `get_django_models` | List Django models with app label, table name, field count |
187
+ | `get_django_urls` | List all URL patterns with view names and namespaces |
188
+ | `get_django_settings` | Key Django settings (DBs, INSTALLED_APPS, MIDDLEWARE) |
189
+ | `get_django_migrations` | Migration status per app: applied vs pending |
190
+
191
+ ### Celery Inspector
192
+ | Tool | Description |
193
+ |------|-------------|
194
+ | `get_celery_tasks` | List registered Celery tasks with routing info |
195
+ | `get_celery_workers` | Active Celery workers with pool and concurrency |
196
+ | `get_celery_queues` | Queue depth and message stats per queue |
197
+
198
+ ### Flask Extensions Inspector
199
+ | Tool | Description |
200
+ |------|-------------|
201
+ | `get_flask_extensions` | List registered Flask extensions and their bindings |
202
+ | `get_flask_blueprints` | List Flask blueprints with URL prefixes and routes |
203
+ | `get_flask_config` | Flask configuration object values (secrets masked) |
204
+
205
+ ### Jinja2 Inspector
206
+ | Tool | Description |
207
+ |------|-------------|
208
+ | `get_jinja_templates` | List loaded Jinja2 templates with loader paths |
209
+ | `get_jinja_filters` | List registered Jinja2 filters, tests, and globals |
210
+
211
+ ### Signals Inspector
212
+ | Tool | Description |
213
+ |------|-------------|
214
+ | `get_signal_handlers` | List Python signal handlers registered via signal module |
215
+ | `get_django_signals` | List Django signal receivers connected to senders |
216
+
217
+ ### WSGI/ASGI Inspector
218
+ | Tool | Description |
219
+ |------|-------------|
220
+ | `get_wsgi_info` | WSGI server details (Gunicorn/uWSGI workers, config) |
221
+ | `get_asgi_apps` | List ASGI application scope and middleware chain |
222
+
223
+ ### Logging Inspector
224
+ | Tool | Description |
225
+ |------|-------------|
226
+ | `get_logging_tree` | Python logging module logger hierarchy and levels |
227
+ | `get_recent_logs` | Recent log entries from the built-in ring buffer |
228
+ | `get_logging_config` | Current logging configuration (handlers, formatters, levels) |
229
+ | `set_log_level` | Dynamically set the log level for a named logger |
230
+
231
+ ### Cache Inspector
232
+ | Tool | Description |
233
+ |------|-------------|
234
+ | `get_cache_info` | Stats for registered caches (hit rate, miss count, key count) |
235
+ | `get_cache_keys` | List keys from a registered cache with optional prefix filter |
236
+ | `clear_cache` | Clear all entries from a registered cache |
237
+
238
+ ### Outbound HTTP Inspector
239
+ | Tool | Description |
240
+ |------|-------------|
241
+ | `get_http_pool_stats` | HTTP client connection pool stats (connections, keepalive, timeouts) |
242
+ | `get_outbound_summary` | Aggregated outbound HTTP call stats (total, avg latency, error rate) |
243
+
244
+ ### File Descriptor Inspector
245
+ | Tool | Description |
246
+ |------|-------------|
247
+ | `get_fd_count` | Current number of open file descriptors |
248
+ | `get_fd_limit` | File descriptor soft and hard limits (RLIMIT_NOFILE) |
249
+ | `get_fd_list` | List open file descriptors with type and details |
250
+
251
+ ### Metrics Inspector
252
+ | Tool | Description |
253
+ |------|-------------|
254
+ | `get_registered_metrics` | List all registered metrics from prometheus_client |
255
+ | `get_metric_value` | Get current value of a specific metric by name |
256
+
257
+ ### FastAPI Inspector
258
+ | Tool | Description |
259
+ |------|-------------|
260
+ | `get_fastapi_openapi` | List FastAPI routes, schemas, and OpenAPI spec details |
261
+
262
+ ### Warnings Inspector
263
+ | Tool | Description |
264
+ |------|-------------|
265
+ | `get_warnings` | List captured Python warnings with category, message, and location |
266
+
152
267
  ## Custom Tools
153
268
 
154
269
  ```python
@@ -171,6 +286,26 @@ def check_redis():
171
286
 
172
287
  ## Run the Demo
173
288
 
289
+ The demo uses **Flask** + **redis-py** + **SQLAlchemy** + **Celery**. Start Redis with Docker Compose first:
290
+
291
+ ### Docker Compose
292
+
293
+ ```yaml
294
+ # docker-compose.yml
295
+ services:
296
+ redis:
297
+ image: redis:7-alpine
298
+ ports:
299
+ - "6379:6379"
300
+ command: redis-server --save 60 1 --loglevel warning
301
+ ```
302
+
303
+ ```bash
304
+ docker compose up -d
305
+ ```
306
+
307
+ ### Start the app
308
+
174
309
  ```bash
175
310
  export LLM_API_KEY=your-key
176
311
  cd demo && python app.py
@@ -0,0 +1,270 @@
1
+ # Python Debug Agent
2
+
3
+ [![debug-agent-py](https://img.shields.io/pypi/v/debug-agent-py.svg)](https://pypi.org/project/debug-agent-py/)
4
+ ![Tools](https://img.shields.io/badge/tools-68-blue)
5
+ ![Inspectors](https://img.shields.io/badge/inspectors-24-green)
6
+
7
+ An AI-powered runtime debugging agent that embeds directly into your Python web application. Add one dependency, configure an LLM key, and chat with your live app at `/agent` to inspect memory, threads, GC, modules, database connections, Redis, Django models/URLs, Celery tasks, Flask extensions, Jinja2 templates, signals, routes, HTTP requests, and more — **68 diagnostic tools across 24 inspectors**.
8
+
9
+ ## Quick Start
10
+
11
+ ### 1. Install
12
+
13
+ ```bash
14
+ pip install debug-agent-py
15
+ ```
16
+
17
+ ### 2. Integrate (Flask)
18
+
19
+ ```python
20
+ from flask import Flask
21
+ from debug_agent import setup_debug_agent
22
+
23
+ app = Flask(__name__)
24
+
25
+ # One line to integrate
26
+ setup_debug_agent(app)
27
+ ```
28
+
29
+ ### 3. Configure LLM
30
+
31
+ ```bash
32
+ export LLM_API_KEY=your-key
33
+ export LLM_BASE_URL=https://open.bigmodel.cn/api/coding/paas/v4 # default
34
+ export LLM_MODEL=glm-5.2 # default
35
+ ```
36
+
37
+ Supports any OpenAI-compatible endpoint.
38
+
39
+ ### 4. Run and open
40
+
41
+ ```
42
+ http://localhost:8000/agent
43
+ ```
44
+
45
+ ## Features
46
+
47
+ - **Streaming AI responses** with real-time tool call badges (pending / success / error)
48
+ - **Context compression** — automatically summarizes old conversation when token limit is approached
49
+ - **Dark-themed chat UI** with full markdown rendering (tables, code blocks, lists)
50
+ - **Max tool rounds** (25) with forced final summary when limit is reached
51
+ - **68 diagnostic tools** across **24 inspectors**
52
+ - Works with Flask, FastAPI, and Django
53
+ - Zero external dependencies (no Datadog, no Grafana, no APM)
54
+
55
+ ## Inspectors & Tools (68)
56
+
57
+ ### Memory Inspector
58
+ | Tool | Description |
59
+ |------|-------------|
60
+ | `get_tracemalloc_stats` | Python tracemalloc top allocations by file/line |
61
+ | `get_object_counts` | Count objects by type via gc |
62
+ | `get_gc_stats` | gc.get_stats() generation details |
63
+ | `get_ref_cycles` | Count reference cycles detected by gc |
64
+ | `trigger_gc` | Force garbage collection |
65
+
66
+ ### Threads Inspector
67
+ | Tool | Description |
68
+ |------|-------------|
69
+ | `get_thread_info` | List all threads with name, daemon, alive status |
70
+ | `get_thread_count` | Active thread count |
71
+ | `get_thread_summary` | Thread state distribution |
72
+ | `get_thread_stacks` | Current frame/stack for all threads |
73
+
74
+ ### Database Inspector
75
+ | Tool | Description |
76
+ |------|-------------|
77
+ | `get_sqlalchemy_engines` | Find SQLAlchemy engines and pool status |
78
+ | `get_db_connections` | Inspect database connection pools |
79
+ | `get_db_pool_config` | Pool configuration: size, timeout, recycle settings |
80
+
81
+ ### Modules Inspector
82
+ | Tool | Description |
83
+ |------|-------------|
84
+ | `get_loaded_modules` | List loaded Python modules (sys.modules) with versions |
85
+ | `get_module_count` | Total loaded module count |
86
+ | `get_installed_packages` | List installed packages from pip |
87
+
88
+ ### Async Tasks Inspector
89
+ | Tool | Description |
90
+ |------|-------------|
91
+ | `get_async_tasks` | List pending asyncio tasks |
92
+ | `get_event_loop_info` | Event loop details: type, running state |
93
+ | `get_pending_callbacks` | List scheduled callbacks on the event loop |
94
+
95
+ ### Runtime Inspector
96
+ | Tool | Description |
97
+ |------|-------------|
98
+ | `get_memory_info` | Process memory info (RSS, VMS, shared) |
99
+ | `get_cpu_usage` | CPU usage percentage |
100
+ | `get_python_info` | Python version, implementation, executable path |
101
+ | `get_open_fds` | Open file descriptor count and limits |
102
+
103
+ ### System Inspector
104
+ | Tool | Description |
105
+ |------|-------------|
106
+ | `get_system_info` | Hostname, platform, CPU cores, disk |
107
+ | `get_environment_variables` | Environment variables (masked secrets) |
108
+ | `get_disk_usage` | Disk usage for the working directory |
109
+
110
+ ### Framework Inspector
111
+ | Tool | Description |
112
+ |------|-------------|
113
+ | `get_routes` | List all registered web routes/endpoints |
114
+ | `get_middleware` | List registered middleware |
115
+
116
+ ### HTTP Tracker Inspector
117
+ | Tool | Description |
118
+ |------|-------------|
119
+ | `get_recent_requests` | Recent HTTP requests ring buffer |
120
+ | `get_slow_requests` | Slowest requests by duration |
121
+ | `get_error_requests` | Error requests (4xx/5xx) |
122
+ | `get_request_stats` | P50/P95/P99 latency, error rate |
123
+
124
+ ### Redis Inspector
125
+ | Tool | Description |
126
+ |------|-------------|
127
+ | `get_redis_info` | Redis server info: memory, clients, persistence |
128
+ | `get_redis_keys` | Scan Redis keyspace with pattern matching |
129
+ | `get_redis_config` | Redis runtime configuration (CONFIG GET) |
130
+ | `get_redis_slowlog` | Redis slow query log entries |
131
+
132
+ ### Django Inspector
133
+ | Tool | Description |
134
+ |------|-------------|
135
+ | `get_django_models` | List Django models with app label, table name, field count |
136
+ | `get_django_urls` | List all URL patterns with view names and namespaces |
137
+ | `get_django_settings` | Key Django settings (DBs, INSTALLED_APPS, MIDDLEWARE) |
138
+ | `get_django_migrations` | Migration status per app: applied vs pending |
139
+
140
+ ### Celery Inspector
141
+ | Tool | Description |
142
+ |------|-------------|
143
+ | `get_celery_tasks` | List registered Celery tasks with routing info |
144
+ | `get_celery_workers` | Active Celery workers with pool and concurrency |
145
+ | `get_celery_queues` | Queue depth and message stats per queue |
146
+
147
+ ### Flask Extensions Inspector
148
+ | Tool | Description |
149
+ |------|-------------|
150
+ | `get_flask_extensions` | List registered Flask extensions and their bindings |
151
+ | `get_flask_blueprints` | List Flask blueprints with URL prefixes and routes |
152
+ | `get_flask_config` | Flask configuration object values (secrets masked) |
153
+
154
+ ### Jinja2 Inspector
155
+ | Tool | Description |
156
+ |------|-------------|
157
+ | `get_jinja_templates` | List loaded Jinja2 templates with loader paths |
158
+ | `get_jinja_filters` | List registered Jinja2 filters, tests, and globals |
159
+
160
+ ### Signals Inspector
161
+ | Tool | Description |
162
+ |------|-------------|
163
+ | `get_signal_handlers` | List Python signal handlers registered via signal module |
164
+ | `get_django_signals` | List Django signal receivers connected to senders |
165
+
166
+ ### WSGI/ASGI Inspector
167
+ | Tool | Description |
168
+ |------|-------------|
169
+ | `get_wsgi_info` | WSGI server details (Gunicorn/uWSGI workers, config) |
170
+ | `get_asgi_apps` | List ASGI application scope and middleware chain |
171
+
172
+ ### Logging Inspector
173
+ | Tool | Description |
174
+ |------|-------------|
175
+ | `get_logging_tree` | Python logging module logger hierarchy and levels |
176
+ | `get_recent_logs` | Recent log entries from the built-in ring buffer |
177
+ | `get_logging_config` | Current logging configuration (handlers, formatters, levels) |
178
+ | `set_log_level` | Dynamically set the log level for a named logger |
179
+
180
+ ### Cache Inspector
181
+ | Tool | Description |
182
+ |------|-------------|
183
+ | `get_cache_info` | Stats for registered caches (hit rate, miss count, key count) |
184
+ | `get_cache_keys` | List keys from a registered cache with optional prefix filter |
185
+ | `clear_cache` | Clear all entries from a registered cache |
186
+
187
+ ### Outbound HTTP Inspector
188
+ | Tool | Description |
189
+ |------|-------------|
190
+ | `get_http_pool_stats` | HTTP client connection pool stats (connections, keepalive, timeouts) |
191
+ | `get_outbound_summary` | Aggregated outbound HTTP call stats (total, avg latency, error rate) |
192
+
193
+ ### File Descriptor Inspector
194
+ | Tool | Description |
195
+ |------|-------------|
196
+ | `get_fd_count` | Current number of open file descriptors |
197
+ | `get_fd_limit` | File descriptor soft and hard limits (RLIMIT_NOFILE) |
198
+ | `get_fd_list` | List open file descriptors with type and details |
199
+
200
+ ### Metrics Inspector
201
+ | Tool | Description |
202
+ |------|-------------|
203
+ | `get_registered_metrics` | List all registered metrics from prometheus_client |
204
+ | `get_metric_value` | Get current value of a specific metric by name |
205
+
206
+ ### FastAPI Inspector
207
+ | Tool | Description |
208
+ |------|-------------|
209
+ | `get_fastapi_openapi` | List FastAPI routes, schemas, and OpenAPI spec details |
210
+
211
+ ### Warnings Inspector
212
+ | Tool | Description |
213
+ |------|-------------|
214
+ | `get_warnings` | List captured Python warnings with category, message, and location |
215
+
216
+ ## Custom Tools
217
+
218
+ ```python
219
+ from debug_agent import debug_tool
220
+
221
+ @debug_tool('check_redis', 'Check Redis connection')
222
+ def check_redis():
223
+ return {'connected': True}
224
+ ```
225
+
226
+ ## Configuration
227
+
228
+ | Env Var | Default | Description |
229
+ |---------|---------|-------------|
230
+ | `LLM_BASE_URL` | `https://open.bigmodel.cn/api/coding/paas/v4` | LLM endpoint |
231
+ | `LLM_API_KEY` | (required) | API key |
232
+ | `LLM_MODEL` | `glm-5.2` | Model name |
233
+ | `LLM_MAX_TOOL_ROUNDS` | `25` | Max tool-calling rounds |
234
+ | `LLM_CONTEXT_WINDOW_TOKENS` | `100000` | Context window size |
235
+
236
+ ## Run the Demo
237
+
238
+ The demo uses **Flask** + **redis-py** + **SQLAlchemy** + **Celery**. Start Redis with Docker Compose first:
239
+
240
+ ### Docker Compose
241
+
242
+ ```yaml
243
+ # docker-compose.yml
244
+ services:
245
+ redis:
246
+ image: redis:7-alpine
247
+ ports:
248
+ - "6379:6379"
249
+ command: redis-server --save 60 1 --loglevel warning
250
+ ```
251
+
252
+ ```bash
253
+ docker compose up -d
254
+ ```
255
+
256
+ ### Start the app
257
+
258
+ ```bash
259
+ export LLM_API_KEY=your-key
260
+ cd demo && python app.py
261
+ # Open http://localhost:8000/agent
262
+ ```
263
+
264
+ ## PyPI
265
+
266
+ [![debug-agent-py](https://img.shields.io/pypi/v/debug-agent-py.svg)](https://pypi.org/project/debug-agent-py/)
267
+
268
+ ## License
269
+
270
+ MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "debug-agent-py"
7
- version = "0.2.2"
7
+ version = "0.4.0"
8
8
  description = "AI-powered runtime debugging agent for Python web applications"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -33,6 +33,10 @@ dependencies = [
33
33
  fastapi = ["fastapi>=0.100", "starlette>=0.27", "uvicorn>=0.23"]
34
34
  flask = ["flask>=2.3"]
35
35
  django = ["django>=4.2"]
36
+ sqlalchemy = ["sqlalchemy>=2.0", "flask-sqlalchemy>=3.0"]
37
+ redis = ["redis>=5.0"]
38
+ celery = ["celery>=5.3"]
39
+ demo = ["flask>=2.3", "sqlalchemy>=2.0", "flask-sqlalchemy>=3.0", "redis>=5.0", "celery>=5.3", "gunicorn>=21.2"]
36
40
  dev = ["fastapi", "uvicorn", "flask", "pytest"]
37
41
 
38
42
  [project.urls]
@@ -2,12 +2,25 @@
2
2
 
3
3
  from debug_agent.inspectors import ( # noqa: F401
4
4
  async_tasks,
5
+ cache_inspector,
6
+ celery,
5
7
  database,
8
+ django,
9
+ fastapi_ext,
10
+ fd_inspector,
11
+ flask_ext,
6
12
  framework,
13
+ http_client_inspector,
7
14
  http_tracker,
15
+ jinja2,
16
+ logging_inspector,
8
17
  memory,
18
+ metrics_inspector,
9
19
  modules,
20
+ redis,
10
21
  runtime,
22
+ signals,
11
23
  system,
12
24
  threads,
25
+ warnings_inspector,
13
26
  )