agentscope-runtime 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. agentscope_runtime/__init__.py +4 -0
  2. agentscope_runtime/engine/__init__.py +9 -0
  3. agentscope_runtime/engine/agents/__init__.py +2 -0
  4. agentscope_runtime/engine/agents/agentscope_agent/__init__.py +6 -0
  5. agentscope_runtime/engine/agents/agentscope_agent/agent.py +342 -0
  6. agentscope_runtime/engine/agents/agentscope_agent/hooks.py +156 -0
  7. agentscope_runtime/engine/agents/agno_agent.py +220 -0
  8. agentscope_runtime/engine/agents/base_agent.py +29 -0
  9. agentscope_runtime/engine/agents/langgraph_agent.py +59 -0
  10. agentscope_runtime/engine/agents/llm_agent.py +51 -0
  11. agentscope_runtime/engine/deployers/__init__.py +3 -0
  12. agentscope_runtime/engine/deployers/adapter/__init__.py +0 -0
  13. agentscope_runtime/engine/deployers/adapter/a2a/__init__.py +2 -0
  14. agentscope_runtime/engine/deployers/adapter/a2a/a2a_adapter_utils.py +425 -0
  15. agentscope_runtime/engine/deployers/adapter/a2a/a2a_agent_adapter.py +69 -0
  16. agentscope_runtime/engine/deployers/adapter/a2a/a2a_protocol_adapter.py +60 -0
  17. agentscope_runtime/engine/deployers/adapter/protocol_adapter.py +24 -0
  18. agentscope_runtime/engine/deployers/base.py +17 -0
  19. agentscope_runtime/engine/deployers/local_deployer.py +586 -0
  20. agentscope_runtime/engine/helpers/helper.py +127 -0
  21. agentscope_runtime/engine/llms/__init__.py +3 -0
  22. agentscope_runtime/engine/llms/base_llm.py +60 -0
  23. agentscope_runtime/engine/llms/qwen_llm.py +47 -0
  24. agentscope_runtime/engine/misc/__init__.py +0 -0
  25. agentscope_runtime/engine/runner.py +186 -0
  26. agentscope_runtime/engine/schemas/__init__.py +0 -0
  27. agentscope_runtime/engine/schemas/agent_schemas.py +551 -0
  28. agentscope_runtime/engine/schemas/context.py +54 -0
  29. agentscope_runtime/engine/services/__init__.py +9 -0
  30. agentscope_runtime/engine/services/base.py +77 -0
  31. agentscope_runtime/engine/services/context_manager.py +129 -0
  32. agentscope_runtime/engine/services/environment_manager.py +50 -0
  33. agentscope_runtime/engine/services/manager.py +174 -0
  34. agentscope_runtime/engine/services/memory_service.py +270 -0
  35. agentscope_runtime/engine/services/sandbox_service.py +198 -0
  36. agentscope_runtime/engine/services/session_history_service.py +256 -0
  37. agentscope_runtime/engine/tracing/__init__.py +40 -0
  38. agentscope_runtime/engine/tracing/base.py +309 -0
  39. agentscope_runtime/engine/tracing/local_logging_handler.py +356 -0
  40. agentscope_runtime/engine/tracing/tracing_metric.py +69 -0
  41. agentscope_runtime/engine/tracing/wrapper.py +321 -0
  42. agentscope_runtime/sandbox/__init__.py +14 -0
  43. agentscope_runtime/sandbox/box/__init__.py +0 -0
  44. agentscope_runtime/sandbox/box/base/__init__.py +0 -0
  45. agentscope_runtime/sandbox/box/base/base_sandbox.py +37 -0
  46. agentscope_runtime/sandbox/box/base/box/__init__.py +0 -0
  47. agentscope_runtime/sandbox/box/browser/__init__.py +0 -0
  48. agentscope_runtime/sandbox/box/browser/box/__init__.py +0 -0
  49. agentscope_runtime/sandbox/box/browser/browser_sandbox.py +176 -0
  50. agentscope_runtime/sandbox/box/dummy/__init__.py +0 -0
  51. agentscope_runtime/sandbox/box/dummy/dummy_sandbox.py +26 -0
  52. agentscope_runtime/sandbox/box/filesystem/__init__.py +0 -0
  53. agentscope_runtime/sandbox/box/filesystem/box/__init__.py +0 -0
  54. agentscope_runtime/sandbox/box/filesystem/filesystem_sandbox.py +87 -0
  55. agentscope_runtime/sandbox/box/sandbox.py +115 -0
  56. agentscope_runtime/sandbox/box/shared/__init__.py +0 -0
  57. agentscope_runtime/sandbox/box/shared/app.py +44 -0
  58. agentscope_runtime/sandbox/box/shared/dependencies/__init__.py +5 -0
  59. agentscope_runtime/sandbox/box/shared/dependencies/deps.py +22 -0
  60. agentscope_runtime/sandbox/box/shared/routers/__init__.py +12 -0
  61. agentscope_runtime/sandbox/box/shared/routers/generic.py +173 -0
  62. agentscope_runtime/sandbox/box/shared/routers/mcp.py +207 -0
  63. agentscope_runtime/sandbox/box/shared/routers/mcp_utils.py +153 -0
  64. agentscope_runtime/sandbox/box/shared/routers/runtime_watcher.py +187 -0
  65. agentscope_runtime/sandbox/box/shared/routers/workspace.py +325 -0
  66. agentscope_runtime/sandbox/box/training_box/__init__.py +0 -0
  67. agentscope_runtime/sandbox/box/training_box/base.py +120 -0
  68. agentscope_runtime/sandbox/box/training_box/env_service.py +752 -0
  69. agentscope_runtime/sandbox/box/training_box/environments/__init__.py +0 -0
  70. agentscope_runtime/sandbox/box/training_box/environments/appworld/appworld_env.py +987 -0
  71. agentscope_runtime/sandbox/box/training_box/registry.py +54 -0
  72. agentscope_runtime/sandbox/box/training_box/src/trajectory.py +278 -0
  73. agentscope_runtime/sandbox/box/training_box/training_box.py +219 -0
  74. agentscope_runtime/sandbox/build.py +213 -0
  75. agentscope_runtime/sandbox/client/__init__.py +5 -0
  76. agentscope_runtime/sandbox/client/http_client.py +527 -0
  77. agentscope_runtime/sandbox/client/training_client.py +265 -0
  78. agentscope_runtime/sandbox/constant.py +5 -0
  79. agentscope_runtime/sandbox/custom/__init__.py +16 -0
  80. agentscope_runtime/sandbox/custom/custom_sandbox.py +40 -0
  81. agentscope_runtime/sandbox/custom/example.py +37 -0
  82. agentscope_runtime/sandbox/enums.py +68 -0
  83. agentscope_runtime/sandbox/manager/__init__.py +4 -0
  84. agentscope_runtime/sandbox/manager/collections/__init__.py +22 -0
  85. agentscope_runtime/sandbox/manager/collections/base_mapping.py +20 -0
  86. agentscope_runtime/sandbox/manager/collections/base_queue.py +25 -0
  87. agentscope_runtime/sandbox/manager/collections/base_set.py +25 -0
  88. agentscope_runtime/sandbox/manager/collections/in_memory_mapping.py +22 -0
  89. agentscope_runtime/sandbox/manager/collections/in_memory_queue.py +28 -0
  90. agentscope_runtime/sandbox/manager/collections/in_memory_set.py +27 -0
  91. agentscope_runtime/sandbox/manager/collections/redis_mapping.py +26 -0
  92. agentscope_runtime/sandbox/manager/collections/redis_queue.py +27 -0
  93. agentscope_runtime/sandbox/manager/collections/redis_set.py +23 -0
  94. agentscope_runtime/sandbox/manager/container_clients/__init__.py +8 -0
  95. agentscope_runtime/sandbox/manager/container_clients/base_client.py +39 -0
  96. agentscope_runtime/sandbox/manager/container_clients/docker_client.py +170 -0
  97. agentscope_runtime/sandbox/manager/sandbox_manager.py +694 -0
  98. agentscope_runtime/sandbox/manager/server/__init__.py +0 -0
  99. agentscope_runtime/sandbox/manager/server/app.py +194 -0
  100. agentscope_runtime/sandbox/manager/server/config.py +68 -0
  101. agentscope_runtime/sandbox/manager/server/models.py +17 -0
  102. agentscope_runtime/sandbox/manager/storage/__init__.py +10 -0
  103. agentscope_runtime/sandbox/manager/storage/data_storage.py +16 -0
  104. agentscope_runtime/sandbox/manager/storage/local_storage.py +44 -0
  105. agentscope_runtime/sandbox/manager/storage/oss_storage.py +89 -0
  106. agentscope_runtime/sandbox/manager/utils.py +78 -0
  107. agentscope_runtime/sandbox/mcp_server.py +192 -0
  108. agentscope_runtime/sandbox/model/__init__.py +12 -0
  109. agentscope_runtime/sandbox/model/api.py +16 -0
  110. agentscope_runtime/sandbox/model/container.py +72 -0
  111. agentscope_runtime/sandbox/model/manager_config.py +158 -0
  112. agentscope_runtime/sandbox/registry.py +129 -0
  113. agentscope_runtime/sandbox/tools/__init__.py +12 -0
  114. agentscope_runtime/sandbox/tools/base/__init__.py +8 -0
  115. agentscope_runtime/sandbox/tools/base/tool.py +52 -0
  116. agentscope_runtime/sandbox/tools/browser/__init__.py +57 -0
  117. agentscope_runtime/sandbox/tools/browser/tool.py +597 -0
  118. agentscope_runtime/sandbox/tools/filesystem/__init__.py +32 -0
  119. agentscope_runtime/sandbox/tools/filesystem/tool.py +319 -0
  120. agentscope_runtime/sandbox/tools/function_tool.py +321 -0
  121. agentscope_runtime/sandbox/tools/mcp_tool.py +191 -0
  122. agentscope_runtime/sandbox/tools/sandbox_tool.py +104 -0
  123. agentscope_runtime/sandbox/tools/tool.py +123 -0
  124. agentscope_runtime/sandbox/tools/utils.py +68 -0
  125. agentscope_runtime/version.py +2 -0
  126. agentscope_runtime-0.1.0.dist-info/METADATA +327 -0
  127. agentscope_runtime-0.1.0.dist-info/RECORD +131 -0
  128. agentscope_runtime-0.1.0.dist-info/WHEEL +5 -0
  129. agentscope_runtime-0.1.0.dist-info/entry_points.txt +4 -0
  130. agentscope_runtime-0.1.0.dist-info/licenses/LICENSE +202 -0
  131. agentscope_runtime-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,54 @@
1
+ # -*- coding: utf-8 -*-
2
+ # registry.py
3
+ """
4
+ This module contains the registry for training boxes.
5
+ """
6
+
7
+ from typing import Dict, Type
8
+ from .base import BaseEnv
9
+
10
+
11
+ class Registry:
12
+ """
13
+ Registry for registering and managing environment classes.
14
+ Stores all BaseEnv subclasses with their names.
15
+ """
16
+
17
+ _envs: Dict[str, Type[BaseEnv]] = {}
18
+
19
+ @classmethod
20
+ def register(cls, name: str):
21
+ """
22
+ Registry for registering
23
+ """
24
+
25
+ def _register(env_class):
26
+ if not hasattr(env_class, "__bases__") or not any(
27
+ "BaseEnv" in str(base) for base in env_class.__bases__
28
+ ):
29
+ raise TypeError(
30
+ f"{env_class.__name__} must inherit from BaseEnv",
31
+ )
32
+ cls._envs[name] = env_class
33
+ return env_class
34
+
35
+ return _register
36
+
37
+ @classmethod
38
+ def get(cls, name: str) -> Type[BaseEnv]:
39
+ """
40
+ Get the Environment subclass by name.
41
+ """
42
+ if name not in cls._envs:
43
+ raise KeyError(
44
+ f"Environment '{name}' not found. "
45
+ f"Available: {list(cls._envs.keys())}",
46
+ )
47
+ return cls._envs[name]
48
+
49
+ @classmethod
50
+ def list(cls) -> list:
51
+ """
52
+ Get the environment classes registered.
53
+ """
54
+ return list(cls._envs.keys())
@@ -0,0 +1,278 @@
1
+ # -*- coding: utf-8 -*-
2
+ # pylint: disable=no-member
3
+ """
4
+ Module for defining data structures and models used in trajectory tracking.
5
+
6
+ This module provides classes and enums for managing messages, tool calls,
7
+ roles, rewards, and trajectory information in an agent-based system.
8
+ """
9
+ import datetime
10
+ import json
11
+ from typing import List, Any
12
+ from uuid import uuid4
13
+ from enum import Enum
14
+ from pydantic import BaseModel, Field # , model_validator
15
+
16
+
17
+ class Reward(BaseModel):
18
+ """
19
+ Represents a reward with an optional value and metadata.
20
+
21
+ Attributes:
22
+ reward_value (float, optional): The numerical reward value.
23
+ metadata (dict): Additional information about the reward.
24
+ """
25
+
26
+ reward_value: float | None = Field(default=None)
27
+ metadata: dict = Field(default_factory=dict)
28
+
29
+
30
+ class Role(str, Enum):
31
+ """
32
+ Enumeration of possible roles in the agent communication system.
33
+
34
+ Defines standard roles for system, user, tool,
35
+ and different types of assistants.
36
+ """
37
+
38
+ SYSTEM = "system"
39
+ USER = "user"
40
+ TOOL = "tool" # environment
41
+ ASSISTANT = "assistant" # policy model
42
+ CONTEXT_ASSISTANT = "context_assistant" # context model
43
+ SUMMARY_ASSISTANT = "summary_assistant" # summary model
44
+
45
+
46
+ class ToolCall(BaseModel):
47
+ """
48
+ Represents a tool call with its associated metadata and properties.
49
+
50
+ Attributes:
51
+ index (int): The index of the tool call.
52
+ id (str): Unique identifier for the tool call.
53
+ name (str): Name of the tool being called.
54
+ arguments (str): Arguments for the tool call.
55
+ type (str): Type of the tool call.
56
+ result (Any, optional): Result of the tool call.
57
+ """
58
+
59
+ index: int = Field(default=...)
60
+ id: str = Field(default="")
61
+ name: str = Field(default="")
62
+ arguments: str = Field(default="")
63
+ type: str = Field(default="function")
64
+ result: Any = Field(default=None, exclude=True)
65
+
66
+ # @model_validator(mode="before") # noqa
67
+ @classmethod
68
+ def init_tool_call(cls, data: dict):
69
+ """
70
+ Initialize tool call data, ensuring required fields are present.
71
+
72
+ Args:
73
+ data (dict): Input data for tool call.
74
+
75
+ Returns:
76
+ dict: Processed tool call data.
77
+ """
78
+ tool_type = data.get("type", "")
79
+ tool_type_dict = data.get(tool_type, {})
80
+
81
+ for key in ["name", "arguments"]:
82
+ if key not in data:
83
+ data[key] = tool_type_dict.get(key, "")
84
+ return data
85
+
86
+ @property
87
+ def argument_dict(self):
88
+ """
89
+ Convert arguments string to a dictionary.
90
+
91
+ Returns:
92
+ dict: Parsed arguments.
93
+ """
94
+ return json.loads(self.arguments)
95
+
96
+ @property
97
+ def simple_dict(self):
98
+ """
99
+ Create a simplified dictionary representation of the tool call.
100
+
101
+ Returns:
102
+ dict: Simplified tool call information.
103
+ """
104
+ return {
105
+ "id": self.id,
106
+ self.type: {"arguments": self.arguments, "name": self.name},
107
+ "type": self.type,
108
+ "index": self.index,
109
+ "result": self.result,
110
+ }
111
+
112
+
113
+ class Message(BaseModel):
114
+ """
115
+ Represents a message in the communication system.
116
+
117
+ Attributes:
118
+ role (Role): The role of the message sender.
119
+ content (str or bytes): The message content.
120
+ reasoning_content (str):
121
+ Additional reasoning content.
122
+ tool_calls (List[ToolCall]):
123
+ List of tool calls associated with the message.
124
+ timestamp (str): Timestamp of message creation.
125
+ metadata (dict): Additional metadata for the message.
126
+ """
127
+
128
+ role: Role = Field(default=Role.USER)
129
+ content: str | bytes = Field(default="")
130
+ reasoning_content: str = Field(default="")
131
+ tool_calls: List[ToolCall] = Field(default_factory=list)
132
+ timestamp: str = Field(
133
+ default_factory=lambda: datetime.datetime.now().strftime(
134
+ "%Y-%m-%d %H:%M:%S.%f",
135
+ ),
136
+ )
137
+ metadata: dict = Field(default_factory=dict)
138
+
139
+ @property
140
+ def simple_dict(self) -> dict:
141
+ """
142
+ Create a simplified dictionary representation of the message.
143
+
144
+ Returns:
145
+ dict: Simplified message information.
146
+ """
147
+ result = {
148
+ "role": self.role.value,
149
+ "content": self.content,
150
+ }
151
+ if self.tool_calls:
152
+ result["tool_calls"] = [x.simple_dict for x in self.tool_calls]
153
+ return result
154
+
155
+
156
+ class ActionMessage(Message):
157
+ """
158
+ Represents an action message with a predefined role of ASSISTANT.
159
+ """
160
+
161
+ role: Role = Field(default=Role.ASSISTANT)
162
+
163
+
164
+ class StateMessage(Message):
165
+ """
166
+ Represents a state message with additional tool call tracking.
167
+
168
+ Attributes:
169
+ tool_call_id (str): Identifier for the associated tool call.
170
+ """
171
+
172
+ role: Role = Field(default=Role.USER)
173
+ tool_call_id: str = Field(default="")
174
+
175
+ @property
176
+ def simple_dict(self) -> dict:
177
+ """
178
+ Create a simplified dictionary representation of the state message.
179
+
180
+ Returns:
181
+ dict: Simplified state message information.
182
+ """
183
+ result = {
184
+ "role": self.role.value,
185
+ "content": self.content,
186
+ "tool_calls": [tc.simple_dict for tc in self.tool_calls],
187
+ }
188
+ if self.tool_call_id:
189
+ result["tool_call_id"] = self.tool_call_id
190
+ return result
191
+
192
+ @property
193
+ def simple_list(self) -> list:
194
+ """
195
+ Create a simplified list representation of the state message.
196
+
197
+ Returns:
198
+ list: Simplified list of state message information.
199
+ """
200
+ return [
201
+ {
202
+ "role": self.role.value,
203
+ "content": str(x.result),
204
+ "tool_call_id": x.id,
205
+ }
206
+ for x in self.tool_calls
207
+ ]
208
+
209
+
210
+ class ContextMessage(Message):
211
+ """
212
+ Represents a context message with a predefined role of CONTEXT_ASSISTANT.
213
+ """
214
+
215
+ role: Role = Field(default=Role.CONTEXT_ASSISTANT)
216
+
217
+
218
+ class SummaryMessage(Message):
219
+ """
220
+ Represents a summary message with a predefined role of SUMMARY_ASSISTANT.
221
+ """
222
+
223
+ role: Role = Field(default=Role.SUMMARY_ASSISTANT)
224
+
225
+
226
+ class Sample(BaseModel):
227
+ """
228
+ Represents a sample with a list of messages and associated metadata.
229
+
230
+ Attributes:
231
+ steps (List[Message]): List of messages in the sample.
232
+ metadata (dict): Additional metadata for the sample.
233
+ """
234
+
235
+ steps: List[Message] = Field(default_factory=list)
236
+ metadata: dict = Field(default_factory=dict)
237
+
238
+
239
+ class Trajectory(BaseModel):
240
+ """
241
+ Represents a trajectory of steps with associated metadata.
242
+
243
+ Attributes:
244
+ id (str): Unique identifier for the trajectory.
245
+ steps (List[Message]): List of messages/steps in the trajectory.
246
+ done (bool): Flag indicating if the trajectory is complete.
247
+ query (str): Query associated with the trajectory.
248
+ answer (Any): Answer to the query.
249
+ metadata (dict): Additional metadata for the trajectory.
250
+ """
251
+
252
+ id: str = Field(default_factory=lambda: uuid4().hex)
253
+ steps: List[Message] = Field(default_factory=list)
254
+ done: bool = Field(default=False)
255
+ query: str = Field(default="")
256
+ answer: Any = Field(default=None)
257
+ metadata: dict = Field(default_factory=dict)
258
+
259
+ def add_step(self, step: Message):
260
+ """
261
+ Add a step (message) to the trajectory.
262
+
263
+ Args:
264
+ step (Message): Message to be added to the trajectory.
265
+ """
266
+ self.steps.append(step)
267
+
268
+ def reset(self):
269
+ """
270
+ Reset the trajectory to its initial state.
271
+
272
+ Clears steps, resets flags, and clears metadata.
273
+ """
274
+ self.steps.clear()
275
+ self.done = False
276
+ self.query = ""
277
+ self.answer = ""
278
+ self.metadata.clear()
@@ -0,0 +1,219 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Module for the Training Sandbox implementation.
4
+
5
+ This module provides a sandbox environment for training tasks
6
+ with specific configuration and tool calling methods.
7
+ """
8
+ import platform
9
+ from typing import Dict, Optional
10
+
11
+ from ...registry import SandboxRegistry
12
+ from ...enums import SandboxType
13
+ from ...box.sandbox import Sandbox
14
+ from ...constant import IMAGE_TAG
15
+
16
+
17
+ def get_image_tag() -> str:
18
+ machine = platform.machine().lower()
19
+ if machine in ("arm64", "aarch64", "armv7l", "armv8"):
20
+ return f"{IMAGE_TAG}-arm64"
21
+ return IMAGE_TAG
22
+
23
+
24
+ @SandboxRegistry.register(
25
+ f"agentscope/runtime-sandbox-appworld:{get_image_tag()}",
26
+ sandbox_type=SandboxType.APPWORLD,
27
+ runtime_config={"shm_size": "5.06gb"},
28
+ security_level="medium",
29
+ timeout=30,
30
+ description="appworld Sandbox",
31
+ )
32
+ class TrainingSandbox(Sandbox):
33
+ """
34
+ Training Sandbox class for managing and executing training-related tasks.
35
+
36
+ This class provides methods to create, manage, and interact with
37
+ training environment instances using specialized tool calls.
38
+ """
39
+
40
+ def __init__(
41
+ self,
42
+ sandbox_id: Optional[str] = None,
43
+ timeout: int = 3000,
44
+ base_url: Optional[str] = None,
45
+ bearer_token: Optional[str] = None,
46
+ ):
47
+ """
48
+ Initialize the Training Sandbox.
49
+
50
+ Args:
51
+ sandbox_id (Optional[str]): Unique identifier for the sandbox.
52
+ timeout (int): Maximum time allowed for sandbox operations.
53
+ base_url (Optional[str]): Base URL for sandbox API.
54
+ bearer_token (Optional[str]): Authentication token for API access.
55
+ """
56
+ super().__init__(
57
+ sandbox_id,
58
+ timeout,
59
+ base_url,
60
+ bearer_token,
61
+ SandboxType.APPWORLD,
62
+ )
63
+
64
+ def create_instance(
65
+ self,
66
+ env_type: str,
67
+ task_id: str,
68
+ instance_id: str = None,
69
+ params: Dict = None,
70
+ ):
71
+ """
72
+ Create a new instance of a training environment.
73
+
74
+ Args:
75
+ env_type (str): Type of environment to create.
76
+ task_id (str): Identifier for the specific task.
77
+ instance_id (str, optional): Custom instance identifier.
78
+ params (Dict, optional):
79
+ Additional parameters for instance creation.
80
+
81
+ Returns:
82
+ The created instance details.
83
+ """
84
+ return self.call_tool(
85
+ name="create_instance",
86
+ arguments={
87
+ "env_type": env_type,
88
+ "task_id": task_id,
89
+ "instance_id": instance_id,
90
+ "params": params,
91
+ },
92
+ )
93
+
94
+ def get_task_ids(
95
+ self,
96
+ env_type: str,
97
+ split: str = "train",
98
+ params: dict = None,
99
+ ):
100
+ """
101
+ Retrieve task identifiers for a specific environment.
102
+
103
+ Args:
104
+ env_type (str): Type of environment.
105
+ split (str, optional):
106
+ Data split to retrieve tasks from. Defaults to "train".
107
+ params (dict, optional): Additional filtering parameters.
108
+
109
+ Returns:
110
+ List of task identifiers.
111
+ """
112
+ return self.call_tool(
113
+ name="get_task_ids",
114
+ arguments={
115
+ "env_type": env_type,
116
+ "split": split,
117
+ "params": params,
118
+ },
119
+ )
120
+
121
+ def get_env_profile(
122
+ self,
123
+ env_type: str,
124
+ split: str = "train",
125
+ params: dict = None,
126
+ ):
127
+ """
128
+ Retrieve the environment profile.
129
+
130
+ Args:
131
+ env_type (str): Type of environment.
132
+ split (str, optional):
133
+ Data split to retrieve profile from. Defaults to "train".
134
+ params (dict, optional): Additional profile retrieval parameters.
135
+
136
+ Returns:
137
+ Environment profile details.
138
+ """
139
+ return self.call_tool(
140
+ name="get_env_profile",
141
+ arguments={
142
+ "env_type": env_type,
143
+ "split": split,
144
+ "params": params,
145
+ },
146
+ )
147
+
148
+ def step(
149
+ self,
150
+ instance_id: str,
151
+ action: Dict = None,
152
+ params: Dict = None,
153
+ ) -> str:
154
+ """
155
+ Execute a step in the training environment.
156
+
157
+ Args:
158
+ instance_id (str): Identifier of the environment instance.
159
+ action (Dict, optional): Action to be performed in the environment.
160
+ params (Dict, optional): Additional step parameters.
161
+
162
+ Returns:
163
+ str: Result of the step execution.
164
+ """
165
+ action = action or {}
166
+ params = params or {}
167
+ return self.call_tool(
168
+ name="step",
169
+ arguments={
170
+ "instance_id": instance_id,
171
+ "action": action,
172
+ "params": params,
173
+ },
174
+ )
175
+
176
+ def evaluate(
177
+ self,
178
+ instance_id: str,
179
+ messages: Dict = None,
180
+ params: Dict = None,
181
+ ):
182
+ """
183
+ Evaluate the performance of a training environment instance.
184
+
185
+ Args:
186
+ instance_id (str): Identifier of the environment instance.
187
+ messages (Dict, optional): Evaluation-related messages.
188
+ params (Dict, optional): Additional evaluation parameters.
189
+
190
+ Returns:
191
+ Evaluation results.
192
+ """
193
+ messages = messages or {}
194
+ params = params or {}
195
+ return self.call_tool(
196
+ name="evaluate",
197
+ arguments={
198
+ "instance_id": instance_id,
199
+ "messages": messages,
200
+ "params": params,
201
+ },
202
+ )
203
+
204
+ def release_instance(self, instance_id: str):
205
+ """
206
+ Release a training environment instance.
207
+
208
+ Args:
209
+ instance_id (str): Identifier of the instance to be released.
210
+
211
+ Returns:
212
+ Result of the instance release operation.
213
+ """
214
+ return self.call_tool(
215
+ name="release_instance",
216
+ arguments={
217
+ "instance_id": instance_id,
218
+ },
219
+ )