Agents API¶
Package Exports¶
ProactiveAgent
¶
Proactive agent wrapper that manages observe and execute agents.
Observer agent is responsible for continuous monitoring of the environment and proposing goals to the user. Executer agent is responsible for executing the confirmed goal.
Source code in pare/agents/proactive/agent.py
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 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 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 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | |
agent_framework
property
¶
Name of the agent.
execute_model
property
¶
Name of the execute model.
observe_model
property
¶
Name of the observe model.
__init__(log_callback, pause_env, resume_env, observe_llm_engine, observe_agent, execute_llm_engine, execute_agent, time_manager, tools=None, observe_max_iterations=10, execute_max_iterations=20, max_turns=None, simulated_generation_time_config=None)
¶
Initializes the ProactiveAgent wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_callback
|
Callable[[BaseAgentLog], None]
|
Callback to log agent logs. |
required |
pause_env
|
Callable[[], None] | None
|
Callback to pause the environment. |
required |
resume_env
|
Callable[[float], None] | None
|
Callback to resume the environment. |
required |
observe_llm_engine
|
LLMEngine
|
LLM engine to use for the observer agent. |
required |
observe_agent
|
BaseAgent
|
Observer agent to wrap. |
required |
execute_llm_engine
|
LLMEngine
|
LLM engine to use for the execute agent. |
required |
execute_agent
|
BaseAgent
|
Execute agent to wrap. |
required |
time_manager
|
TimeManager
|
Time manager to use for the agent. |
required |
tools
|
list[Tool] | None
|
Tools to use for the agent. |
None
|
observe_max_iterations
|
int
|
Maximum number of iterations to run per turn for the observer agent. |
10
|
execute_max_iterations
|
int
|
Maximum number of iterations to run per turn for the execute agent. |
20
|
max_turns
|
int | None
|
Maximum number of turns to run. |
None
|
simulated_generation_time_config
|
SimulatedGenerationTimeConfig | None
|
Simulated generation time config to use for the agent. |
None
|
Source code in pare/agents/proactive/agent.py
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 | |
agent_loop(initial_task=None, reset=True)
¶
Execute one proactive agent turn either in observe or execute mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_task
|
str | None
|
Initial task to run the agent with. |
None
|
reset
|
bool
|
Whether to reset the proactive agent. |
True
|
Returns:
| Type | Description |
|---|---|
str | MMObservation | None
|
Result from the last agent turn execution. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If notification system is not set for either observe or execute agent. |
Source code in pare/agents/proactive/agent.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
build_task_from_notifications(user_messages)
¶
Build User Agent task from agent messages.
User messages comes from the User Agent in the form of accept/reject responses. Environment notifications are handled separately by preprocessing step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_messages
|
list[Message]
|
List of user messages. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Task string for the User Agent. |
Source code in pare/agents/proactive/agent.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
get_notifications()
¶
Get new notifications from the custom state, NOT from the notification system.
Notification system get_by_timestamp() method is destructive and removes messages from the queue. This creates an assymetric view of system notifications for the two agents.
From the Proactive Agent perspective: - user_messages: messages sent by the user to the agent. - environment_notifications: Environment events like incoming email, messages etc. - env_stop_messages: Environment stop signals
Returns:
| Type | Description |
|---|---|
tuple[list[Message], list[Message], list[Message]]
|
Tuple of (list of new user messages, list of new environment notifications, list of environment stop messages). |
Source code in pare/agents/proactive/agent.py
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 | |
get_proposal_count()
¶
Count the number of proposals made by the observe agent.
Proposals are identified by calls to send_message_to_user tool.
Returns:
| Type | Description |
|---|---|
int
|
Number of proposals made. |
Source code in pare/agents/proactive/agent.py
567 568 569 570 571 572 573 574 575 576 577 578 579 | |
get_read_only_actions()
¶
Count read-only actions from both observe and execute agents.
Returns:
| Type | Description |
|---|---|
int
|
Number of read-only tool calls. |
Source code in pare/agents/proactive/agent.py
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | |
get_turn_ending_tool(agent)
¶
Get the turn ending tool from the agent logs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
BaseAgent
|
The agent to get the turn ending tool for. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str | None]
|
The turn ending tool name. |
Source code in pare/agents/proactive/agent.py
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 | |
get_write_actions()
¶
Count write actions from both observe and execute agents.
Returns:
| Type | Description |
|---|---|
int
|
Number of write tool calls. |
Source code in pare/agents/proactive/agent.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | |
init_execute_system_prompt(scenario)
¶
Initialize the execute system prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
Scenario
|
Scenario to initialize the execute system prompt for. |
required |
Source code in pare/agents/proactive/agent.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
init_notification_system(notification_system)
¶
Initialize the notification system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notification_system
|
BaseNotificationSystem
|
Notification system to initialize. |
required |
Source code in pare/agents/proactive/agent.py
248 249 250 251 252 253 254 255 256 257 | |
init_observe_system_prompt(scenario)
¶
Initialize the observe system prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
Scenario
|
Scenario to initialize the observe system prompt for. |
required |
Source code in pare/agents/proactive/agent.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
init_tools(scenario)
¶
Initialize the tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
Scenario
|
Scenario to initialize the tools for. |
required |
Source code in pare/agents/proactive/agent.py
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 | |
prepare_proactive_agent_run(scenario, notification_system=None, observe_agent_logs=None, execute_agent_logs=None)
¶
Prepare the proactive agent run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
Scenario
|
Scenario to run the turn for. |
required |
notification_system
|
BaseNotificationSystem | None
|
Notification system to use for the agent. |
None
|
observe_agent_logs
|
list[BaseAgentLog] | None
|
Initial agent logs to use for the observe agent. |
None
|
execute_agent_logs
|
list[BaseAgentLog] | None
|
Initial agent logs to use for the execute agent. |
None
|
Source code in pare/agents/proactive/agent.py
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 | |
remove_aui_irrelevant_tools(app_tools)
¶
Remove irrelevant tools from the app tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_tools
|
list[AppTool]
|
List of app tools. |
required |
Returns:
| Type | Description |
|---|---|
list[AppTool]
|
List of app tools. |
Source code in pare/agents/proactive/agent.py
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 | |
UserAgent
¶
User agent wrapper that simulates realistic user behavior on a mobile phone.
Wraps a Meta-ARE BaseAgent and configured for single-action turns. Manages notification polling, task building and tool refreshing. Based on meta-are/are/simulation/agents/default_agent/are_simulation_main.py
Source code in pare/agents/user/agent.py
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 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 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
agent_framework
property
¶
Name of the agent.
model
property
¶
Name of the model.
__init__(log_callback, pause_env, resume_env, llm_engine, base_agent, time_manager, max_iterations=1, max_turns=None, simulated_generation_time_config=None)
¶
Initializes the UserAgent wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_callback
|
Callable[[BaseAgentLog], None]
|
Callback to log agent logs. |
required |
pause_env
|
Callable[[], None] | None
|
Callback to pause the environment. |
required |
resume_env
|
Callable[[float], None] | None
|
Callback to resume the environment. |
required |
llm_engine
|
LLMEngine
|
LLM engine to use for the agent. |
required |
base_agent
|
BaseAgent
|
Base agent to wrap. |
required |
time_manager
|
TimeManager
|
Time manager to use for the agent. |
required |
max_iterations
|
int
|
Maximum number of iterations to run per turn. |
1
|
max_turns
|
int | None
|
Maximum number of turns to run. |
None
|
simulated_generation_time_config
|
SimulatedGenerationTimeConfig | None
|
Simulated generation time config to use for the agent. |
None
|
Source code in pare/agents/user/agent.py
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 | |
agent_loop(current_tools, current_app=None, current_state=None, reset=True)
¶
Execute one user agent turn.
This is completely synchronous function where the agent runs on notifications.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_tools
|
list[AppTool]
|
Current tools to use for the turn. |
required |
current_app
|
App | None
|
Current active app in the environment for the user. |
None
|
current_state
|
AppState | None
|
Current active state in the active app for the user. |
None
|
reset
|
bool
|
Whether to reset the user agent. |
True
|
Returns:
| Type | Description |
|---|---|
str | MMObservation | None
|
Result from the last agent turn execution. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If user agent is not initialized or notification system is not set. |
Source code in pare/agents/user/agent.py
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 | |
build_task_from_notifications(agent_messages)
¶
Build User Agent task from agent messages.
User messages comes from the User Agent in the form of accept/reject responses. Environment notifications are handled separately by preprocessing step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_messages
|
list[Message]
|
List of agent messages. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Task string for the User Agent. |
Source code in pare/agents/user/agent.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
get_acceptance_count()
¶
Count the number of proposal acceptances from the user.
Acceptances are identified by calls to accept_proposal tool.
Returns:
| Type | Description |
|---|---|
int
|
Number of acceptances. |
Source code in pare/agents/user/agent.py
343 344 345 346 347 348 349 350 351 352 353 354 355 | |
get_notifications()
¶
Get ENVIRONMENT_STOP notifications from the notification system.
Returns:
| Type | Description |
|---|---|
tuple[list[Message], list[Message], list[Message]]
|
Tuple of (list of agent messages, list of environment notifications, list of environment stop messages). |
Source code in pare/agents/user/agent.py
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 | |
get_read_only_actions()
¶
Count read-only actions from the user agent.
Returns:
| Type | Description |
|---|---|
int
|
Number of read-only tool calls. |
Source code in pare/agents/user/agent.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
get_write_actions()
¶
Count write actions from the user agent.
Returns:
| Type | Description |
|---|---|
int
|
Number of write tool calls. |
Source code in pare/agents/user/agent.py
372 373 374 375 376 377 378 379 380 381 382 383 384 | |
init_notification_system(notification_system)
¶
Initialize the notification system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notification_system
|
BaseNotificationSystem
|
Notification system to initialize. |
required |
Source code in pare/agents/user/agent.py
193 194 195 196 197 198 199 200 201 | |
init_system_prompt(scenario)
¶
Initialize the system prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
Scenario
|
Scenario to initialize the system prompt for. |
required |
Source code in pare/agents/user/agent.py
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 | |
init_tools(tools)
¶
Initialize the tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tools
|
list[AppTool]
|
Tools to initialize. |
required |
Source code in pare/agents/user/agent.py
128 129 130 131 132 133 134 135 136 137 138 139 | |
prepare_user_agent_run(scenario, notification_system=None, initial_agent_logs=None)
¶
Prepare the user agent run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
Scenario
|
Scenario to run the turn for. |
required |
notification_system
|
BaseNotificationSystem | None
|
Notification system to use for the agent. |
None
|
initial_agent_logs
|
list[BaseAgentLog] | None
|
Initial agent logs to use for the agent. |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
If pause and resume environment functions are not provided if simulated generation time config is set. |
Source code in pare/agents/user/agent.py
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 | |
remove_aui_irrelevant_tools(tools)
¶
Remove irrelevant tools from the tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tools
|
list[AppTool]
|
Tools to remove irrelevant tools from. |
required |
Returns:
| Type | Description |
|---|---|
list[AppTool]
|
List of tools. |
Source code in pare/agents/user/agent.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
Agent Configuration¶
PAREAgentConfig
¶
Bases: ABC
Abstract class for PARE agent configurations.
Source code in pare/agents/pare_agent_config.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
get_agent_name()
abstractmethod
¶
Get the name of the agent.
Source code in pare/agents/pare_agent_config.py
13 14 15 16 | |
get_base_agent_configs()
abstractmethod
¶
Get the base agent configurations.
Source code in pare/agents/pare_agent_config.py
23 24 25 26 | |
get_model_dump()
abstractmethod
¶
Get the model dump of the agent configuration.
Source code in pare/agents/pare_agent_config.py
18 19 20 21 | |
get_model_json_schema()
abstractmethod
¶
Get the JSON schema of the agent configuration.
Source code in pare/agents/pare_agent_config.py
28 29 30 31 | |
validate_model(agent_config_dict)
abstractmethod
¶
Validate the agent configuration model.
Source code in pare/agents/pare_agent_config.py
33 34 35 36 | |
ProactiveObserveExecuteAgentConfig
¶
Bases: BaseModel, PAREAgentConfig
Proactive agent configuration for PARE.
Source code in pare/agents/pare_agent_config.py
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 | |
get_agent_name()
¶
Get the name of the agent.
Source code in pare/agents/pare_agent_config.py
81 82 83 | |
get_base_agent_configs()
¶
Get the base agent configurations for the observe and execute agents.
Source code in pare/agents/pare_agent_config.py
85 86 87 | |
get_model_dump()
¶
Docstring for get_model_dump.
Source code in pare/agents/pare_agent_config.py
89 90 91 | |
get_model_json_schema()
¶
Docstring for get_model_json_schema.
Source code in pare/agents/pare_agent_config.py
93 94 95 | |
validate_model(agent_config_dict)
¶
Docstring for validate_model.
Source code in pare/agents/pare_agent_config.py
97 98 99 | |
UserDefaultAgentConfig
¶
Bases: BaseModel, PAREAgentConfig
User agent configuration for PARE.
Source code in pare/agents/pare_agent_config.py
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 | |
get_agent_name()
¶
Get the name of the agent.
Source code in pare/agents/pare_agent_config.py
48 49 50 | |
get_base_agent_configs()
¶
Get the base agent configurations for the user agent.
Source code in pare/agents/pare_agent_config.py
52 53 54 | |
get_model_dump()
¶
Docstring for get_model_dump.
Source code in pare/agents/pare_agent_config.py
56 57 58 | |
get_model_json_schema()
¶
Docstring for get_model_json_schema.
Source code in pare/agents/pare_agent_config.py
60 61 62 | |
validate_model(agent_config_dict)
¶
Docstring for validate_model.
Source code in pare/agents/pare_agent_config.py
64 65 66 | |
Agent Config Builder¶
AbstractAgentConfigBuilder
¶
Bases: ABC
Abstract class for building agent configs.
Source code in pare/agents/agent_config_builder.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
build(agent_name)
abstractmethod
¶
Build a config for the specified agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
Name of the agent that affects the config type. |
required |
Returns:
| Type | Description |
|---|---|
PAREAgentConfig
|
An instance of the config. |
Source code in pare/agents/agent_config_builder.py
16 17 18 19 20 21 22 23 24 25 26 27 28 | |
ProactiveAgentConfigBuilder
¶
Bases: AbstractAgentConfigBuilder
Builder for ProactiveAgentConfig.
Source code in pare/agents/agent_config_builder.py
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 | |
build(agent_name)
¶
Build the correct ProactiveAgentConfig based on the agent name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
Name of the proactive agent type. |
required |
Returns:
| Type | Description |
|---|---|
PAREAgentConfig
|
A configured ProactiveObserveExecuteAgentConfig instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the agent name is not recognized. |
Source code in pare/agents/agent_config_builder.py
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 | |
UserAgentConfigBuilder
¶
Bases: AbstractAgentConfigBuilder
Builder for UserAgentConfig.
Source code in pare/agents/agent_config_builder.py
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 | |
build(agent_name)
¶
Build the correct UserAgentConfig based on the agent name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
Name of the user agent type. |
required |
Returns:
| Type | Description |
|---|---|
PAREAgentConfig
|
A configured UserDefaultAgentConfig instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the agent name is not recognized. |
Source code in pare/agents/agent_config_builder.py
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 | |
Agent Builder¶
Agent builders for PARE agents.
This module contains builders for creating UserAgent and ProactiveAgent instances from their respective configurations.
AbstractAgentBuilder
¶
Bases: ABC
Abstract class for building PARE agents.
Source code in pare/agents/agent_builder.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 | |
build(agent_config, env=None, mock_responses=None)
abstractmethod
¶
Build an agent from config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_config
|
PAREAgentConfig
|
Configuration for the agent to be built. |
required |
env
|
StateAwareEnvironmentWrapper | None
|
Optional environment in which the agent will operate. |
None
|
mock_responses
|
list[str] | None
|
Optional list of mock responses for testing. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
An instance of the agent. |
Source code in pare/agents/agent_builder.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
list_agents()
abstractmethod
¶
List all available agent types.
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of agent names that this builder can create. |
Source code in pare/agents/agent_builder.py
25 26 27 28 29 30 31 | |
ProactiveAgentBuilder
¶
Bases: AbstractAgentBuilder
Builder for ProactiveAgent instances.
Source code in pare/agents/agent_builder.py
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 | |
__init__(llm_engine_builder=None)
¶
Initialize the ProactiveAgentBuilder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
llm_engine_builder
|
LLMEngineBuilder | None
|
Optional LLM engine builder. If not provided, a default LLMEngineBuilder will be used. |
None
|
Source code in pare/agents/agent_builder.py
125 126 127 128 129 130 131 132 | |
build(agent_config, env=None, mock_responses=None)
¶
Build a ProactiveAgent from config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_config
|
PAREAgentConfig
|
Configuration for the proactive agent. Must be a ProactiveObserveExecuteAgentConfig. |
required |
env
|
StateAwareEnvironmentWrapper | None
|
Environment in which the agent will operate. |
None
|
mock_responses
|
list[str] | None
|
Optional list of mock responses for testing. |
None
|
Returns:
| Type | Description |
|---|---|
ProactiveAgent
|
A configured ProactiveAgent instance. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If agent_config is not a ProactiveObserveExecuteAgentConfig. |
ValueError
|
If the agent name is not supported or required environment components are missing. |
Source code in pare/agents/agent_builder.py
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 | |
list_agents()
¶
List all available proactive agent types.
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of proactive agent names that this builder can create. |
Source code in pare/agents/agent_builder.py
134 135 136 137 138 139 140 | |
UserAgentBuilder
¶
Bases: AbstractAgentBuilder
Builder for UserAgent instances.
Source code in pare/agents/agent_builder.py
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 | |
__init__(llm_engine_builder=None)
¶
Initialize the UserAgentBuilder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
llm_engine_builder
|
LLMEngineBuilder | None
|
Optional LLM engine builder. If not provided, a default LLMEngineBuilder will be used. |
None
|
Source code in pare/agents/agent_builder.py
55 56 57 58 59 60 61 62 | |
build(agent_config, env=None, mock_responses=None)
¶
Build a UserAgent from config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_config
|
PAREAgentConfig
|
Configuration for the user agent. Must be a UserAgentConfig. |
required |
env
|
StateAwareEnvironmentWrapper | None
|
Environment in which the agent will operate. |
None
|
mock_responses
|
list[str] | None
|
Optional list of mock responses for testing. |
None
|
Returns:
| Type | Description |
|---|---|
UserAgent
|
A configured UserAgent instance. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If agent_config is not a UserDefaultAgentConfig. |
ValueError
|
If the agent name is not supported or required environment components are missing. |
Source code in pare/agents/agent_builder.py
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 | |
list_agents()
¶
List all available user agent types.
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of user agent names that this builder can create. |
Source code in pare/agents/agent_builder.py
64 65 66 67 68 69 70 | |
Agent Factory¶
Factory functions for creating PARE agents.
This module contains factory functions that create BaseAgent instances with the appropriate prompts, presteps, and configurations, then wrap them in UserAgent or ProactiveAgent wrappers.
create_default_user_agent(agent_config, env, llm_engine)
¶
Create a default UserAgent with the given configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_config
|
UserDefaultAgentConfig
|
Configuration for the user agent. |
required |
env
|
StateAwareEnvironmentWrapper
|
Environment in which the agent will operate. |
required |
llm_engine
|
LLMEngine
|
Pre-built LLM engine for the agent. |
required |
Returns:
| Type | Description |
|---|---|
UserAgent
|
A configured UserAgent instance. |
Source code in pare/agents/agent_factory.py
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 | |
create_observe_execute_proactive_agent(agent_config, env, observe_llm_engine, execute_llm_engine)
¶
Create an observe-execute ProactiveAgent with the given configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_config
|
ProactiveObserveExecuteAgentConfig
|
Configuration for the proactive agent. |
required |
env
|
StateAwareEnvironmentWrapper
|
Environment in which the agent will operate. |
required |
observe_llm_engine
|
LLMEngine
|
Pre-built LLM engine for the observe agent. |
required |
execute_llm_engine
|
LLMEngine
|
Pre-built LLM engine for the execute agent. |
required |
Returns:
| Type | Description |
|---|---|
ProactiveAgent
|
A configured ProactiveAgent instance. |
Source code in pare/agents/agent_factory.py
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 | |
Agent Log Types¶
PARE-specific agent log types.
AgentMessageLog
dataclass
¶
Bases: BaseAgentLog
Log entry for messages from ProactiveAgent to UserAgent.
Used by UserAgent preprocessing to store AGENT_MESSAGE notifications. These are proposals/messages sent via send_message_to_user tool.
Source code in pare/agents/agent_log.py
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 | |
get_attachments_for_llm()
¶
Return attachments for LLM.
Source code in pare/agents/agent_log.py
121 122 123 | |
get_content_for_llm()
¶
Return content to be sent to LLM.
Source code in pare/agents/agent_log.py
112 113 114 | |
get_content_for_llm_no_attachment()
¶
Return content without attachment placeholders.
Source code in pare/agents/agent_log.py
116 117 118 119 | |
get_type()
¶
Return log type identifier.
Source code in pare/agents/agent_log.py
125 126 127 | |
AvailableToolsLog
dataclass
¶
Bases: BaseAgentLog
Log entry for all available tools for user agent at the current state.
Used by UserAgent preprocessing to store AVAILABLE_TOOLS notifications. These are tools that are available to the user agent at the current state.
Source code in pare/agents/agent_log.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
get_content_for_llm()
¶
Return content to be sent to LLM.
Source code in pare/agents/agent_log.py
140 141 142 | |
get_type()
¶
Return log type identifier.
Source code in pare/agents/agent_log.py
144 145 146 | |
CurrentAppStateLog
dataclass
¶
Bases: BaseAgentLog
Log entry for the current app state for user agent at the current state.
Used by UserAgent preprocessing to store CURRENT_APP_STATE notifications. These are the current state of the app at the current state.
Source code in pare/agents/agent_log.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
get_content_for_llm()
¶
Return content to be sent to LLM.
Source code in pare/agents/agent_log.py
178 179 180 | |
get_type()
¶
Return log type identifier.
Source code in pare/agents/agent_log.py
182 183 184 | |
PAREAgentLog
dataclass
¶
Bases: BaseAgentLog
Base class for all PARE Agent Logs.
Source code in pare/agents/agent_log.py
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 | |
from_dict(d)
classmethod
¶
Create a PAREAgentLog from a dictionary.
Source code in pare/agents/agent_log.py
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 | |
UserActionLog
dataclass
¶
Bases: BaseAgentLog
Log entry for user actions observed by the proactive agent.
Each log represents a list of user actions since the last step. Multiple logs accumulate in the agent history to show full action sequence.
Source code in pare/agents/agent_log.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
get_content_for_llm()
¶
Return content to be sent to LLM.
Source code in pare/agents/agent_log.py
159 160 161 | |
get_type()
¶
Return log type identifier.
Source code in pare/agents/agent_log.py
163 164 165 | |