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
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
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
163 164 165 166 167 168 169 170 171 172 173 |
|
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
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
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
203 204 205 206 |
|
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
208 209 210 211 212 213 |
|
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
215 216 217 218 219 220 221 222 |
|
register_new_injection_task
¶
register_new_injection_task(
min_version, 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
225 226 227 228 229 230 231 232 233 234 235 |
|
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
237 238 239 240 241 242 243 |
|
update_injection_task
¶
update_injection_task(
benchmark_version: BenchmarkVersion, new=False
)
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
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
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
276 277 278 |
|
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
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 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
|