类class
agentscope.workspaceK8sWorkspace
class K8sWorkspace(SandboxedWorkspaceBase)
源码Source
agentscope/workspace/_k8s/_k8s_workspace.py:55–620K 8 s 工作区,在隔离环境中安全执行代码和工具。位于 agentscope.workspace 包,继承自 SandboxedWorkspaceBase。核心成员包括 get_instructions。
default_mcps and skill_paths are seed-time inputs and are
not retained as instance state past :meth:initialize.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(*, workspace_id: str | None = None, kubeconfig: str | None = None, namespace: str = 'agentscope', image: s… | 初始化 `K8sWorkspace` 实例。 Construct a :class:`K8sWorkspace`. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def get_instructions() -> strasync | 获取指令。 Return the system-prompt fragment for this workspace. |
构造器详情Constructor Detail
K8sWorkspace
def __init__(*, workspace_id: str | None = None, kubeconfig: str | None = None, namespace: str = 'agentscope', image: str = DEFAULT_IMAGE, image_pull_policy: str = 'IfNotPresent', image_pull_secrets: list[str] | None = None, resources: dict[str, Any] | None = None, node_selector: dict[str, str] | None = None, tolerations: list[dict[str, Any]] | None = None, service_account: str | None = None, gateway_port: int = DEFAULT_GATEWAY_PORT, extra_pip: list[str] | None = None, storage_class: str | None = None, storage_size: str = '1Gi', delete_pvc_on_close: bool = False, env: dict[str, str] | None = None, instructions: str = DEFAULT_WORKSPACE_INSTRUCTIONS, default_mcps: list[MCPClient] | None = None, skill_paths: list[str] | None = None) -> None
初始化 K8sWorkspace 实例。
The Pod is not started here; call :meth:initialize (or use the workspace as an async context manager).
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspace_idkw默认default None | str | None | 工作区标识(类型 `str | None`)。Stable identifier. `None` generates a fresh UUID. |
kubeconfigkw默认default None | str | None | kubeconfig(类型 `str | None`)。Path to kubeconfig file. `None` uses in-cluster config. |
namespacekw默认default 'agentscope' | str | 命名空间(类型 `str`)。K8s namespace for the Pod and PVC. |
imagekw默认default DEFAULT_IMAGE | str | 图像(类型 `str`)。Container image. |
image_pull_policykw默认default 'IfNotPresent' | str | 图像 pull 策略(类型 `str`)。K8s imagePullPolicy. |
image_pull_secretskw默认default None | list[str] | None | 图像 pull secrets(类型 `list[str] | None`)。Names of K8s image pull secrets. |
resourceskw默认default None | dict[str, Any] | None | resources(类型 `dict[str, Any] | None`)。K8s ResourceRequirements dict. |
node_selectorkw默认default None | dict[str, str] | None | 节点 selector(类型 `dict[str, str] | None`)。K8s nodeSelector. |
tolerationskw默认default None | list[dict[str, Any]] | None | tolerations(类型 `list[dict[str, Any]] | None`)。K8s tolerations list. |
service_accountkw默认default None | str | None | 服务 account(类型 `str | None`)。K8s serviceAccountName. |
gateway_portkw默认default DEFAULT_GATEWAY_PORT | int | 网关 port(类型 `int`)。Port the gateway listens on inside the Pod. |
extra_pipkw默认default None | list[str] | None | extra pip(类型 `list[str] | None`)。Extra packages for the gateway venv. |
storage_classkw默认default None | str | None | 存储类(类型 `str | None`)。K8s StorageClass name. `None` uses cluster default. |
storage_sizekw默认default '1Gi' | str | 存储大小(类型 `str`)。PVC size. |
delete_pvc_on_closekw默认default False | bool | 删除 pvc on 关闭(类型 `bool`)。When `True`, :meth:`close` also deletes the PVC. |
envkw默认default None | dict[str, str] | None | env(类型 `dict[str, str] | None`)。Environment variables for the container. |
instructionskw默认default DEFAULT_WORKSPACE_INSTRUCTIONS | str | 指令(类型 `str`)。System-prompt fragment template. |
default_mcpskw默认default None | list[MCPClient] | None | 默认 mcps(类型 `list[MCPClient] | None`)。MCPs seeded on first init. |
skill_pathskw默认default None | list[str] | None | 技能 paths(类型 `list[str] | None`)。Skill directories seeded on first init. |
源码Source
agentscope/workspace/_k8s/_k8s_workspace.py:64–170方法详情Method Detail
get_instructions
async def get_instructions() -> str
async
获取指令。
Return the system-prompt fragment for this workspace.
str
返回字符串结果。Returns a string.
源码Source
agentscope/workspace/_k8s/_k8s_workspace.py:242–244