-
Notifications
You must be signed in to change notification settings - Fork 78
Support lanuch webui by agentapp.run(web_ui=True)
#233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support lanuch webui by agentapp.run(web_ui=True)
#233
Conversation
agentapp.run(web_ui=True)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for launching a browser-based WebUI alongside the AgentApp HTTP API server. When the new web_ui=True parameter is passed to the run() method, the application spawns a separate Node.js-based WebUI process using npx @agentscope-ai/chat.
Key Changes:
- Added
web_uiparameter to therun()method to optionally launch the WebUI - Integrated subprocess management to start the WebUI alongside the FastAPI server
- Enhanced documentation with detailed parameter descriptions and usage notes
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "[AgentApp] Note: First WebUI launch may take extra time " | ||
| "as dependencies are installed.", | ||
| ) | ||
| with subprocess.Popen(shlex.split(cmd)): |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no error handling for the WebUI subprocess startup. If npx is not installed or the WebUI package fails to start, the subprocess will fail silently and only the uvicorn server will run. Consider checking if the subprocess starts successfully before proceeding with uvicorn.run(), or at least logging any subprocess errors.
| with subprocess.Popen(shlex.split(cmd)): | |
| try: | |
| webui_proc = subprocess.Popen(shlex.split(cmd)) | |
| except Exception as e: | |
| logger.error(f"[AgentApp] Failed to start WebUI subprocess: {e}") | |
| else: | |
| # Optionally, wait a short time and check if process exited | |
| import time | |
| time.sleep(2) | |
| if webui_proc.poll() is not None: | |
| logger.error(f"[AgentApp] WebUI subprocess exited early with code {webui_proc.returncode}") |
| self, | ||
| host="0.0.0.0", | ||
| port=8090, | ||
| web_ui=False, |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new web_ui parameter lacks test coverage. The existing tests in tests/integrated/test_agent_app.py only test the basic run() method without the web_ui=True option. Consider adding test coverage for the WebUI launch functionality, including:
- Testing that the WebUI subprocess starts when
web_ui=True - Testing cleanup of the WebUI subprocess on shutdown
- Testing error handling when npx is not available
Usage: