delegation
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
AgentPool llmling_agent.delegation.pool Pool managing message processing nodes (agents and teams). |
||
BaseTeam llmling_agent.delegation.base_team Base class for Team and TeamRun. |
||
Team llmling_agent.delegation.team Group of agents that can execute together. |
||
TeamRun llmling_agent.delegation.teamrun Handles team operations with monitoring. |
🛈 DocStrings¶
Agent delegation and collaboration functionality.
AgentPool
¶
Bases: BaseRegistry[NodeName, MessageEmitter[Any, Any]]
Pool managing message processing nodes (agents and teams).
Acts as a unified registry for all nodes, providing: - Centralized node management and lookup - Shared dependency injection - Connection management - Resource coordination
Nodes can be accessed through: - nodes: All registered nodes (agents and teams) - agents: Only Agent instances - teams: Only Team instances
Source code in src/llmling_agent/delegation/pool.py
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 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 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 |
|
event_nodes
property
¶
Get agents dict (backward compatibility).
__aenter__
async
¶
__aenter__() -> Self
Enter async context and initialize all agents.
Source code in src/llmling_agent/delegation/pool.py
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 |
|
__aexit__
async
¶
__aexit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
)
Exit async context.
Source code in src/llmling_agent/delegation/pool.py
189 190 191 192 193 194 195 196 197 198 199 200 |
|
__init__
¶
__init__(
manifest: StrPath | AgentsManifest | None = None,
*,
shared_deps: TPoolDeps | None = None,
connect_nodes: bool = True,
input_provider: InputProvider | None = None,
parallel_load: bool = True,
)
Initialize agent pool with immediate agent creation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
manifest
|
StrPath | AgentsManifest | None
|
Agent configuration manifest |
None
|
shared_deps
|
TPoolDeps | None
|
Dependencies to share across all nodes |
None
|
connect_nodes
|
bool
|
Whether to set up forwarding connections |
True
|
input_provider
|
InputProvider | None
|
Input provider for tool / step confirmations / HumanAgents |
None
|
parallel_load
|
bool
|
Whether to load nodes in parallel (async) |
True
|
Raises:
Type | Description |
---|---|
ValueError
|
If manifest contains invalid node configurations |
RuntimeError
|
If node initialization fails |
Source code in src/llmling_agent/delegation/pool.py
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 |
|
_connect_nodes
¶
_connect_nodes()
Set up connections defined in manifest.
Source code in src/llmling_agent/delegation/pool.py
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 |
|
_create_teams
¶
_create_teams()
Create all teams in two phases to allow nesting.
Source code in src/llmling_agent/delegation/pool.py
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 |
|
_validate_item
¶
_validate_item(item: MessageEmitter[Any, Any] | Any) -> MessageEmitter[Any, Any]
Validate and convert items before registration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
MessageEmitter[Any, Any] | Any
|
Item to validate |
required |
Returns:
Type | Description |
---|---|
MessageEmitter[Any, Any]
|
Validated Node |
Raises:
Type | Description |
---|---|
LLMlingError
|
If item is not a valid node |
Source code in src/llmling_agent/delegation/pool.py
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
|
add_agent
async
¶
add_agent(
name: AgentName, *, result_type: None = None, **kwargs: Unpack[AgentKwargs]
) -> Agent[Any]
add_agent(
name: AgentName,
*,
result_type: type[TResult] | str | ResponseDefinition,
**kwargs: Unpack[AgentKwargs],
) -> StructuredAgent[Any, TResult]
add_agent(
name: AgentName,
*,
result_type: type[Any] | str | ResponseDefinition | None = None,
**kwargs: Unpack[AgentKwargs],
) -> Agent[Any] | StructuredAgent[Any, Any]
Add a new permanent agent to the pool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
AgentName
|
Name for the new agent |
required |
result_type
|
type[Any] | str | ResponseDefinition | None
|
Optional type for structured responses: - None: Regular unstructured agent - type: Python type for validation - str: Name of response definition - ResponseDefinition: Complete response definition |
None
|
**kwargs
|
Unpack[AgentKwargs]
|
Additional agent configuration |
{}
|
Returns:
Type | Description |
---|---|
Agent[Any] | StructuredAgent[Any, Any]
|
Either a regular Agent or StructuredAgent depending on result_type |
Source code in src/llmling_agent/delegation/pool.py
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 |
|
cleanup
async
¶
cleanup()
Clean up all agents.
Source code in src/llmling_agent/delegation/pool.py
202 203 204 205 |
|
clone_agent
async
¶
clone_agent(
agent: AgentName | Agent[TDeps],
new_name: AgentName | None = None,
*,
system_prompts: list[str] | None = None,
template_context: dict[str, Any] | None = None,
) -> Agent[TDeps]
clone_agent(
agent: StructuredAgent[TDeps, TResult],
new_name: AgentName | None = None,
*,
system_prompts: list[str] | None = None,
template_context: dict[str, Any] | None = None,
) -> StructuredAgent[TDeps, TResult]
clone_agent(
agent: AgentName | AnyAgent[TDeps, TAgentResult],
new_name: AgentName | None = None,
*,
system_prompts: list[str] | None = None,
template_context: dict[str, Any] | None = None,
) -> AnyAgent[TDeps, TAgentResult]
Create a copy of an agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent
|
AgentName | AnyAgent[TDeps, TAgentResult]
|
Agent instance or name to clone |
required |
new_name
|
AgentName | None
|
Optional name for the clone |
None
|
system_prompts
|
list[str] | None
|
Optional different prompts |
None
|
template_context
|
dict[str, Any] | None
|
Variables for template rendering |
None
|
Returns:
Type | Description |
---|---|
AnyAgent[TDeps, TAgentResult]
|
The new agent instance |
Source code in src/llmling_agent/delegation/pool.py
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 |
|
create_agent
async
¶
create_agent(
name: AgentName,
*,
session: SessionIdType | SessionQuery = None,
name_override: str | None = None,
) -> Agent[TPoolDeps]
create_agent(
name: AgentName,
*,
deps: TCustomDeps,
session: SessionIdType | SessionQuery = None,
name_override: str | None = None,
) -> Agent[TCustomDeps]
create_agent(
name: AgentName,
*,
return_type: type[TResult],
session: SessionIdType | SessionQuery = None,
name_override: str | None = None,
) -> StructuredAgent[TPoolDeps, TResult]
create_agent(
name: AgentName,
*,
deps: TCustomDeps,
return_type: type[TResult],
session: SessionIdType | SessionQuery = None,
name_override: str | None = None,
) -> StructuredAgent[TCustomDeps, TResult]
create_agent(
name: AgentName,
*,
deps: Any | None = None,
return_type: Any | None = None,
session: SessionIdType | SessionQuery = None,
name_override: str | None = None,
) -> AnyAgent[Any, Any]
Create a new agent instance from configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
AgentName
|
Name of the agent configuration to use |
required |
deps
|
Any | None
|
Optional custom dependencies (overrides pool deps) |
None
|
return_type
|
Any | None
|
Optional type for structured responses |
None
|
session
|
SessionIdType | SessionQuery
|
Optional session ID or query to recover conversation |
None
|
name_override
|
str | None
|
Optional different name for this instance |
None
|
Returns:
Type | Description |
---|---|
AnyAgent[Any, Any]
|
New agent instance with the specified configuration |
Raises:
Type | Description |
---|---|
KeyError
|
If agent configuration not found |
ValueError
|
If configuration is invalid |
Source code in src/llmling_agent/delegation/pool.py
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
|
create_team
¶
create_team(
agents: Sequence[AgentName | MessageNode[Any, Any]] | None = None,
*,
name: str | None = None,
description: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
pick_prompt: str | None = None,
) -> Team[Any]
Create a group from agent names or instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agents
|
Sequence[AgentName | MessageNode[Any, Any]] | None
|
List of agent names or instances (all if None) |
None
|
name
|
str | None
|
Optional name for the team |
None
|
description
|
str | None
|
Optional description for the team |
None
|
shared_prompt
|
str | None
|
Optional prompt for all agents |
None
|
picker
|
AnyAgent[Any, Any] | None
|
Agent to use for picking agents |
None
|
num_picks
|
int | None
|
Number of agents to pick |
None
|
pick_prompt
|
str | None
|
Prompt to use for picking agents |
None
|
Source code in src/llmling_agent/delegation/pool.py
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 |
|
create_team_run
¶
create_team_run(
agents: Sequence[str],
validator: MessageNode[Any, TResult] | None = None,
*,
name: str | None = None,
description: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
pick_prompt: str | None = None,
) -> TeamRun[TPoolDeps, TResult]
create_team_run(
agents: Sequence[MessageNode[TDeps, Any]],
validator: MessageNode[Any, TResult] | None = None,
*,
name: str | None = None,
description: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
pick_prompt: str | None = None,
) -> TeamRun[TDeps, TResult]
create_team_run(
agents: Sequence[AgentName | MessageNode[Any, Any]],
validator: MessageNode[Any, TResult] | None = None,
*,
name: str | None = None,
description: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
pick_prompt: str | None = None,
) -> TeamRun[Any, TResult]
create_team_run(
agents: Sequence[AgentName | MessageNode[Any, Any]] | None = None,
validator: MessageNode[Any, TResult] | None = None,
*,
name: str | None = None,
description: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
pick_prompt: str | None = None,
) -> TeamRun[Any, TResult]
Create a a sequential TeamRun from a list of Agents.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agents
|
Sequence[AgentName | MessageNode[Any, Any]] | None
|
List of agent names or team/agent instances (all if None) |
None
|
validator
|
MessageNode[Any, TResult] | None
|
Node to validate the results of the TeamRun |
None
|
name
|
str | None
|
Optional name for the team |
None
|
description
|
str | None
|
Optional description for the team |
None
|
shared_prompt
|
str | None
|
Optional prompt for all agents |
None
|
picker
|
AnyAgent[Any, Any] | None
|
Agent to use for picking agents |
None
|
num_picks
|
int | None
|
Number of agents to pick |
None
|
pick_prompt
|
str | None
|
Prompt to use for picking agents |
None
|
Source code in src/llmling_agent/delegation/pool.py
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 |
|
get_agent
¶
get_agent(
agent: AgentName | Agent[Any],
*,
model_override: str | None = None,
session: SessionIdType | SessionQuery = None,
) -> Agent[TPoolDeps]
get_agent(
agent: AgentName | Agent[Any],
*,
return_type: type[TResult],
model_override: str | None = None,
session: SessionIdType | SessionQuery = None,
) -> StructuredAgent[TPoolDeps, TResult]
get_agent(
agent: AgentName | Agent[Any],
*,
deps: TCustomDeps,
model_override: str | None = None,
session: SessionIdType | SessionQuery = None,
) -> Agent[TCustomDeps]
get_agent(
agent: AgentName | Agent[Any],
*,
deps: TCustomDeps,
return_type: type[TResult],
model_override: str | None = None,
session: SessionIdType | SessionQuery = None,
) -> StructuredAgent[TCustomDeps, TResult]
get_agent(
agent: AgentName | Agent[Any],
*,
deps: Any | None = None,
return_type: Any | None = None,
model_override: str | None = None,
session: SessionIdType | SessionQuery = None,
) -> AnyAgent[Any, Any]
Get or configure an agent from the pool.
This method provides flexible agent configuration with dependency injection: - Without deps: Agent uses pool's shared dependencies - With deps: Agent uses provided custom dependencies - With return_type: Returns a StructuredAgent with type validation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent
|
AgentName | Agent[Any]
|
Either agent name or instance |
required |
deps
|
Any | None
|
Optional custom dependencies (overrides shared deps) |
None
|
return_type
|
Any | None
|
Optional type for structured responses |
None
|
model_override
|
str | None
|
Optional model override |
None
|
session
|
SessionIdType | SessionQuery
|
Optional session ID or query to recover conversation |
None
|
Returns:
Name | Type | Description |
---|---|---|
Either |
AnyAgent[Any, Any]
|
|
AnyAgent[Any, Any]
|
|
|
AnyAgent[Any, Any]
|
|
|
AnyAgent[Any, Any]
|
|
Raises:
Type | Description |
---|---|
KeyError
|
If agent name not found |
ValueError
|
If configuration is invalid |
Source code in src/llmling_agent/delegation/pool.py
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 |
|
get_mermaid_diagram
¶
Generate mermaid flowchart of all agents and their connections.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include_details
|
bool
|
Whether to show connection details (types, queues, etc) |
True
|
Source code in src/llmling_agent/delegation/pool.py
892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 |
|
list_nodes
¶
List available agent names.
Source code in src/llmling_agent/delegation/pool.py
832 833 834 |
|
run_event_loop
async
¶
run_event_loop()
Run pool in event-watching mode until interrupted.
Source code in src/llmling_agent/delegation/pool.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
|
setup_agent_workers
¶
Set up workers for an agent from configuration.
Source code in src/llmling_agent/delegation/pool.py
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 |
|
track_message_flow
async
¶
track_message_flow() -> AsyncIterator[MessageFlowTracker]
Track message flow during a context.
Source code in src/llmling_agent/delegation/pool.py
374 375 376 377 378 379 380 381 382 |
|
BaseTeam
¶
Bases: MessageNode[TDeps, TResult]
Base class for Team and TeamRun.
Source code in src/llmling_agent/delegation/base_team.py
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 |
|
context
property
writable
¶
context: TeamContext
Get shared pool from team members.
Raises:
Type | Description |
---|---|
ValueError
|
If team members belong to different pools |
__and__
¶
Combine teams, preserving type safety for same types.
Source code in src/llmling_agent/delegation/base_team.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
__getitem__
¶
__getitem__(index_or_name: int | str) -> MessageNode[TDeps, TResult]
Get team member by index or name.
Source code in src/llmling_agent/delegation/base_team.py
192 193 194 195 196 |
|
__init__
¶
__init__(
agents: Sequence[MessageNode[TDeps, TResult]],
*,
name: str | None = None,
description: str | None = None,
shared_prompt: str | None = None,
mcp_servers: list[str | MCPServerConfig] | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
pick_prompt: str | None = None,
)
Common variables only for typing.
Source code in src/llmling_agent/delegation/base_team.py
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 |
|
__iter__
¶
__iter__() -> Iterator[MessageNode[TDeps, TResult]]
Iterate over team members.
Source code in src/llmling_agent/delegation/base_team.py
188 189 190 |
|
__len__
¶
__len__() -> int
Get number of team members.
Source code in src/llmling_agent/delegation/base_team.py
184 185 186 |
|
__or__
¶
__or__(
other: AnyAgent[Any, Any] | ProcessorCallback[Any] | BaseTeam[Any, Any],
) -> TeamRun[Any, Any]
Create a sequential pipeline.
Source code in src/llmling_agent/delegation/base_team.py
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 |
|
__repr__
¶
__repr__() -> str
Create readable representation.
Source code in src/llmling_agent/delegation/base_team.py
178 179 180 181 182 |
|
_on_node_added
¶
_on_node_added(index: int, node: MessageNode[Any, Any])
Handler for adding nodes to the team.
Source code in src/llmling_agent/delegation/base_team.py
159 160 161 162 163 164 |
|
_on_node_changed
¶
_on_node_changed(index: int, old: MessageNode, new: MessageNode)
Handle node replacement in the agents list.
Source code in src/llmling_agent/delegation/base_team.py
154 155 156 157 |
|
_on_node_removed
¶
_on_node_removed(index: int, node: MessageNode[Any, Any])
Handler for removing nodes from the team.
Source code in src/llmling_agent/delegation/base_team.py
170 171 172 173 174 175 |
|
cancel
async
¶
cancel()
Cancel execution and cleanup.
Source code in src/llmling_agent/delegation/base_team.py
350 351 352 353 354 |
|
distribute
async
¶
distribute(
content: str,
*,
tools: list[str] | None = None,
resources: list[str] | None = None,
metadata: dict[str, Any] | None = None,
)
Distribute content and capabilities to all team members.
Source code in src/llmling_agent/delegation/base_team.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
|
get_structure_diagram
¶
get_structure_diagram() -> str
Generate mermaid flowchart of node hierarchy.
Source code in src/llmling_agent/delegation/base_team.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
|
is_busy
¶
is_busy() -> bool
Check if team is processing any tasks.
Source code in src/llmling_agent/delegation/base_team.py
271 272 273 |
|
iter_agents
¶
Recursively iterate over all child agents.
Source code in src/llmling_agent/delegation/base_team.py
380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
pick_agents
async
¶
pick_agents(task: str) -> Sequence[MessageNode[Any, Any]]
Pick agents to run.
Source code in src/llmling_agent/delegation/base_team.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
run_in_background
async
¶
run_in_background(
*prompts: AnyPromptType | Image | PathLike[str] | None,
max_count: int | None = 1,
interval: float = 1.0,
**kwargs: Any,
) -> ExtendedTeamTalk
Start execution in background.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompts
|
AnyPromptType | Image | PathLike[str] | None
|
Prompts to execute |
()
|
max_count
|
int | None
|
Maximum number of executions (None = run indefinitely) |
1
|
interval
|
float
|
Seconds between executions |
1.0
|
**kwargs
|
Any
|
Additional args for execute() |
{}
|
Source code in src/llmling_agent/delegation/base_team.py
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 |
|
run_sync
¶
run_sync(
*prompt: AnyPromptType | Image | PathLike[str], store_history: bool = True
) -> ChatMessage[TResult]
Run agent synchronously (convenience wrapper).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
AnyPromptType | Image | PathLike[str]
|
User query or instruction |
()
|
store_history
|
bool
|
Whether the message exchange should be added to the context window |
True
|
Returns: Result containing response and run information
Source code in src/llmling_agent/delegation/base_team.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
|
stop
async
¶
stop()
Stop background execution if running.
Source code in src/llmling_agent/delegation/base_team.py
275 276 277 278 279 280 281 |
|
temporary_state
async
¶
temporary_state(
*,
system_prompts: list[AnyPromptType] | None = None,
replace_prompts: bool = False,
tools: list[ToolType] | None = None,
replace_tools: bool = False,
history: list[AnyPromptType] | SessionQuery | None = None,
replace_history: bool = False,
pause_routing: bool = False,
model: ModelType | None = None,
provider: AgentProvider | None = None,
) -> AsyncIterator[Self]
Temporarily modify state of all agents in the team.
All agents in the team will enter their temporary state simultaneously.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
system_prompts
|
list[AnyPromptType] | None
|
Temporary system prompts to use |
None
|
replace_prompts
|
bool
|
Whether to replace existing prompts |
False
|
tools
|
list[ToolType] | None
|
Temporary tools to make available |
None
|
replace_tools
|
bool
|
Whether to replace existing tools |
False
|
history
|
list[AnyPromptType] | SessionQuery | None
|
Conversation history (prompts or query) |
None
|
replace_history
|
bool
|
Whether to replace existing history |
False
|
pause_routing
|
bool
|
Whether to pause message routing |
False
|
model
|
ModelType | None
|
Temporary model override |
None
|
provider
|
AgentProvider | None
|
Temporary provider override |
None
|
Source code in src/llmling_agent/delegation/base_team.py
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 |
|
to_tool
¶
Create a tool from this agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str | None
|
Optional tool name override |
None
|
description
|
str | None
|
Optional tool description override |
None
|
Source code in src/llmling_agent/delegation/base_team.py
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 |
|
wait
async
¶
wait() -> ChatMessage[Any] | None
Wait for background execution to complete and return last message.
Source code in src/llmling_agent/delegation/base_team.py
283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
Team
¶
Group of agents that can execute together.
Source code in src/llmling_agent/delegation/team.py
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 |
|
__prompt__
¶
__prompt__() -> str
Format team info for prompts.
Source code in src/llmling_agent/delegation/team.py
90 91 92 93 94 |
|
_run
async
¶
_run(
*prompts: AnyPromptType | Image | PathLike[str] | None,
wait_for_connections: bool | None = None,
message_id: str | None = None,
conversation_id: str | None = None,
**kwargs: Any,
) -> ChatMessage[list[Any]]
Run all agents in parallel and return combined message.
Source code in src/llmling_agent/delegation/team.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
execute
async
¶
execute(
*prompts: AnyPromptType | Image | PathLike[str] | None, **kwargs: Any
) -> TeamResponse
Run all agents in parallel with monitoring.
Source code in src/llmling_agent/delegation/team.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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
run_iter
async
¶
run_iter(*prompts: AnyPromptType, **kwargs: Any) -> AsyncIterator[ChatMessage[Any]]
Yield messages as they arrive from parallel execution.
Source code in src/llmling_agent/delegation/team.py
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 |
|
run_job
async
¶
run_job(
job: Job[TDeps, TJobResult],
*,
store_history: bool = True,
include_agent_tools: bool = True,
) -> list[AgentResponse[TJobResult]]
Execute a job across all team members in parallel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job
|
Job[TDeps, TJobResult]
|
Job configuration to execute |
required |
store_history
|
bool
|
Whether to add job execution to conversation history |
True
|
include_agent_tools
|
bool
|
Whether to include agent's tools alongside job tools |
True
|
Returns:
Type | Description |
---|---|
list[AgentResponse[TJobResult]]
|
List of responses from all agents |
Raises:
Type | Description |
---|---|
JobError
|
If job execution fails for any agent |
ValueError
|
If job configuration is invalid |
Source code in src/llmling_agent/delegation/team.py
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 |
|
TeamRun
¶
Bases: BaseTeam[TDeps, TResult]
Handles team operations with monitoring.
Source code in src/llmling_agent/delegation/teamrun.py
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 |
|
__prompt__
¶
__prompt__() -> str
Format team info for prompts.
Source code in src/llmling_agent/delegation/teamrun.py
88 89 90 91 92 |
|
_run
async
¶
_run(
*prompts: AnyPromptType | Image | PathLike[str] | None,
wait_for_connections: bool | None = None,
message_id: str | None = None,
conversation_id: str | None = None,
**kwargs: Any,
) -> ChatMessage[TResult]
Run agents sequentially and return combined message.
This message wraps execute and extracts the ChatMessage in order to fulfill the "message protocol".
Source code in src/llmling_agent/delegation/teamrun.py
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 |
|
chain_stream
async
¶
chain_stream(
*prompts: AnyPromptType | Image | PathLike[str] | None,
require_all: bool = True,
**kwargs: Any,
) -> AsyncIterator[StreamingResponseProtocol]
Stream results through chain of team members.
Source code in src/llmling_agent/delegation/teamrun.py
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 |
|
execute
async
¶
execute(
*prompts: AnyPromptType | Image | PathLike[str] | None, **kwargs: Any
) -> TeamResponse[TResult]
Start execution with optional monitoring.
Source code in src/llmling_agent/delegation/teamrun.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
run_iter
async
¶
run_iter(
*prompts: AnyPromptType | Image | PathLike[str], **kwargs: Any
) -> AsyncIterator[ChatMessage[Any]]
Yield messages from the execution chain.
Source code in src/llmling_agent/delegation/teamrun.py
155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
run_stream
async
¶
run_stream(
*prompts: AnyPromptType | Image | PathLike[str], **kwargs: Any
) -> AsyncIterator[StreamingResponseProtocol[TResult]]
Stream responses through the chain.
Provides same interface as Agent.run_stream.
Source code in src/llmling_agent/delegation/teamrun.py
300 301 302 303 304 305 306 307 308 309 310 311 |
|