DevUI for Microsoft Agent Framework
agent-framework-devui is a lightweight, standalone sample application providing a debug UI for the Microsoft Agent Framework. It offers an OpenAI-compatible API server for running and testing AI agents and workflows, supporting directory-based discovery, in-memory entity registration, and a gallery of sample entities. It also includes an OpenAI Proxy feature, enabling direct testing of OpenAI models via the interface while keeping API keys secure on the server. Primarily designed as an 'inner-loop' developer tool, it visualizes agent execution, including reasoning, actions, and observations.
Common errors
-
ModuleNotFoundError: No module named 'agent_framework'
cause The 'agent_framework' package is not installed in the current Python environment.fixInstall the package using pip: 'pip install agent-framework'. -
ImportError: cannot import name 'DevServer' from 'agent_framework.devui'
cause The 'DevServer' class is not available in the 'agent_framework.devui' module, possibly due to version incompatibility or incorrect import.fixEnsure you are using the correct version of 'agent-framework-devui' and check the module's documentation for the correct import statement. -
AttributeError: module 'agent_framework' has no attribute 'serve'
cause The 'serve' function is not defined in the 'agent_framework' module, possibly due to incorrect usage or version mismatch.fixVerify the module's documentation for the correct usage of the 'serve' function and ensure compatibility with your version. -
TypeError: serve() got an unexpected keyword argument 'entities_dir'
cause The 'serve' function does not accept 'entities_dir' as a keyword argument, indicating a possible API change or incorrect usage.fixReview the function's signature in the module's documentation and update your code accordingly. -
ValueError: No entities found in the specified directory
cause The specified directory does not contain any valid agents or workflows for discovery.fixEnsure the directory structure follows the required format with '__init__.py' files exporting 'agent' or 'workflow' variables as per the documentation.
Warnings
- breaking The Microsoft Agent Framework, including DevUI, is currently in a development/preview stage. APIs and features are subject to frequent changes, and building from source is sometimes recommended over pre-release packages to ensure the latest updates.
- gotcha DevUI is explicitly stated as a 'sample app' and 'not intended for production use.' Its primary purpose is for local development, testing, and debugging of agents and workflows within the Agent Framework, rather than deployment.
- gotcha When using DevUI's OpenAI Proxy feature or agents that interact with OpenAI-compatible clients (like `OpenAIChatClient`), an `OPENAI_API_KEY` (or a `GITHUB_TOKEN` for GitHub Models) must be configured as an environment variable on the backend for proper authentication.
- gotcha A specific architectural consideration for developers is to avoid using `async with` context managers when creating agents with Model Context Protocol (MCP) tools for DevUI.
- gotcha Due to its pre-release status, installation of `agent-framework-devui` typically requires the `--pre` flag with pip (e.g., `pip install agent-framework-devui --pre`) to access the latest beta versions.
Install
-
pip install agent-framework-devui --pre
Imports
- serve
from agent_framework.devui import serve
- Agent
from agent_framework import Agent
- OpenAIChatClient
from agent_framework.openai import OpenAIChatClient
Quickstart
import os
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient
from agent_framework.devui import serve
# NOTE: Set OPENAI_API_KEY environment variable for actual API calls
# Example for a simple tool
def get_weather(location: str) -> str:
"""Get weather for a location."""
return f"Weather in {location}: 72°F and sunny"
# Create your agent
agent = Agent(
name="WeatherAgent",
client=OpenAIChatClient(api_key=os.environ.get('OPENAI_API_KEY', '')) if os.environ.get('OPENAI_API_KEY') else None, # Pass API key if available
tools=[get_weather]
)
# Launch debug UI - this opens a browser to http://localhost:8080
print("Launching DevUI... access at http://localhost:8080")
serve(entities=[agent], auto_open=True)