Skip to content

feature (sandbox): add configurable Nginx timeouts and improve startup reliability#411

Merged
AgentScopeTeam merged 8 commits intoagentscope-ai:mainfrom
rayrayraykk:dev/0121/opt_dockerfile
Jan 22, 2026
Merged

feature (sandbox): add configurable Nginx timeouts and improve startup reliability#411
AgentScopeTeam merged 8 commits intoagentscope-ai:mainfrom
rayrayraykk:dev/0121/opt_dockerfile

Conversation

@rayrayraykk
Copy link
Copy Markdown
Member

Description

This PR improves sandbox image startup and configurability.

Changes

  • Add default env vars in sandbox Dockerfiles and include them in envsubst:
    • SECRET_TOKEN (default: secret_token_123)
    • NGINX_TIMEOUT (default: 60)
  • Add Nginx proxy timeouts using ${NGINX_TIMEOUT} in Nginx config/templates.
  • Make GUI/custom sandbox supervisord services more robust by cleaning stale pid/lock files and waiting for X/VNC readiness; pass SECRET_TOKEN via supervisord env.
  • Inject NGINX_TIMEOUT when creating sandboxes in sandbox_manager.py.

Result

More reliable sandbox startup and configurable Nginx timeouts.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactoring

Component(s) Affected

  • Engine
  • Sandbox
  • Tools
  • Common
  • Documentation
  • Tests
  • CI/CD

Checklist

  • Pre-commit hooks pass
  • Tests pass locally
  • Documentation updated (if needed)
  • Ready for review

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 enhances sandbox reliability and configurability by adding support for configurable Nginx proxy timeouts and implementing robust startup procedures for GUI-based sandboxes.

Changes:

  • Added NGINX_TIMEOUT environment variable support (default: 60 seconds) for configurable Nginx proxy timeouts across all sandbox types
  • Implemented robust startup procedures in GUI and custom sandboxes by cleaning stale pid/lock files and waiting for X server/VNC readiness before starting dependent services
  • Updated all Dockerfiles to export and substitute both SECRET_TOKEN and NGINX_TIMEOUT environment variables with fallback defaults

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/agentscope_runtime/sandbox/manager/sandbox_manager.py Injects NGINX_TIMEOUT environment variable when creating sandbox containers
src/agentscope_runtime/sandbox/box/mobile/box/config/nginx.conf Adds proxy timeout directives using ${NGINX_TIMEOUT} placeholder (has critical bug - no envsubst)
src/agentscope_runtime/sandbox/box/gui/box/config/supervisord.conf Improves service startup with stale file cleanup and X server readiness checks
src/agentscope_runtime/sandbox/box/gui/box/config/nginx.conf.template Adds proxy timeout directives at http level for global coverage
src/agentscope_runtime/sandbox/box/gui/Dockerfile Exports and substitutes environment variables for runtime configuration
src/agentscope_runtime/sandbox/box/filesystem/Dockerfile Exports and substitutes environment variables for runtime configuration
src/agentscope_runtime/sandbox/box/browser/Dockerfile Exports and substitutes environment variables for runtime configuration
src/agentscope_runtime/sandbox/box/base/box/config/nginx.conf.template Adds proxy timeout directives at location level (inconsistent with other sandboxes)
src/agentscope_runtime/sandbox/box/base/Dockerfile Exports and substitutes environment variables for runtime configuration
examples/sandbox/custom_sandbox/box/config/supervisord.conf Improves service startup with stale file cleanup and X server readiness checks
examples/sandbox/custom_sandbox/box/config/nginx.conf.template Adds proxy timeout directives at http level for global coverage
examples/sandbox/custom_sandbox/Dockerfile Exports and substitutes environment variables for runtime configuration
cookbook/zh/sandbox/advanced.md Updates documentation example to reflect new CMD pattern
cookbook/en/sandbox/advanced.md Updates documentation example to reflect new CMD pattern

Comment thread src/agentscope_runtime/sandbox/box/base/box/config/nginx.conf.template Outdated
Comment thread src/agentscope_runtime/sandbox/box/gui/Dockerfile Outdated
Comment thread src/agentscope_runtime/sandbox/box/filesystem/Dockerfile Outdated
Comment thread src/agentscope_runtime/sandbox/box/browser/Dockerfile Outdated
Comment thread src/agentscope_runtime/sandbox/box/base/Dockerfile Outdated
Comment thread examples/sandbox/custom_sandbox/Dockerfile Outdated
@rayrayraykk
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces configurable Nginx timeouts and significantly improves the startup reliability of sandbox services. The changes are well-structured, particularly the enhancements to supervisord.conf which replace fixed sleep calls with more robust readiness checks. I've provided a few suggestions to further improve maintainability and correctness. One suggestion is to move long CMD commands in Dockerfiles to separate startup scripts for better readability. Another is to remove an unnecessary flag in a bash command. Finally, I've pointed out a missing default value for an environment variable in the mobile sandbox's startup script, which could lead to configuration errors. Overall, this is a great set of improvements.

Comment thread src/agentscope_runtime/sandbox/box/mobile/box/scripts/start.sh
Comment thread cookbook/en/sandbox/advanced.md Outdated
Comment thread cookbook/zh/sandbox/advanced.md Outdated
Comment thread examples/sandbox/custom_sandbox/Dockerfile Outdated
Comment thread examples/sandbox/custom_sandbox/box/config/supervisord.conf
Comment thread src/agentscope_runtime/sandbox/box/base/Dockerfile Outdated
Comment thread src/agentscope_runtime/sandbox/box/browser/Dockerfile Outdated
Comment thread src/agentscope_runtime/sandbox/box/filesystem/Dockerfile Outdated
Comment thread src/agentscope_runtime/sandbox/box/gui/Dockerfile Outdated
Comment thread src/agentscope_runtime/sandbox/box/gui/box/config/supervisord.conf
Copilot AI review requested due to automatic review settings January 22, 2026 03:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Comment thread src/agentscope_runtime/sandbox/box/mobile/box/scripts/start.sh
Comment thread src/agentscope_runtime/sandbox/box/gui/box/config/supervisord.conf
Comment thread examples/sandbox/custom_sandbox/box/config/supervisord.conf
@AgentScopeTeam AgentScopeTeam merged commit 160f69e into agentscope-ai:main Jan 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants