agent-framework-devui 1.0.0b260107__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 (24) hide show
  1. agent_framework_devui-1.0.0b260107/LICENSE +21 -0
  2. agent_framework_devui-1.0.0b260107/PKG-INFO +414 -0
  3. agent_framework_devui-1.0.0b260107/README.md +380 -0
  4. agent_framework_devui-1.0.0b260107/agent_framework_devui/__init__.py +267 -0
  5. agent_framework_devui-1.0.0b260107/agent_framework_devui/_cli.py +201 -0
  6. agent_framework_devui-1.0.0b260107/agent_framework_devui/_conversations.py +695 -0
  7. agent_framework_devui-1.0.0b260107/agent_framework_devui/_deployment.py +596 -0
  8. agent_framework_devui-1.0.0b260107/agent_framework_devui/_discovery.py +953 -0
  9. agent_framework_devui-1.0.0b260107/agent_framework_devui/_executor.py +1081 -0
  10. agent_framework_devui-1.0.0b260107/agent_framework_devui/_mapper.py +1813 -0
  11. agent_framework_devui-1.0.0b260107/agent_framework_devui/_openai/__init__.py +9 -0
  12. agent_framework_devui-1.0.0b260107/agent_framework_devui/_openai/_executor.py +270 -0
  13. agent_framework_devui-1.0.0b260107/agent_framework_devui/_server.py +1329 -0
  14. agent_framework_devui-1.0.0b260107/agent_framework_devui/_session.py +191 -0
  15. agent_framework_devui-1.0.0b260107/agent_framework_devui/_tracing.py +168 -0
  16. agent_framework_devui-1.0.0b260107/agent_framework_devui/_utils.py +635 -0
  17. agent_framework_devui-1.0.0b260107/agent_framework_devui/models/__init__.py +94 -0
  18. agent_framework_devui-1.0.0b260107/agent_framework_devui/models/_discovery_models.py +201 -0
  19. agent_framework_devui-1.0.0b260107/agent_framework_devui/models/_openai_custom.py +411 -0
  20. agent_framework_devui-1.0.0b260107/agent_framework_devui/ui/agentframework.svg +33 -0
  21. agent_framework_devui-1.0.0b260107/agent_framework_devui/ui/assets/index.css +1 -0
  22. agent_framework_devui-1.0.0b260107/agent_framework_devui/ui/assets/index.js +611 -0
  23. agent_framework_devui-1.0.0b260107/agent_framework_devui/ui/index.html +14 -0
  24. agent_framework_devui-1.0.0b260107/pyproject.toml +98 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
@@ -0,0 +1,414 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-framework-devui
3
+ Version: 1.0.0b260107
4
+ Summary: Debug UI for Microsoft Agent Framework with OpenAI-compatible API server.
5
+ Author-email: Microsoft <af-support@microsoft.com>
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Typing :: Typed
18
+ License-File: LICENSE
19
+ Requires-Dist: agent-framework-core
20
+ Requires-Dist: fastapi>=0.104.0
21
+ Requires-Dist: uvicorn[standard]>=0.24.0
22
+ Requires-Dist: python-dotenv>=1.0.0
23
+ Requires-Dist: pytest>=7.0.0 ; extra == "all"
24
+ Requires-Dist: watchdog>=3.0.0 ; extra == "all"
25
+ Requires-Dist: pytest>=7.0.0 ; extra == "dev"
26
+ Requires-Dist: watchdog>=3.0.0 ; extra == "dev"
27
+ Project-URL: homepage, https://github.com/microsoft/agent-framework
28
+ Project-URL: issues, https://github.com/microsoft/agent-framework/issues
29
+ Project-URL: release_notes, https://github.com/microsoft/agent-framework/releases?q=tag%3Apython-1&expanded=true
30
+ Project-URL: source, https://github.com/microsoft/agent-framework/tree/main/python
31
+ Provides-Extra: all
32
+ Provides-Extra: dev
33
+
34
+ # DevUI - A Sample App for Running Agents and Workflows
35
+
36
+ A lightweight, standalone sample app interface for running entities (agents/workflows) in the Microsoft Agent Framework supporting **directory-based discovery**, **in-memory entity registration**, and **sample entity gallery**.
37
+
38
+ > [!IMPORTANT]
39
+ > DevUI is a **sample app** to help you get started with the Agent Framework. It is **not** intended for production use. For production, or for features beyond what is provided in this sample app, it is recommended that you build your own custom interface and API server using the Agent Framework SDK.
40
+
41
+ ![DevUI Screenshot](./docs/devuiscreen.png)
42
+
43
+ ## Quick Start
44
+
45
+ ```bash
46
+ # Install
47
+ pip install agent-framework-devui --pre
48
+ ```
49
+
50
+ You can also launch it programmatically
51
+
52
+ ```python
53
+ from agent_framework import ChatAgent
54
+ from agent_framework.openai import OpenAIChatClient
55
+ from agent_framework.devui import serve
56
+
57
+ def get_weather(location: str) -> str:
58
+ """Get weather for a location."""
59
+ return f"Weather in {location}: 72°F and sunny"
60
+
61
+ # Create your agent
62
+ agent = ChatAgent(
63
+ name="WeatherAgent",
64
+ chat_client=OpenAIChatClient(),
65
+ tools=[get_weather]
66
+ )
67
+
68
+ # Launch debug UI - that's it!
69
+ serve(entities=[agent], auto_open=True)
70
+ # → Opens browser to http://localhost:8080
71
+ ```
72
+
73
+ In addition, if you have agents/workflows defined in a specific directory structure (see below), you can launch DevUI from the _cli_ to discover and run them.
74
+
75
+ ```bash
76
+
77
+ # Launch web UI + API server
78
+ devui ./agents --port 8080
79
+ # → Web UI: http://localhost:8080
80
+ # → API: http://localhost:8080/v1/*
81
+ ```
82
+
83
+ When DevUI starts with no discovered entities, it displays a **sample entity gallery** with curated examples from the Agent Framework repository. You can download these samples, review them, and run them locally to get started quickly.
84
+
85
+ ## Using MCP Tools
86
+
87
+ **Important:** Don't use `async with` context managers when creating agents with MCP tools for DevUI - connections will close before execution.
88
+
89
+ ```python
90
+ # ✅ Correct - DevUI handles cleanup automatically
91
+ mcp_tool = MCPStreamableHTTPTool(url="http://localhost:8011/mcp", chat_client=chat_client)
92
+ agent = ChatAgent(tools=mcp_tool)
93
+ serve(entities=[agent])
94
+ ```
95
+
96
+ MCP tools use lazy initialization and connect automatically on first use. DevUI attempts to clean up connections on shutdown
97
+
98
+ ## Resource Cleanup
99
+
100
+ Register cleanup hooks to properly close credentials and resources on shutdown:
101
+
102
+ ```python
103
+ from azure.identity.aio import DefaultAzureCredential
104
+ from agent_framework import ChatAgent
105
+ from agent_framework.azure import AzureOpenAIChatClient
106
+ from agent_framework_devui import register_cleanup, serve
107
+
108
+ credential = DefaultAzureCredential()
109
+ client = AzureOpenAIChatClient()
110
+ agent = ChatAgent(name="MyAgent", chat_client=client)
111
+
112
+ # Register cleanup hook - credential will be closed on shutdown
113
+ register_cleanup(agent, credential.close)
114
+ serve(entities=[agent])
115
+ ```
116
+
117
+ Works with multiple resources and file-based discovery. See tests for more examples.
118
+
119
+ ## Directory Structure
120
+
121
+ For your agents to be discovered by the DevUI, they must be organized in a directory structure like below. Each agent/workflow must have an `__init__.py` that exports the required variable (`agent` or `workflow`).
122
+
123
+ **Note**: `.env` files are optional but will be automatically loaded if present in the agent/workflow directory or parent entities directory. Use them to store API keys, configuration variables, and other environment-specific settings.
124
+
125
+ ```
126
+ agents/
127
+ ├── weather_agent/
128
+ │ ├── __init__.py # Must export: agent = ChatAgent(...)
129
+ │ ├── agent.py
130
+ │ └── .env # Optional: API keys, config vars
131
+ ├── my_workflow/
132
+ │ ├── __init__.py # Must export: workflow = WorkflowBuilder()...
133
+ │ ├── workflow.py
134
+ │ └── .env # Optional: environment variables
135
+ └── .env # Optional: shared environment variables
136
+ ```
137
+
138
+ ### Importing from External Modules
139
+
140
+ If your agents import tools or utilities from sibling directories (e.g., `from tools.helpers import my_tool`), you must set `PYTHONPATH` to include the parent directory:
141
+
142
+ ```bash
143
+ # Project structure:
144
+ # backend/
145
+ # ├── agents/
146
+ # │ └── my_agent/
147
+ # │ └── agent.py # contains: from tools.helpers import my_tool
148
+ # └── tools/
149
+ # └── helpers.py
150
+
151
+ # Run from project root with PYTHONPATH
152
+ cd backend
153
+ PYTHONPATH=. devui ./agents --port 8080
154
+ ```
155
+
156
+ Without `PYTHONPATH`, Python cannot find modules in sibling directories and DevUI will report an import error.
157
+
158
+ ## Viewing Telemetry (Otel Traces) in DevUI
159
+
160
+ Agent Framework emits OpenTelemetry (Otel) traces for various operations. You can view these traces in DevUI by enabling instrumentation when starting the server.
161
+
162
+ ```bash
163
+ devui ./agents --instrumentation
164
+ ```
165
+
166
+ ## OpenAI-Compatible API
167
+
168
+ For convenience, DevUI provides an OpenAI Responses backend API. This means you can run the backend and also use the OpenAI client sdk to connect to it. Use **agent/workflow name as the entity_id in metadata**, and set streaming to `True` as needed.
169
+
170
+ ```bash
171
+ # Simple - use your entity name as the entity_id in metadata
172
+ curl -X POST http://localhost:8080/v1/responses \
173
+ -H "Content-Type: application/json" \
174
+ -d @- << 'EOF'
175
+ {
176
+ "metadata": {"entity_id": "weather_agent"},
177
+ "input": "Hello world"
178
+ }
179
+ ```
180
+
181
+ Or use the OpenAI Python SDK:
182
+
183
+ ```python
184
+ from openai import OpenAI
185
+
186
+ client = OpenAI(
187
+ base_url="http://localhost:8080/v1",
188
+ api_key="not-needed" # API key not required for local DevUI
189
+ )
190
+
191
+ response = client.responses.create(
192
+ metadata={"entity_id": "weather_agent"}, # Your agent/workflow name
193
+ input="What's the weather in Seattle?"
194
+ )
195
+
196
+ # Extract text from response
197
+ print(response.output[0].content[0].text)
198
+ # Supports streaming with stream=True
199
+ ```
200
+
201
+ ### Multi-turn Conversations
202
+
203
+ Use the standard OpenAI `conversation` parameter for multi-turn conversations:
204
+
205
+ ```python
206
+ # Create a conversation
207
+ conversation = client.conversations.create(
208
+ metadata={"agent_id": "weather_agent"}
209
+ )
210
+
211
+ # Use it across multiple turns
212
+ response1 = client.responses.create(
213
+ metadata={"entity_id": "weather_agent"},
214
+ input="What's the weather in Seattle?",
215
+ conversation=conversation.id
216
+ )
217
+
218
+ response2 = client.responses.create(
219
+ metadata={"entity_id": "weather_agent"},
220
+ input="How about tomorrow?",
221
+ conversation=conversation.id # Continues the conversation!
222
+ )
223
+ ```
224
+
225
+ **How it works:** DevUI automatically retrieves the conversation's message history from the stored thread and passes it to the agent. You don't need to manually manage message history - just provide the same `conversation` ID for follow-up requests.
226
+
227
+ ### OpenAI Proxy Mode
228
+
229
+ DevUI provides an **OpenAI Proxy** feature for testing OpenAI models directly through the interface without creating custom agents. Enable via Settings → OpenAI Proxy tab.
230
+
231
+ **How it works:** The UI sends requests to the DevUI backend (with `X-Proxy-Backend: openai` header), which then proxies them to OpenAI's Responses API (and Conversations API for multi-turn chats). This proxy approach keeps your `OPENAI_API_KEY` secure on the server—never exposed in the browser or client-side code.
232
+
233
+ **Example:**
234
+
235
+ ```bash
236
+ curl -X POST http://localhost:8080/v1/responses \
237
+ -H "X-Proxy-Backend: openai" \
238
+ -d '{"model": "gpt-4.1-mini", "input": "Hello"}'
239
+ ```
240
+
241
+ **Note:** Requires `OPENAI_API_KEY` environment variable configured on the backend.
242
+
243
+ ## CLI Options
244
+
245
+ ```bash
246
+ devui [directory] [options]
247
+
248
+ Options:
249
+ --port, -p Port (default: 8080)
250
+ --host Host (default: 127.0.0.1)
251
+ --headless API only, no UI
252
+ --no-open Don't automatically open browser
253
+ --instrumentation Enable OpenTelemetry instrumentation
254
+ --reload Enable auto-reload
255
+ --mode developer|user (default: developer)
256
+ --auth Enable Bearer token authentication
257
+ --auth-token Custom authentication token
258
+ ```
259
+
260
+ ### UI Modes
261
+
262
+ - **developer** (default): Full access - debug panel, entity details, hot reload, deployment
263
+ - **user**: Simplified UI with restricted APIs - only chat and conversation management
264
+
265
+ ```bash
266
+ # Development
267
+ devui ./agents
268
+
269
+ # Production (user-facing)
270
+ devui ./agents --mode user --auth
271
+ ```
272
+
273
+ ## Key Endpoints
274
+
275
+ ## API Mapping
276
+
277
+ Given that DevUI offers an OpenAI Responses API, it internally maps messages and events from Agent Framework to OpenAI Responses API events (in `_mapper.py`). For transparency, this mapping is shown below:
278
+
279
+ | OpenAI Event/Type | Agent Framework Content | Status |
280
+ | ------------------------------------------------------------ | --------------------------------- | -------- |
281
+ | | **Lifecycle Events** | |
282
+ | `response.created` + `response.in_progress` | `AgentStartedEvent` | OpenAI |
283
+ | `response.completed` | `AgentCompletedEvent` | OpenAI |
284
+ | `response.failed` | `AgentFailedEvent` | OpenAI |
285
+ | `response.created` + `response.in_progress` | `WorkflowStartedEvent` | OpenAI |
286
+ | `response.completed` | `WorkflowCompletedEvent` | OpenAI |
287
+ | `response.failed` | `WorkflowFailedEvent` | OpenAI |
288
+ | | **Content Types** | |
289
+ | `response.content_part.added` + `response.output_text.delta` | `TextContent` | OpenAI |
290
+ | `response.reasoning_text.delta` | `TextReasoningContent` | OpenAI |
291
+ | `response.output_item.added` | `FunctionCallContent` (initial) | OpenAI |
292
+ | `response.function_call_arguments.delta` | `FunctionCallContent` (args) | OpenAI |
293
+ | `response.function_result.complete` | `FunctionResultContent` | DevUI |
294
+ | `response.function_approval.requested` | `FunctionApprovalRequestContent` | DevUI |
295
+ | `response.function_approval.responded` | `FunctionApprovalResponseContent` | DevUI |
296
+ | `response.output_item.added` (ResponseOutputImage) | `DataContent` (images) | DevUI |
297
+ | `response.output_item.added` (ResponseOutputFile) | `DataContent` (files) | DevUI |
298
+ | `response.output_item.added` (ResponseOutputData) | `DataContent` (other) | DevUI |
299
+ | `response.output_item.added` (ResponseOutputImage/File) | `UriContent` (images/files) | DevUI |
300
+ | `error` | `ErrorContent` | OpenAI |
301
+ | Final `Response.usage` field (not streamed) | `UsageContent` | OpenAI |
302
+ | | **Workflow Events** | |
303
+ | `response.output_item.added` (ExecutorActionItem)* | `ExecutorInvokedEvent` | OpenAI |
304
+ | `response.output_item.done` (ExecutorActionItem)* | `ExecutorCompletedEvent` | OpenAI |
305
+ | `response.output_item.done` (ExecutorActionItem with error)* | `ExecutorFailedEvent` | OpenAI |
306
+ | `response.output_item.added` (ResponseOutputMessage) | `WorkflowOutputEvent` | OpenAI |
307
+ | `response.workflow_event.complete` | `WorkflowEvent` (other) | DevUI |
308
+ | `response.trace.complete` | `WorkflowStatusEvent` | DevUI |
309
+ | `response.trace.complete` | `WorkflowWarningEvent` | DevUI |
310
+ | | **Trace Content** | |
311
+ | `response.trace.complete` | `DataContent` (no data/errors) | DevUI |
312
+ | `response.trace.complete` | `UriContent` (unsupported MIME) | DevUI |
313
+ | `response.trace.complete` | `HostedFileContent` | DevUI |
314
+ | `response.trace.complete` | `HostedVectorStoreContent` | DevUI |
315
+
316
+ \*Uses standard OpenAI event structure but carries DevUI-specific `ExecutorActionItem` payload
317
+
318
+ - **OpenAI** = Standard OpenAI Responses API event types
319
+ - **DevUI** = Custom event types specific to Agent Framework (e.g., workflows, traces, function approvals)
320
+
321
+ ### OpenAI Responses API Compliance
322
+
323
+ DevUI follows the OpenAI Responses API specification for maximum compatibility:
324
+
325
+ **OpenAI Standard Event Types Used:**
326
+
327
+ - `ResponseOutputItemAddedEvent` - Output item notifications (function calls, images, files, data)
328
+ - `ResponseOutputItemDoneEvent` - Output item completion notifications
329
+ - `Response.usage` - Token usage (in final response, not streamed)
330
+
331
+ **Custom DevUI Extensions:**
332
+
333
+ - `response.output_item.added` with custom item types:
334
+ - `ResponseOutputImage` - Agent-generated images (inline display)
335
+ - `ResponseOutputFile` - Agent-generated files (inline display)
336
+ - `ResponseOutputData` - Agent-generated structured data (inline display)
337
+ - `response.function_approval.requested` - Function approval requests (for interactive approval workflows)
338
+ - `response.function_approval.responded` - Function approval responses (user approval/rejection)
339
+ - `response.function_result.complete` - Server-side function execution results
340
+ - `response.workflow_event.complete` - Agent Framework workflow events
341
+ - `response.trace.complete` - Execution traces and internal content (DataContent, UriContent, hosted files/stores)
342
+
343
+ These custom extensions are clearly namespaced and can be safely ignored by standard OpenAI clients. Note that DevUI also uses standard OpenAI events with custom payloads (e.g., `ExecutorActionItem` within `response.output_item.added`).
344
+
345
+ ### Entity Management
346
+
347
+ - `GET /v1/entities` - List discovered agents/workflows
348
+ - `GET /v1/entities/{entity_id}/info` - Get detailed entity information
349
+ - `POST /v1/entities/{entity_id}/reload` - Hot reload entity (for development)
350
+
351
+ ### Execution (OpenAI Responses API)
352
+
353
+ - `POST /v1/responses` - Execute agent/workflow (streaming or sync)
354
+
355
+ ### Conversations (OpenAI Standard)
356
+
357
+ - `POST /v1/conversations` - Create conversation
358
+ - `GET /v1/conversations/{id}` - Get conversation
359
+ - `POST /v1/conversations/{id}` - Update conversation metadata
360
+ - `DELETE /v1/conversations/{id}` - Delete conversation
361
+ - `GET /v1/conversations?agent_id={id}` - List conversations _(DevUI extension)_
362
+ - `POST /v1/conversations/{id}/items` - Add items to conversation
363
+ - `GET /v1/conversations/{id}/items` - List conversation items
364
+ - `GET /v1/conversations/{id}/items/{item_id}` - Get conversation item
365
+
366
+ ### Health
367
+
368
+ - `GET /health` - Health check
369
+
370
+ ## Security
371
+
372
+ DevUI is designed as a **sample application for local development** and should not be exposed to untrusted networks without proper authentication.
373
+
374
+ **For production deployments:**
375
+
376
+ ```bash
377
+ # User mode with authentication (recommended)
378
+ devui ./agents --mode user --auth --host 0.0.0.0
379
+ ```
380
+
381
+ This restricts developer APIs (reload, deployment, entity details) and requires Bearer token authentication.
382
+
383
+ **Security features:**
384
+
385
+ - User mode restricts developer-facing APIs
386
+ - Optional Bearer token authentication via `--auth`
387
+ - Only loads entities from local directories or in-memory registration
388
+ - No remote code execution capabilities
389
+ - Binds to localhost (127.0.0.1) by default
390
+
391
+ **Best practices:**
392
+
393
+ - Use `--mode user --auth` for any deployment exposed to end users
394
+ - Review all agent/workflow code before running
395
+ - Only load entities from trusted sources
396
+ - Use `.env` files for sensitive credentials (never commit them)
397
+
398
+ ## Implementation
399
+
400
+ - **Discovery**: `agent_framework_devui/_discovery.py`
401
+ - **Execution**: `agent_framework_devui/_executor.py`
402
+ - **Message Mapping**: `agent_framework_devui/_mapper.py`
403
+ - **Conversations**: `agent_framework_devui/_conversations.py`
404
+ - **API Server**: `agent_framework_devui/_server.py`
405
+ - **CLI**: `agent_framework_devui/_cli.py`
406
+
407
+ ## Examples
408
+
409
+ See working implementations in `python/samples/getting_started/devui/`
410
+
411
+ ## License
412
+
413
+ MIT
414
+