Agent Lightning Core¶
Client Side¶
agentlightning.litagent
¶
LitAgent
¶
Base class for the training and validation logic of an agent.
Developers should subclass this class and implement the rollout methods to define the agent's behavior for a single task. The agent's logic is completely decoupled from the server communication and training infrastructure.
Source code in agentlightning/litagent.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
runner
property
¶
Get the runner for this agent.
Returns:
Type | Description |
---|---|
AgentRunner
|
The AgentRunner instance associated with this agent. |
tracer
property
¶
Get the tracer for this agent.
Returns:
Type | Description |
---|---|
BaseTracer
|
The BaseTracer instance associated with this agent. |
trainer
property
¶
Get the trainer for this agent.
Returns:
Type | Description |
---|---|
Trainer
|
The Trainer instance associated with this agent. |
__init__(*, trained_agents=None)
¶
Initialize the LitAgent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trained_agents
|
Optional[str]
|
Optional string representing the trained agents. This can be used to track which agents have been trained by this instance. |
None
|
Source code in agentlightning/litagent.py
on_rollout_end(task, rollout, runner, tracer)
¶
Hook called after a rollout completes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
Task
|
The :class: |
required |
rollout
|
Rollout
|
The resulting :class: |
required |
runner
|
AgentRunner
|
The :class: |
required |
tracer
|
BaseTracer
|
The tracer instance associated with the runner. |
required |
Subclasses can override this method for cleanup or additional logging. By default, this is a no-op.
Source code in agentlightning/litagent.py
on_rollout_start(task, runner, tracer)
¶
Hook called immediately before a rollout begins.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
Task
|
The :class: |
required |
runner
|
AgentRunner
|
The :class: |
required |
tracer
|
BaseTracer
|
The tracer instance associated with the runner. |
required |
Subclasses can override this method to implement custom logic such as logging, metric collection, or resource setup. By default, this is a no-op.
Source code in agentlightning/litagent.py
set_runner(runner)
¶
Set the runner for this agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
runner
|
AgentRunner
|
The AgentRunner instance that will handle the execution of rollouts. |
required |
set_trainer(trainer)
¶
Set the trainer for this agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trainer
|
Trainer
|
The Trainer instance that will handle training and validation. |
required |
training_rollout(task, rollout_id, resources)
¶
Defines the agent's behavior for a single training task.
This method should contain the logic for how the agent processes an input, uses the provided resources (like LLMs or prompts), and produces a result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
TaskInput
|
The task object received from the server, containing the input data and metadata. |
required |
rollout_id
|
str
|
A unique identifier for the rollout, used for tracking and reporting purposes. |
required |
resources
|
NamedResources
|
A dictionary of named resources (e.g., LLMs, prompt templates) for the agent to use. |
required |
Returns:
Type | Description |
---|---|
RolloutRawResult
|
The result of the rollout, which can be one of: |
RolloutRawResult
|
|
RolloutRawResult
|
|
RolloutRawResult
|
|
RolloutRawResult
|
|
RolloutRawResult
|
|
RolloutRawResult
|
|
Source code in agentlightning/litagent.py
training_rollout_async(task, rollout_id, resources)
async
¶
Asynchronous version of training_rollout
.
This method should be implemented by agents that perform asynchronous operations (e.g., non-blocking I/O, concurrent API calls).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
TaskInput
|
The task object received from the server. |
required |
rollout_id
|
str
|
A unique identifier for the training rollout, used for tracking and reporting purposes. |
required |
resources
|
NamedResources
|
A dictionary of named resources for the agent to use. |
required |
Returns:
Type | Description |
---|---|
RolloutRawResult
|
The result of the asynchronous training rollout. |
Source code in agentlightning/litagent.py
validation_rollout(task, rollout_id, resources)
¶
Defines the agent's behavior for a single validation task.
By default, this method redirects to training_rollout
. Override it
if the agent should behave differently during validation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
TaskInput
|
The task object received from the server, containing the input data and metadata. |
required |
rollout_id
|
str
|
A unique identifier for the validation rollout, used for tracking and reporting purposes. |
required |
resources
|
NamedResources
|
A dictionary of named resources for the agent to use. |
required |
Returns:
Type | Description |
---|---|
RolloutRawResult
|
The result of the validation rollout. See |
RolloutRawResult
|
possible return types. |
Source code in agentlightning/litagent.py
validation_rollout_async(task, rollout_id, resources)
async
¶
Asynchronous version of validation_rollout
.
By default, this method redirects to training_rollout_async
.
Override it for different asynchronous validation behavior.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
TaskInput
|
The task object received from the server. |
required |
rollout_id
|
str
|
A unique identifier for the validation rollout, used for tracking and reporting purposes. |
required |
resources
|
NamedResources
|
A dictionary of named resources for the agent to use. |
required |
Returns:
Type | Description |
---|---|
RolloutRawResult
|
The result of the asynchronous validation rollout. |
Source code in agentlightning/litagent.py
agentlightning.client
¶
AgentLightningClient
¶
Client for interacting with a version-aware Agent Lightning Server.
This client handles polling for tasks, fetching specific versions of resources (like model configurations), and posting completed rollouts back to the server. It provides both synchronous and asynchronous methods for these operations and includes a cache for resources.
Source code in agentlightning/client.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
__init__(endpoint, poll_interval=5.0, timeout=10.0)
¶
Initializes the AgentLightningClient.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint
|
str
|
The root URL of the Agent Lightning server. |
required |
poll_interval
|
float
|
The interval in seconds to wait between polling for new tasks. |
5.0
|
timeout
|
float
|
The timeout in seconds for HTTP requests. |
10.0
|
Source code in agentlightning/client.py
get_latest_resources()
¶
Fetches the latest available resources from the server synchronously.
Returns:
Type | Description |
---|---|
Optional[ResourcesUpdate]
|
A ResourcesUpdate object containing the latest resources. |
Source code in agentlightning/client.py
get_latest_resources_async()
async
¶
Fetches the latest available resources from the server.
Returns:
Type | Description |
---|---|
Optional[ResourcesUpdate]
|
A ResourcesUpdate object containing the latest resources. |
Source code in agentlightning/client.py
get_resources_by_id(resource_id)
¶
Fetches a specific version of resources by its ID synchronously, using a cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resource_id
|
str
|
The ID of the resources to fetch, usually from a Task's metadata. |
required |
Returns:
Type | Description |
---|---|
Optional[ResourcesUpdate]
|
A ResourcesUpdate object containing the versioned resources, or None if not found. |
Source code in agentlightning/client.py
get_resources_by_id_async(resource_id)
async
¶
Fetches a specific version of resources by its ID, using a cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resource_id
|
str
|
The ID of the resources to fetch, usually from a Task's metadata. |
required |
Returns:
Type | Description |
---|---|
Optional[ResourcesUpdate]
|
A ResourcesUpdate object containing the versioned resources, or None if not found. |
Source code in agentlightning/client.py
poll_next_task()
¶
Polls the server synchronously for the next task until one is available.
Returns:
Type | Description |
---|---|
Task
|
A Task object containing the task details, including the required |
Source code in agentlightning/client.py
poll_next_task_async()
async
¶
Polls the server asynchronously for the next task until one is available.
Returns:
Type | Description |
---|---|
Task
|
A Task object containing the task details. |
Source code in agentlightning/client.py
post_rollout(rollout)
¶
Posts a completed rollout to the server synchronously.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rollout
|
Rollout
|
A Rollout object containing the results of a task. |
required |
Returns:
Type | Description |
---|---|
Optional[Dict[str, Any]]
|
The server's JSON response as a dictionary. |
Source code in agentlightning/client.py
post_rollout_async(rollout)
async
¶
Posts a completed rollout to the server asynchronously.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rollout
|
Rollout
|
A Rollout object containing the results of a task. |
required |
Returns:
Type | Description |
---|---|
Optional[Dict[str, Any]]
|
The server's JSON response as a dictionary. |
Source code in agentlightning/client.py
DevTaskLoader
¶
Bases: AgentLightningClient
A local task manager for development that provides sample tasks and resources.
This client mocks the server APIs by maintaining a local queue of tasks and resources within the same process. It's designed for development, testing, and scenarios where a full Agent Lightning server is not needed.
The DevTaskLoader overrides the polling and resource fetching methods to return data from local collections instead of making HTTP requests to a remote server.
Source code in agentlightning/client.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 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 |
|
rollouts
property
¶
Return rollouts that have been posted back to the loader.
__init__(tasks, resources, **kwargs)
¶
Initializes the DevTaskLoader with pre-defined tasks and resources.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tasks
|
Union[List[TaskInput], List[Task]]
|
Either a List of TaskInput objects or a List of Task objects. |
required |
resources
|
Union[NamedResources, ResourcesUpdate]
|
Either NamedResources or ResourcesUpdate object. |
required |
**kwargs
|
Any
|
Additional arguments passed to the parent AgentLightningClient. |
{}
|
Source code in agentlightning/client.py
poll_next_task()
¶
Returns the next task from the local queue.
If tasks are TaskInput objects, assembles them into Task objects. If tasks are already Task objects, returns them directly.
Returns:
Type | Description |
---|---|
Task
|
The next Task object from the local task list. |
Source code in agentlightning/client.py
agentlightning.runner
¶
AgentRunner
¶
Bases: ParallelWorkerBase
Manages the agent's execution loop and integrates with AgentOps.
This class orchestrates the interaction between the agent (LitAgent
) and
the server (AgentLightningClient
). It handles polling for tasks, executing
the agent's logic, and reporting results back to the server. If enabled,
it will also automatically trace each rollout using AgentOps.
Attributes:
Name | Type | Description |
---|---|---|
agent |
The |
|
client |
The |
|
tracer |
The tracer instance for this runner/worker. |
|
worker_id |
An optional identifier for the worker process. |
|
max_tasks |
The maximum number of tasks to process before stopping. |
Source code in agentlightning/runner.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|
iter()
¶
Executes the synchronous polling and rollout loop.
Source code in agentlightning/runner.py
iter_async()
async
¶
Executes the asynchronous polling and rollout loop.
Source code in agentlightning/runner.py
run()
¶
Poll the task and rollout once synchronously.
Source code in agentlightning/runner.py
run_async()
async
¶
Poll the task and rollout once.
Source code in agentlightning/runner.py
agentlightning.trainer
¶
Trainer
¶
Bases: ParallelWorkerBase
Orchestrates the distributed execution of agent rollouts.
The Trainer is responsible for launching one or more worker processes that run the agent's execution loop. It manages multiprocessing, handles graceful shutdown, and serves as the main entry point for running a client-side agent fleet.
Attributes:
Name | Type | Description |
---|---|---|
dev |
If True, rollouts are run against the dev endpoint provided in |
|
n_workers |
Number of agent workers (processes) to run in parallel. |
|
max_tasks |
Maximum number of tasks to process per worker. If None, workers run until no more tasks are available. |
|
daemon |
Whether worker processes should be daemons. Daemon processes are terminated automatically when the main process exits. |
|
tracer |
A tracer instance, or a string pointing to the class full name or a dictionary with a 'type' key
that specifies the class full name and other initialization parameters.
If None, a default |
|
triplet_exporter |
An instance of |
Source code in agentlightning/trainer.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|
client()
¶
Returns the AgentLightningClient instance.
kill_orphaned_processes()
staticmethod
¶
Kill any orphaned processes that may have been left behind by previous runs. This is useful for cleaning up after crashes or unexpected exits.
Source code in agentlightning/trainer.py
agentlightning.tracer
¶
agentlightning.reward
¶
reward(fn)
¶
A decorator to wrap a function that computes rewards. It will automatically handle the input and output of the function.
Source code in agentlightning/reward.py
Server Side¶
agentlightning.server
¶
AgentLightningServer
¶
The main SDK class for developers to control the Agent Lightning Server.
This class manages the server lifecycle, task queueing, resources updates, and retrieval of results, providing a simple interface for the optimization logic.
Source code in agentlightning/server.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 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 |
|
__init__(host='127.0.0.1', port=8000, task_timeout_seconds=300.0)
¶
Initializes the server controller.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
host
|
str
|
The host to bind the server to. |
'127.0.0.1'
|
port
|
int
|
The port to bind the server to. |
8000
|
task_timeout_seconds
|
float
|
Time in seconds after which a claimed task is considered stale and requeued. |
300.0
|
Source code in agentlightning/server.py
get_completed_rollout(rollout_id)
async
¶
Retrieves a specific completed rollout by its ID.
Source code in agentlightning/server.py
poll_completed_rollout(rollout_id, timeout=None)
async
¶
Polls for a completed rollout by its ID, waiting up to timeout
seconds.
Source code in agentlightning/server.py
queue_task(sample, mode=None, resources_id=None, metadata=None)
async
¶
Adds a task to the queue for a client to process.
Source code in agentlightning/server.py
retrieve_completed_rollouts()
async
¶
Retrieves all available completed trajectories and clears the internal store.
Source code in agentlightning/server.py
run_forever()
async
¶
Runs the server indefinitely until stopped. This is useful when async start and stop methods do not work.
start()
async
¶
Starts the FastAPI server in the background.
stop()
async
¶
Gracefully stops the running FastAPI server.
Source code in agentlightning/server.py
update_resources(resources)
async
¶
Updates the resources, creating a new version and setting it as the latest.
Source code in agentlightning/server.py
ServerDataStore
¶
A centralized, thread-safe, async, in-memory data store for the server's state. This holds the task queue, versioned resources, and completed rollouts.
Source code in agentlightning/server.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
add_task(sample, mode=None, resources_id=None, metadata=None)
async
¶
Adds a new task to the queue with specific metadata and returns its unique ID.
Source code in agentlightning/server.py
get_latest_resources()
async
¶
Safely retrieves the latest version of named resources.
Source code in agentlightning/server.py
get_next_task()
async
¶
Retrieves the next task from the queue without blocking. Returns None if the queue is empty.
Source code in agentlightning/server.py
get_processing_tasks()
¶
get_resources_by_id(resources_id)
async
¶
Safely retrieves a specific version of named resources by its ID.
Source code in agentlightning/server.py
requeue_task(task)
async
¶
Requeues a task that has timed out and removes it from processing.
Source code in agentlightning/server.py
retrieve_completed_rollouts()
async
¶
Retrieves all completed rollouts and clears the store.
Source code in agentlightning/server.py
retrieve_rollout(rollout_id)
async
¶
Safely retrieves a single rollout by its ID, removing it from the store.
Source code in agentlightning/server.py
store_rollout(rollout)
async
¶
Safely stores a completed rollout from a client.
Source code in agentlightning/server.py
update_resources(update)
async
¶
Safely stores a new version of named resources and sets it as the latest.
Source code in agentlightning/server.py
Utilities¶
agentlightning.config
¶
This file is not carefully reviewed. It might contain unintentional bugs and issues. Please always review the parsed construction arguments before using them.
lightning_cli(*classes)
¶
Parses command-line arguments to configure and instantiate provided CliConfigurable classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*classes
|
Type[CliConfigurable]
|
One or more classes that inherit from CliConfigurable. Each class's init parameters will be exposed as command-line arguments. |
()
|
Returns:
Type | Description |
---|---|
CliConfigurable | Tuple[CliConfigurable, ...]
|
A tuple of instantiated objects, corresponding to the input classes in order. |
Source code in agentlightning/config.py
nullable_float(value)
¶
Converts specific string values (case-insensitive) to None, otherwise returns the float.
Source code in agentlightning/config.py
nullable_int(value)
¶
Converts specific string values (case-insensitive) to None, otherwise returns the integer.
Source code in agentlightning/config.py
nullable_str(value)
¶
Converts specific string values (case-insensitive) to None, otherwise returns the string.
agentlightning.types
¶
NamedResources = Dict[str, ResourceUnion]
module-attribute
¶
A dictionary-like class to hold named resources.
Example
resources: NamedResources = { 'main_llm': LLM( endpoint="http://localhost:8080", model="llama3", sampling_parameters={'temperature': 0.7, 'max_tokens': 100} ), 'system_prompt': PromptTemplate( template="You are a helpful assistant.", engine='f-string' ) }
GenericResponse
¶
Bases: BaseModel
A generic response message that can be used for various purposes.
Source code in agentlightning/types.py
LLM
¶
Bases: Resource
Provide an LLM endpoint and model name as a resource.
Attributes:
Name | Type | Description |
---|---|---|
endpoint |
str
|
The URL of the LLM API endpoint. |
model |
str
|
The identifier for the model to be used (e.g., 'gpt-4o'). |
sampling_parameters |
SamplingParameters
|
A dictionary of hyperparameters for model inference, such as temperature, top_p, etc. |
Source code in agentlightning/types.py
ParallelWorkerBase
¶
Base class for objects that can be parallelized across multiple worker processes.
This class defines the standard lifecycle for parallel processing:
Main Process
- init() - Initialize the object in the main process
- spawn workers and call init_worker() in each worker
- run() - Execute the main workload in parallel across workers
- teardown_worker() - Clean up resources in each worker
- teardown() - Final cleanup in the main process
Subclasses should implement the run() method and optionally override the lifecycle methods for custom initialization and cleanup behavior.
Source code in agentlightning/types.py
PromptTemplate
¶
Bases: Resource
A prompt template as a resource.
Attributes:
Name | Type | Description |
---|---|---|
template |
str
|
The template string. The format depends on the engine. |
engine |
Literal['jinja', 'f-string', 'poml']
|
The templating engine to use for rendering the prompt. I imagine users can use their own customized engines, but algos can only well operate on a subset of them. |
Source code in agentlightning/types.py
Resource
¶
ResourcesUpdate
¶
Bases: BaseModel
A resource update message to be sent from the server to clients.
This message contains a dictionary of resources that clients should use for subsequent tasks. It is used to update the resources available to clients dynamically.
Source code in agentlightning/types.py
Rollout
¶
Bases: BaseModel
The standard reporting object from client to server.
Source code in agentlightning/types.py
Task
¶
Bases: BaseModel
A task (rollout request) to be processed by the client agent.
Source code in agentlightning/types.py
Triplet
¶
Bases: BaseModel
A standard structure for a single turn in a trajectory.