Task Suite¶
TaskSuite
¶
TaskSuite(
name: str,
environment_type: type[Env],
tools: list[Function],
data_path: Path | None = None,
benchmark_version: BenchmarkVersion = (1, 0, 0),
)
A suite of tasks that can be run in an environment. Tasks can be both user tasks and injection tasks. It is not mandatory to have injection tasks in case the suite is used to evaluate the model only for utility.
Parameters:
-
name
(str
) –The name of the suite.
-
environment_type
(type[Env]
) –The environment type that the suite operates on.
-
tools
(list[Function]
) –A list of tools that the agent can use to solve the tasks.
-
data_path
(Path | None
, default:None
) –The path to the suite data directory. It should be provided for non-default suites. The directory should contain the following files: -
environment.yaml
: The data of the environment. -injection_vectors.yaml
: The injection vectors in the environment.
Source code in src/agentdojo/task_suite/task_suite.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
user_tasks
property
¶
user_tasks: dict[str, BaseUserTask[Env]]
The user tasks in the suite.
Returns:
-
dict[str, BaseUserTask[Env]]
–A dictionary of user tasks with their IDs as keys.
injection_tasks
property
¶
injection_tasks: dict[str, BaseInjectionTask[Env]]
The injection tasks in the suite.
Returns:
-
dict[str, BaseInjectionTask[Env]]
–A dictionary of injection tasks with their IDs as keys.
register_user_task
¶
register_user_task(
task: type[BaseUserTask[Env]],
) -> type[BaseUserTask[Env]]
Register a user task in the suite.
Parameters:
-
task
(type[BaseUserTask[Env]]
) –The user task class to register.
Source code in src/agentdojo/task_suite/task_suite.py
161 162 163 164 165 166 167 168 169 170 171 |
|
update_user_task
¶
update_user_task(benchmark_version: BenchmarkVersion)
Updates a user task in the suite and makes it part of the benchmark with the given version
Parameters:
-
benchmark_version
(BenchmarkVersion
) –The benchmark version this task belongs to.
Source code in src/agentdojo/task_suite/task_suite.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
get_user_task_by_id
cached
¶
get_user_task_by_id(task_id: str) -> BaseUserTask[Env]
Get a user task by its ID.
Source code in src/agentdojo/task_suite/task_suite.py
201 202 203 204 |
|
get_latest_user_task_by_id
cached
¶
get_latest_user_task_by_id(
task_id: str, version_upperbound: BenchmarkVersion
) -> BaseUserTask[Env]
Get a user task by its ID in its latest version.
Source code in src/agentdojo/task_suite/task_suite.py
206 207 208 209 210 211 |
|
get_latest_injection_task_by_id
cached
¶
get_latest_injection_task_by_id(
task_id: str, version_upperbound: BenchmarkVersion
) -> BaseInjectionTask[Env]
Get a user task by its ID in its latest version.
Source code in src/agentdojo/task_suite/task_suite.py
213 214 215 216 217 218 219 220 |
|
register_injection_task
¶
register_injection_task(
task: type[BaseInjectionTask[Env]],
) -> type[BaseInjectionTask[Env]]
Register an injection task in the suite.
Parameters:
-
task
(type[BaseInjectionTask[Env]]
) –The injection task class to register.
Source code in src/agentdojo/task_suite/task_suite.py
222 223 224 225 226 227 228 229 230 231 232 |
|
update_injection_task
¶
update_injection_task(benchmark_version: BenchmarkVersion)
Updates an injection task in the suite and makes it part of the benchmark with the given version
Parameters:
-
benchmark_version
(BenchmarkVersion
) –The benchmark version this task belongs to.
Source code in src/agentdojo/task_suite/task_suite.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
get_injection_task_by_id
¶
get_injection_task_by_id(
injection_task_id: str,
) -> BaseInjectionTask[Env]
Get an injection task by its ID.
Source code in src/agentdojo/task_suite/task_suite.py
262 263 264 |
|
run_task_with_pipeline
¶
run_task_with_pipeline(
agent_pipeline: BasePipelineElement,
user_task: BaseUserTask[Env] | BaseInjectionTask[Env],
injection_task: BaseInjectionTask[Env] | None,
injections: dict[str, str],
runtime_class: type[
FunctionsRuntime
] = FunctionsRuntime,
environment: Env | None = None,
verbose: bool = False,
) -> tuple[bool, bool]
Run a task with the provided pipeline.
Parameters:
-
agent_pipeline
(BasePipelineElement
) –The pipeline to use for the task.
-
user_task
(BaseUserTask[Env] | BaseInjectionTask[Env]
) –The user task to run.
-
injection_task
(BaseInjectionTask[Env] | None
) –The injection task to run.
-
injections
(dict[str, str]
) –The injections to use for the task.
-
runtime_class
(type[FunctionsRuntime]
, default:FunctionsRuntime
) –The runtime class to use for the task.
-
environment
(Env | None
, default:None
) –The environment to use for the task.
-
verbose
(bool
, default:False
) –Whether to print debug information.
Returns:
-
bool
–A tuple of two booleans, the first indicating whether the task was successful, and the second indicating if
-
bool
–the injection was successful.
Source code in src/agentdojo/task_suite/task_suite.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
|