Skip to content

Conversation

@zzhangpurdue
Copy link
Collaborator

@zzhangpurdue zzhangpurdue commented Dec 9, 2025

Description

  1. add cli system
  2. pass test for run/web from project+entrypoint, project, entrypoint file
  3. pass test for k8s/modelstudio/local deploy method by both cli and interface
  4. pass test for k8s/local stop method, modelstudio has no stop logic yet, will be add soon
  5. update temp file location and naming, all builds are sorted by platform-time, and store at user workspace/.agentscope_runtime, user could easily review/test and delete
  6. add deploy state manager for deploy info management.
  7. run by deploy id
  8. lint
  9. ut
  10. docs

Todo:

  1. pass test for agentrun deploy and stop by cli

Run an agent in interactive way with multi-turn

as-runtime run examples/deployments/detached_local_deploy/app_agent.py

Run an agent in simple reply

as-runtime run examples/deployments/detached_local_deploy/app_agent.py --query

Run an agent with webui

as-runtime web examples/deployments/detached_local_deploy/app_agent.py

Deployment

modelstudio

export USE_LOCAL_RUNTIME=True && as-runtime deploy modelstudio examples/deployments/detached_local_deploy/app_agent.py --name my-test6 --env DASHSCOPE_API_KEY=sk-xxx

k8s

# USE_LOCAL_RUNTIME will use local agentscope runtime instead of from pypi
export USE_LOCAL_RUNTIME=True && as-runtime deploy k8s examples/deployments/detached_local_deploy/app_agent.py --image-name agent_app --env DASHSCOPE_API_KEY=xxxx --image-tag linux-amd64-4 --registry-url yyy

local

as-runtime deploy local examples/deployments/detached_local_deploy/app_agent.py --env DASHSCOPE_API_KEY=sk-xxx

An URL will be print in the terminal, user could query the agent by this url,

curl -i -X POST "http:/127.0.0.1:8080/process" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer 8ddcc903-b75b-40b8-ba7f-1501e05cb3f2" \
  -d '{
    "input": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Hello, how are you?"
          }
        ]
      }
    ],
    "session_id": "123"
  }'

or call run cli

as-runtime run  [DEPLOYMENT_ID]

A deployment id will be print in the terminal, then use it to stop

as-runtime stop [DEPLOYMENT_ID]

Related Issue: Fixes #[issue_number] or Relates to #[issue_number]

Security Considerations: [If applicable, especially for sandbox changes]

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

Testing

[How to test these changes]

Additional Notes

[Optional: any other context]

Copilot AI review requested due to automatic review settings December 9, 2025 02:35
@cla-assistant
Copy link

cla-assistant bot commented Dec 9, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Zhicheng Zhang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant
Copy link

cla-assistant bot commented Dec 9, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Zhicheng Zhang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
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 introduces a comprehensive CLI system for AgentScope Runtime, adding a unified as-runtime command-line interface that consolidates agent development, deployment, and runtime operations. The PR includes build caching for faster deployments, enhanced deployment management across multiple platforms (local, k8s, modelstudio, agentrun), and improved temporary file organization.

Key Changes:

  • New unified CLI system with commands: run, web, deploy, stop, list, status, invoke, sandbox
  • Build cache implementation with content-aware hashing for faster repeated deployments
  • Enhanced deployer interfaces with standardized stop() methods across all platforms

Reviewed changes

Copilot reviewed 46 out of 47 changed files in this pull request and generated 28 comments.

Show a summary per file
File Description
src/agentscope_runtime/cli/ New CLI module with command implementations, agent loaders, state management, and utilities
src/agentscope_runtime/engine/deployers/utils/build_cache.py Build cache system with content hashing and workspace management
src/agentscope_runtime/engine/deployers/ Updated deployers with stop() method, build directory improvements, and entrypoint support
src/agentscope_runtime/engine/deployers/utils/docker_image_utils/ Enhanced Docker image building with platform support and wheel merging
src/agentscope_runtime/engine/deployers/utils/k8s_utils.py K8s environment detection for local vs cloud clusters
tests/deploy/test_build_cache.py Comprehensive test suite for build cache functionality
pyproject.toml Added click dependency and as-runtime console script
examples/deployments/ Example configuration files for various deployment platforms
cookbook/en/cli/README.md CLI documentation and usage guide

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zzhangpurdue zzhangpurdue changed the title Feat/cli [WIP]Feat/cli Dec 9, 2025
@zzhangpurdue zzhangpurdue changed the title [WIP]Feat/cli Feat/cli Dec 10, 2025
@rayrayraykk rayrayraykk self-requested a review December 10, 2025 10:22
runtime-sandbox-mcp = "agentscope_runtime.sandbox.mcp_server:main"
runtime-sandbox-server = "agentscope_runtime.sandbox.manager.server.app:main"
runtime-sandbox-builder = "agentscope_runtime.sandbox.build:main"
runtime-fc-deploy = "agentscope_runtime.engine.deployers.cli_fc_deploy:main"
Copy link
Member

Choose a reason for hiding this comment

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

Could we remove agentscope-runtime-fc-deploy and integrate to as-runtime / main cli?

build-backend = "setuptools.build_meta"

[project.scripts]
as-runtime = "agentscope_runtime.cli.cli:main"
Copy link
Member

Choose a reason for hiding this comment

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

Instead of maintaining multiple long CLI entry points (runtime-sandbox-mcp, runtime-sandbox-server, runtime-fc-deploy, etc.), we could unify them into a single agentscope-runtime CLI and route to the specific functionalities via subcommands or arguments.
This would reduce duplication in pyproject.toml, make the commands easier to remember, and keep naming consistent.
For example:

agentscope-runtime sandbox mcp
agentscope-runtime sandbox server
agentscope-runtime sandbox build
agentscope-runtime fc-deploy
agentscope-runtime modelstudio mcp-server

from ..adapters.agentscope.message import message_to_agentscope_msg
from agentscope import setup_logger

setup_logger("ERROR")
Copy link
Member

Choose a reason for hiding this comment

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

Maybe move to adapters stream.py


@click.command()
@click.argument("source", required=True)
@click.option(
Copy link
Member

Choose a reason for hiding this comment

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

The default argument is mismatched with agent_app.run (0.0.0.0)

help="Host address to bind to",
default="127.0.0.1",
)
@click.option(
Copy link
Member

Choose a reason for hiding this comment

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

The default argument is mismatched with agent_app.run (8080)

@@ -0,0 +1,120 @@
# -*- coding: utf-8 -*-
Copy link
Member

Choose a reason for hiding this comment

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

I’d strongly recommend leveraging Rich for output formatting instead of plain click.secho / ASCII tables:

Suggested improvements:

  1. Centralize style config – avoid repeating emoji/color logic in each echo_* function. Define a STYLES dict and reuse.
  2. Upgrade table rendering – replace manual ASCII table (format_table) with rich.table.Table for better alignment (handles wide chars) and richer visuals.
  3. Improve JSON display – use rich.json.JSON or console.print_json() to give syntax‑highlighted JSON instead of plain json.dumps.
  4. Consistent layout componentsrich.panel.Panel or Columns can make headers and grouped output more readable.
  5. Windows compatibility – Rich automatically handles ANSI colors on Windows, eliminating need for manual Click color handling.

These changes will make CLI output visually appealing, more readable, and more consistent across platforms, while keeping Click for argument parsing.

@@ -0,0 +1,786 @@
# -*- coding: utf-8 -*-
Copy link
Member

Choose a reason for hiding this comment

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

How about rename to chat?

"'main.py')",
default=None,
)
def run(
Copy link
Member

Choose a reason for hiding this comment

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

Looks like interruption does not works in my IDE (pycharm)...

Image

Copy link
Member

Choose a reason for hiding this comment

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

Maybe try signal.signal(signal.SIGINT, handle_sigint) ?

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.

2 participants