django-agent-studio 0.2.6__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 (41) hide show
  1. django_agent_studio-0.2.6/LICENSE +83 -0
  2. django_agent_studio-0.2.6/PKG-INFO +509 -0
  3. django_agent_studio-0.2.6/README.md +389 -0
  4. django_agent_studio-0.2.6/__init__.py +12 -0
  5. django_agent_studio-0.2.6/agents/__init__.py +29 -0
  6. django_agent_studio-0.2.6/agents/builder.py +3531 -0
  7. django_agent_studio-0.2.6/agents/dynamic.py +693 -0
  8. django_agent_studio-0.2.6/api/__init__.py +4 -0
  9. django_agent_studio-0.2.6/api/permissions.py +160 -0
  10. django_agent_studio-0.2.6/api/serializers.py +606 -0
  11. django_agent_studio-0.2.6/api/urls.py +303 -0
  12. django_agent_studio-0.2.6/api/views.py +2060 -0
  13. django_agent_studio-0.2.6/apps.py +24 -0
  14. django_agent_studio-0.2.6/django_agent_studio.egg-info/PKG-INFO +509 -0
  15. django_agent_studio-0.2.6/django_agent_studio.egg-info/SOURCES.txt +70 -0
  16. django_agent_studio-0.2.6/django_agent_studio.egg-info/dependency_links.txt +1 -0
  17. django_agent_studio-0.2.6/django_agent_studio.egg-info/requires.txt +11 -0
  18. django_agent_studio-0.2.6/django_agent_studio.egg-info/top_level.txt +1 -0
  19. django_agent_studio-0.2.6/management/__init__.py +2 -0
  20. django_agent_studio-0.2.6/management/commands/__init__.py +2 -0
  21. django_agent_studio-0.2.6/migrations/0001_initial.py +63 -0
  22. django_agent_studio-0.2.6/migrations/__init__.py +0 -0
  23. django_agent_studio-0.2.6/models/__init__.py +18 -0
  24. django_agent_studio-0.2.6/models/permissions.py +191 -0
  25. django_agent_studio-0.2.6/pyproject.toml +90 -0
  26. django_agent_studio-0.2.6/services/__init__.py +14 -0
  27. django_agent_studio-0.2.6/services/permissions.py +228 -0
  28. django_agent_studio-0.2.6/setup.cfg +4 -0
  29. django_agent_studio-0.2.6/static/agent-frontend/chat-widget-markdown.js +110 -0
  30. django_agent_studio-0.2.6/static/agent-frontend/chat-widget.css +1824 -0
  31. django_agent_studio-0.2.6/static/agent-frontend/chat-widget.js +478 -0
  32. django_agent_studio-0.2.6/static/django_agent_studio/js/builder.js +247 -0
  33. django_agent_studio-0.2.6/static/django_agent_studio/js/builder.js.map +1 -0
  34. django_agent_studio-0.2.6/static/django_agent_studio/js/style.css +1 -0
  35. django_agent_studio-0.2.6/templates/django_agent_studio/agent_list.html +101 -0
  36. django_agent_studio-0.2.6/templates/django_agent_studio/base.html +138 -0
  37. django_agent_studio-0.2.6/templates/django_agent_studio/builder.html +37 -0
  38. django_agent_studio-0.2.6/templates/django_agent_studio/home.html +97 -0
  39. django_agent_studio-0.2.6/templates/django_agent_studio/test.html +126 -0
  40. django_agent_studio-0.2.6/urls.py +25 -0
  41. django_agent_studio-0.2.6/views.py +100 -0
@@ -0,0 +1,83 @@
1
+ Business Source License 1.1
2
+
3
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
5
+
6
+ Parameters
7
+
8
+ Licensor: Chris Barry
9
+ Licensed Work: django-agent-studio
10
+ The Licensed Work is (c) 2025 Chris Barry
11
+ Additional Use Grant: You may use the Licensed Work for non-production purposes,
12
+ including development, testing, and evaluation. Production
13
+ use requires a commercial license from the Licensor.
14
+ Change Date: 2029-01-24
15
+ Change License: MIT
16
+
17
+ Terms
18
+
19
+ The Licensor hereby grants you the right to copy, modify, create derivative
20
+ works, redistribute, and make non-production use of the Licensed Work. The
21
+ Licensor may make an Additional Use Grant, above, permitting limited production
22
+ use.
23
+
24
+ Effective on the Change Date, or the fourth anniversary of the first publicly
25
+ available distribution of a specific version of the Licensed Work under this
26
+ License, whichever comes first, the Licensor hereby grants you rights under
27
+ the terms of the Change License, and the rights granted in the paragraph above
28
+ terminate.
29
+
30
+ If your use of the Licensed Work does not comply with the requirements
31
+ currently in effect as described in this License, you must purchase a
32
+ commercial license from the Licensor, its affiliated entities, or authorized
33
+ resellers, or you must refrain from using the Licensed Work.
34
+
35
+ All copies of the original and modified Licensed Work, and derivative works
36
+ of the Licensed Work, are subject to this License. This License applies
37
+ separately for each version of the Licensed Work and the Change Date may vary
38
+ for each version of the Licensed Work released by Licensor.
39
+
40
+ You must conspicuously display this License on each original or modified copy
41
+ of the Licensed Work. If you receive the Licensed Work in original or
42
+ modified form from a third party, the terms and conditions set forth in this
43
+ License apply to your use of that work.
44
+
45
+ Any use of the Licensed Work in violation of this License will automatically
46
+ terminate your rights under this License for the current and all other
47
+ versions of the Licensed Work.
48
+
49
+ This License does not grant you any right in any trademark or logo of
50
+ Licensor or its affiliates (provided that you may use a trademark or logo of
51
+ Licensor as expressly required by this License).
52
+
53
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
54
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
55
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
56
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
57
+ TITLE.
58
+
59
+ MariaDB hereby grants you permission to use this License's text to license
60
+ your works, and to refer to it using the trademark "Business Source License",
61
+ as long as you comply with the Covenants of Licensor below.
62
+
63
+ Covenants of Licensor
64
+
65
+ In consideration of the right to use this License's text and the "Business
66
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
67
+ other recipients of the licensed work to be provided by Licensor:
68
+
69
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
70
+ or a license that is compatible with GPL Version 2.0 or a later version,
71
+ where "compatible" means that software provided under the Change License can
72
+ be included in a program with software provided under GPL Version 2.0 or a
73
+ later version. Licensor may specify additional Change Licenses without
74
+ limitation.
75
+
76
+ 2. To either: (a) specify an additional grant of rights to use that does not
77
+ impose any additional restriction on the right granted in this License, as
78
+ the Additional Use Grant; or (b) insert the text "None".
79
+
80
+ 3. To specify a Change Date.
81
+
82
+ 4. Not to modify this License in any other way.
83
+
@@ -0,0 +1,509 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-agent-studio
3
+ Version: 0.2.6
4
+ Summary: Visual agent builder and management studio for Django - build custom GPTs with a two-pane interface
5
+ Author: Chris Barry
6
+ License: Business Source License 1.1
7
+
8
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
9
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
10
+
11
+ Parameters
12
+
13
+ Licensor: Chris Barry
14
+ Licensed Work: django-agent-studio
15
+ The Licensed Work is (c) 2025 Chris Barry
16
+ Additional Use Grant: You may use the Licensed Work for non-production purposes,
17
+ including development, testing, and evaluation. Production
18
+ use requires a commercial license from the Licensor.
19
+ Change Date: 2029-01-24
20
+ Change License: MIT
21
+
22
+ Terms
23
+
24
+ The Licensor hereby grants you the right to copy, modify, create derivative
25
+ works, redistribute, and make non-production use of the Licensed Work. The
26
+ Licensor may make an Additional Use Grant, above, permitting limited production
27
+ use.
28
+
29
+ Effective on the Change Date, or the fourth anniversary of the first publicly
30
+ available distribution of a specific version of the Licensed Work under this
31
+ License, whichever comes first, the Licensor hereby grants you rights under
32
+ the terms of the Change License, and the rights granted in the paragraph above
33
+ terminate.
34
+
35
+ If your use of the Licensed Work does not comply with the requirements
36
+ currently in effect as described in this License, you must purchase a
37
+ commercial license from the Licensor, its affiliated entities, or authorized
38
+ resellers, or you must refrain from using the Licensed Work.
39
+
40
+ All copies of the original and modified Licensed Work, and derivative works
41
+ of the Licensed Work, are subject to this License. This License applies
42
+ separately for each version of the Licensed Work and the Change Date may vary
43
+ for each version of the Licensed Work released by Licensor.
44
+
45
+ You must conspicuously display this License on each original or modified copy
46
+ of the Licensed Work. If you receive the Licensed Work in original or
47
+ modified form from a third party, the terms and conditions set forth in this
48
+ License apply to your use of that work.
49
+
50
+ Any use of the Licensed Work in violation of this License will automatically
51
+ terminate your rights under this License for the current and all other
52
+ versions of the Licensed Work.
53
+
54
+ This License does not grant you any right in any trademark or logo of
55
+ Licensor or its affiliates (provided that you may use a trademark or logo of
56
+ Licensor as expressly required by this License).
57
+
58
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
59
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
60
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
61
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
62
+ TITLE.
63
+
64
+ MariaDB hereby grants you permission to use this License's text to license
65
+ your works, and to refer to it using the trademark "Business Source License",
66
+ as long as you comply with the Covenants of Licensor below.
67
+
68
+ Covenants of Licensor
69
+
70
+ In consideration of the right to use this License's text and the "Business
71
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
72
+ other recipients of the licensed work to be provided by Licensor:
73
+
74
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
75
+ or a license that is compatible with GPL Version 2.0 or a later version,
76
+ where "compatible" means that software provided under the Change License can
77
+ be included in a program with software provided under GPL Version 2.0 or a
78
+ later version. Licensor may specify additional Change Licenses without
79
+ limitation.
80
+
81
+ 2. To either: (a) specify an additional grant of rights to use that does not
82
+ impose any additional restriction on the right granted in this License, as
83
+ the Additional Use Grant; or (b) insert the text "None".
84
+
85
+ 3. To specify a Change Date.
86
+
87
+ 4. Not to modify this License in any other way.
88
+
89
+
90
+ Project-URL: Homepage, https://github.com/makemore/django-agent-studio
91
+ Project-URL: Documentation, https://github.com/makemore/django-agent-studio#readme
92
+ Project-URL: Repository, https://github.com/makemore/django-agent-studio
93
+ Keywords: django,ai,agent,llm,gpt,builder,studio
94
+ Classifier: Development Status :: 3 - Alpha
95
+ Classifier: Environment :: Web Environment
96
+ Classifier: Framework :: Django
97
+ Classifier: Framework :: Django :: 4.2
98
+ Classifier: Framework :: Django :: 5.0
99
+ Classifier: Intended Audience :: Developers
100
+ Classifier: Operating System :: OS Independent
101
+ Classifier: Programming Language :: Python :: 3
102
+ Classifier: Programming Language :: Python :: 3.10
103
+ Classifier: Programming Language :: Python :: 3.11
104
+ Classifier: Programming Language :: Python :: 3.12
105
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
106
+ Requires-Python: >=3.10
107
+ Description-Content-Type: text/markdown
108
+ License-File: LICENSE
109
+ Requires-Dist: Django>=4.2
110
+ Requires-Dist: djangorestframework>=3.14
111
+ Requires-Dist: django-agent-runtime>=0.3.12
112
+ Provides-Extra: dev
113
+ Requires-Dist: pytest>=7.0; extra == "dev"
114
+ Requires-Dist: pytest-django>=4.5; extra == "dev"
115
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
116
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
117
+ Requires-Dist: black>=23.0; extra == "dev"
118
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
119
+ Dynamic: license-file
120
+
121
+ # Django Agent Studio
122
+
123
+ A visual agent builder and management interface for Django applications. Create, customize, and test AI agents through a conversational interface or REST API.
124
+
125
+ ## Recent Updates
126
+
127
+ | Version | Date | Changes |
128
+ |---------|------|---------|
129
+ | **0.2.0** | 2026-01-28 | **Multi-Agent Systems** - System management UI, shared memory configuration, memory privacy controls, builder tools for managing agent systems |
130
+ | **0.1.9** | 2026-01-27 | Spec documents migration, improved builder agent |
131
+ | **0.1.0** | 2026-01-25 | Initial release with builder interface, dynamic tools, knowledge management |
132
+
133
+ ## Features
134
+
135
+ ### 🤖 Agent Builder Interface
136
+
137
+ A two-pane interface for building agents:
138
+ - **Left pane**: Test your agent in real-time
139
+ - **Right pane**: Conversational builder agent that helps you configure your agent
140
+
141
+ The builder agent can:
142
+ - Create new agents
143
+ - Update system prompts, models, and settings
144
+ - Add/remove tools and knowledge sources
145
+ - Scan your Django project for functions to use as tools
146
+ - Manage RAG (Retrieval-Augmented Generation) configuration
147
+
148
+ ### 🔧 Dynamic Tool Discovery
149
+
150
+ Automatically discover functions in your Django project that can be used as agent tools:
151
+
152
+ ```python
153
+ # Functions like this are automatically discovered
154
+ def get_customer_orders(customer_id: int, limit: int = 10) -> list[dict]:
155
+ """
156
+ Fetch recent orders for a customer.
157
+
158
+ Args:
159
+ customer_id: The customer's ID
160
+ limit: Maximum number of orders to return
161
+
162
+ Returns:
163
+ List of order dictionaries
164
+ """
165
+ return Order.objects.filter(customer_id=customer_id)[:limit]
166
+ ```
167
+
168
+ The scanner extracts:
169
+ - Function signatures and parameters
170
+ - Type hints and docstrings
171
+ - Whether functions are async
172
+ - Side effect detection (writes, deletes, etc.)
173
+
174
+ ### 📚 Knowledge Management
175
+
176
+ Add context to your agents through multiple knowledge types:
177
+ - **Text**: Direct text content
178
+ - **URL**: Web pages (fetched and indexed)
179
+ - **File**: Uploaded documents
180
+ - **Dynamic**: Generated at runtime via callbacks
181
+
182
+ Knowledge can be:
183
+ - Always included in context
184
+ - Included via RAG similarity search
185
+ - Included on-demand when relevant
186
+
187
+ ### 🔐 Permission System
188
+
189
+ Fine-grained access control for dynamic tool operations:
190
+
191
+ | Level | Capabilities |
192
+ |-------|-------------|
193
+ | **None** | No access to dynamic tools |
194
+ | **Viewer** | View discovered functions and existing tools |
195
+ | **Scanner** | Scan project for functions |
196
+ | **Requester** | Request tool creation (needs admin approval) |
197
+ | **Creator** | Create tools directly |
198
+ | **Admin** | Full access including approving requests |
199
+
200
+ ### ✅ Approval Workflow
201
+
202
+ For organizations requiring oversight:
203
+ 1. Users with "Requester" access submit tool creation requests
204
+ 2. Admins review proposed tool configurations
205
+ 3. Admins can approve (with optional modifications) or reject
206
+ 4. Approved tools are automatically created and marked as verified
207
+
208
+ ### 📝 Version Control
209
+
210
+ - **Agent Versions**: Create and manage multiple versions of an agent
211
+ - **Revisions**: Automatic snapshots after every change
212
+ - **Restore**: Roll back to any previous revision
213
+
214
+ ## Installation
215
+
216
+ ```bash
217
+ pip install django-agent-studio
218
+ ```
219
+
220
+ Add to your `INSTALLED_APPS`:
221
+
222
+ ```python
223
+ INSTALLED_APPS = [
224
+ # ...
225
+ 'django_agent_runtime', # Required dependency
226
+ 'django_agent_studio',
227
+ ]
228
+ ```
229
+
230
+ Include the URLs:
231
+
232
+ ```python
233
+ # urls.py
234
+ from django.urls import path, include
235
+
236
+ urlpatterns = [
237
+ # ...
238
+ path('studio/', include('django_agent_studio.urls')),
239
+ path('api/agent-runtime/', include('django_agent_runtime.api.urls')),
240
+ ]
241
+ ```
242
+
243
+ Run migrations:
244
+
245
+ ```bash
246
+ python manage.py migrate
247
+ ```
248
+
249
+ ## Usage
250
+
251
+ ### Web Interface
252
+
253
+ Navigate to `/studio/` to access the agent builder interface.
254
+
255
+ ### REST API
256
+
257
+ #### Agents
258
+
259
+ ```http
260
+ # List your agents
261
+ GET /studio/api/agents/
262
+
263
+ # Create an agent
264
+ POST /studio/api/agents/
265
+ {
266
+ "name": "Customer Support Bot",
267
+ "description": "Helps customers with orders and returns"
268
+ }
269
+
270
+ # Get agent details
271
+ GET /studio/api/agents/{id}/
272
+
273
+ # Get full agent schema (for debugging/export)
274
+ GET /studio/api/agents/{id}/full-schema/
275
+
276
+ # Update agent schema
277
+ PUT /studio/api/agents/{id}/full-schema/
278
+ ```
279
+
280
+ #### Versions
281
+
282
+ ```http
283
+ # List versions
284
+ GET /studio/api/agents/{id}/versions/
285
+
286
+ # Create a new version
287
+ POST /studio/api/agents/{id}/versions/
288
+
289
+ # Activate a version
290
+ POST /studio/api/agents/{id}/versions/{version_id}/activate/
291
+ ```
292
+
293
+ #### Tools
294
+
295
+ ```http
296
+ # List agent tools
297
+ GET /studio/api/agents/{id}/tools/
298
+
299
+ # Add a tool
300
+ POST /studio/api/agents/{id}/tools/
301
+
302
+ # List dynamic tools
303
+ GET /studio/api/agents/{id}/dynamic-tools/
304
+
305
+ # Toggle dynamic tool active status
306
+ POST /studio/api/agents/{id}/dynamic-tools/{tool_id}/toggle/
307
+ ```
308
+
309
+ #### Knowledge
310
+
311
+ ```http
312
+ # List knowledge sources
313
+ GET /studio/api/agents/{id}/knowledge/
314
+
315
+ # Add knowledge
316
+ POST /studio/api/agents/{id}/knowledge/
317
+ {
318
+ "name": "Product FAQ",
319
+ "knowledge_type": "text",
320
+ "content": "Q: How do I return an item?...",
321
+ "inclusion_mode": "always"
322
+ }
323
+ ```
324
+
325
+ #### Dynamic Tool Discovery
326
+
327
+ ```http
328
+ # Scan project for functions
329
+ POST /studio/api/agents/{id}/scan-project/
330
+ {
331
+ "include_private": false,
332
+ "include_tests": false,
333
+ "app_filter": "myapp"
334
+ }
335
+
336
+ # List discovered functions
337
+ GET /studio/api/discovered-functions/
338
+
339
+ # Generate tools from functions
340
+ POST /studio/api/agents/{id}/generate-tools/
341
+ {
342
+ "function_ids": ["uuid1", "uuid2"],
343
+ "requires_confirmation": true
344
+ }
345
+ ```
346
+
347
+ #### Approval Workflow
348
+
349
+ ```http
350
+ # List approval requests
351
+ GET /studio/api/tool-approval-requests/
352
+
353
+ # Review a request (admin only)
354
+ POST /studio/api/tool-approval-requests/{id}/review/
355
+ {
356
+ "action": "approve", # or "reject"
357
+ "review_notes": "Looks good!",
358
+ "override_name": "custom_tool_name" # optional
359
+ }
360
+
361
+ # Cancel your own request
362
+ POST /studio/api/tool-approval-requests/{id}/cancel/
363
+ ```
364
+
365
+ #### Permission Management
366
+
367
+ ```http
368
+ # Get your access level
369
+ GET /studio/api/dynamic-tool-access/me/
370
+
371
+ # Grant access (admin only)
372
+ POST /studio/api/dynamic-tool-access/grant/
373
+ {
374
+ "user_id": 123,
375
+ "access_level": "creator",
376
+ "restricted_to_agent_ids": ["uuid1"], # optional
377
+ "notes": "Granted for project X"
378
+ }
379
+
380
+ # Revoke access (admin only)
381
+ POST /studio/api/dynamic-tool-access/revoke/
382
+ {
383
+ "user_id": 123
384
+ }
385
+ ```
386
+
387
+ #### Templates
388
+
389
+ ```http
390
+ # List public template agents
391
+ GET /studio/api/templates/
392
+
393
+ # Fork a template
394
+ POST /studio/api/agents/{id}/fork/
395
+ ```
396
+
397
+ ## Builder Agent
398
+
399
+ The builder agent (`agent-builder`) is a special agent that helps users create and configure other agents through conversation. It has access to tools for:
400
+
401
+ - `create_agent` - Create a new agent
402
+ - `get_current_config` - View current agent configuration
403
+ - `update_system_prompt` - Update the agent's personality/instructions
404
+ - `update_agent_name` - Change name and description
405
+ - `update_model_settings` - Change LLM model and parameters
406
+ - `add_knowledge` - Add knowledge sources
407
+ - `remove_knowledge` - Remove knowledge sources
408
+ - `scan_project_for_tools` - Discover functions in the codebase
409
+ - `list_discovered_functions` - Browse discovered functions
410
+ - `get_function_details` - Get details about a specific function
411
+ - `add_tool_from_function` - Add a function as a tool
412
+ - `list_agent_tools` - List all tools on the agent
413
+ - `remove_tool` - Remove a tool
414
+ - `list_revisions` - View revision history
415
+ - `get_revision` - Get a specific revision
416
+ - `restore_revision` - Restore to a previous state
417
+ - `index_knowledge` - Index knowledge for RAG
418
+ - `get_rag_status` - Check RAG indexing status
419
+ - `preview_rag_search` - Test RAG search queries
420
+ - `update_rag_config` - Configure RAG settings
421
+
422
+ ## Multi-Agent Systems
423
+
424
+ Django Agent Studio supports building multi-agent systems where agents can invoke other agents as tools. This enables powerful patterns like routers, specialists, and hierarchical agent teams.
425
+
426
+ ### Overview
427
+
428
+ Multi-agent systems use the "agent-as-tool" pattern from `agent-runtime-core`:
429
+
430
+ - **Router Pattern**: A main agent routes requests to specialist agents
431
+ - **Delegation**: Sub-agents run and return results to the parent
432
+ - **Handoff**: Control transfers completely to a sub-agent
433
+
434
+ For full documentation, see:
435
+ - [agent-runtime-core Multi-Agent Systems](https://github.com/makemore/agent-runtime-core#multi-agent-systems)
436
+ - [django-agent-runtime Multi-Agent Systems](https://github.com/makemore/django-agent-runtime#multi-agent-systems)
437
+
438
+ ### Using Multi-Agent with Studio Agents
439
+
440
+ Studio-created agents can be used as sub-agents in code-defined router agents:
441
+
442
+ ```python
443
+ from django_agent_studio.runtime import StudioAgentRuntime
444
+ from agent_runtime_core.multi_agent import AgentTool, InvocationMode, ContextMode
445
+
446
+ # Load a studio-created agent
447
+ billing_agent = StudioAgentRuntime.from_agent_id("uuid-of-billing-agent")
448
+
449
+ # Wrap it as a tool
450
+ billing_tool = AgentTool(
451
+ agent=billing_agent,
452
+ name="billing_specialist",
453
+ description="Handles billing questions and refunds",
454
+ invocation_mode=InvocationMode.DELEGATE,
455
+ )
456
+
457
+ # Use in a router agent
458
+ class RouterAgent(AgentRuntime):
459
+ def __init__(self):
460
+ self.agent_tools = [billing_tool]
461
+
462
+ async def run(self, ctx: RunContext) -> RunResult:
463
+ # Register and use agent tools...
464
+ pass
465
+ ```
466
+
467
+ ### Key Concepts
468
+
469
+ | Concept | Description |
470
+ |---------|-------------|
471
+ | **AgentTool** | Wraps any agent to be callable as a tool |
472
+ | **DELEGATE mode** | Sub-agent returns result to parent (parent continues) |
473
+ | **HANDOFF mode** | Control transfers to sub-agent (parent exits) |
474
+ | **Context modes** | FULL (all history), SUMMARY, or MESSAGE_ONLY |
475
+
476
+ ### Events
477
+
478
+ Multi-agent invocations emit events for observability:
479
+
480
+ - `sub_agent.start` - Sub-agent invocation started
481
+ - `sub_agent.end` - Sub-agent completed
482
+ - Events include `parent_run_id` and `sub_agent_run_id` for tracing
483
+
484
+ ## Configuration
485
+
486
+ Configure via Django settings or environment variables:
487
+
488
+ ```python
489
+ AGENT_RUNTIME = {
490
+ # Default model for new agents
491
+ 'DEFAULT_MODEL': 'gpt-4o',
492
+
493
+ # RAG settings
494
+ 'RAG_EMBEDDING_MODEL': 'text-embedding-3-small',
495
+ 'RAG_CHUNK_SIZE': 500,
496
+ 'RAG_CHUNK_OVERLAP': 50,
497
+ }
498
+ ```
499
+
500
+ ## Dependencies
501
+
502
+ - `django-agent-runtime` - Core agent runtime
503
+ - `agent-runtime-core` - Agent execution framework
504
+ - `agent-frontend` - Chat widget for the UI
505
+
506
+ ## License
507
+
508
+ MIT
509
+