llmling_agent
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
Agent llmling_agent.agent.agent Agent for AI-powered interaction with LLMling resources and tools. |
||
AgentConfig llmling_agent.models.agents Configuration for a single agent in the system. |
||
AgentContext llmling_agent.agent.context Runtime context for agent execution. |
||
AgentPool llmling_agent.delegation.pool Pool managing message processing nodes (agents and teams). |
||
AgentsManifest llmling_agent.models.manifest Complete agent configuration manifest defining all available agents. |
||
ChatMessage llmling_agent.messaging.messages Common message format for all UI types. |
||
StructuredAgent llmling_agent.agent.structured Wrapper for Agent that enforces a specific result type. |
||
Team llmling_agent.delegation.team Group of agents that can execute together. |
||
TeamRun llmling_agent.delegation.teamrun Handles team operations with monitoring. |
||
ToolInfo llmling_agent.tools.base Information about a registered tool. |
🛈 DocStrings¶
Agent configuration and creation.
Agent
¶
Bases: MessageNode[TDeps, str]
, TaskManagerMixin
Agent for AI-powered interaction with LLMling resources and tools.
Generically typed with: LLMLingAgent[Type of Dependencies, Type of Result]
This agent integrates LLMling's resource system with PydanticAI's agent capabilities. It provides: - Access to resources through RuntimeConfig - Tool registration for resource operations - System prompt customization - Signals - Message history management - Database logging
Source code in src/llmling_agent/agent/agent.py
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 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 |
|
AgentReset
dataclass
¶
Emitted when agent is reset.
Source code in src/llmling_agent/agent/agent.py
132 133 134 135 136 137 138 139 |
|
__aenter__
async
¶
__aenter__() -> Self
Enter async context and set up MCP servers.
Source code in src/llmling_agent/agent/agent.py
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 |
|
__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/agent/agent.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
|
__and__
¶
__and__(other: Agent[TDeps] | StructuredAgent[TDeps, Any]) -> Team[TDeps]
Create agent group using | operator.
Example
group = analyzer & planner & executor # Create group of 3 group = analyzer & existing_group # Add to existing group
Source code in src/llmling_agent/agent/agent.py
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 |
|
__init__
¶
__init__(
name: str = "llmling-agent",
provider: AgentType = "pydantic_ai",
*,
model: ModelType = None,
runtime: RuntimeConfig | Config | StrPath | None = None,
context: AgentContext[TDeps] | None = None,
session: SessionIdType | SessionQuery | MemoryConfig | bool | int = None,
system_prompt: AnyPromptType | Sequence[AnyPromptType] = (),
description: str | None = None,
tools: Sequence[ToolType] | None = None,
capabilities: Capabilities | None = None,
mcp_servers: Sequence[str | MCPServerConfig] | None = None,
resources: Sequence[Resource | PromptType | str] = (),
retries: int = 1,
result_retries: int | None = None,
end_strategy: EndStrategy = "early",
defer_model_check: bool = False,
input_provider: InputProvider | None = None,
parallel_init: bool = True,
debug: bool = False,
)
Initialize agent with runtime configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
runtime
|
RuntimeConfig | Config | StrPath | None
|
Runtime configuration providing access to resources/tools |
None
|
context
|
AgentContext[TDeps] | None
|
Agent context with capabilities and configuration |
None
|
provider
|
AgentType
|
Agent type to use (ai: PydanticAIProvider, human: HumanProvider) |
'pydantic_ai'
|
session
|
SessionIdType | SessionQuery | MemoryConfig | bool | int
|
Memory configuration. - None: Default memory config - False: Disable message history (max_messages=0) - int: Max tokens for memory - str/UUID: Session identifier - SessionQuery: Query to recover conversation - MemoryConfig: Complete memory configuration |
None
|
model
|
ModelType
|
The default model to use (defaults to GPT-4) |
None
|
system_prompt
|
AnyPromptType | Sequence[AnyPromptType]
|
Static system prompts to use for this agent |
()
|
name
|
str
|
Name of the agent for logging |
'llmling-agent'
|
description
|
str | None
|
Description of the Agent ("what it can do") |
None
|
tools
|
Sequence[ToolType] | None
|
List of tools to register with the agent |
None
|
capabilities
|
Capabilities | None
|
Capabilities for the agent |
None
|
mcp_servers
|
Sequence[str | MCPServerConfig] | None
|
MCP servers to connect to |
None
|
resources
|
Sequence[Resource | PromptType | str]
|
Additional resources to load |
()
|
retries
|
int
|
Default number of retries for failed operations |
1
|
result_retries
|
int | None
|
Max retries for result validation (defaults to retries) |
None
|
end_strategy
|
EndStrategy
|
Strategy for handling tool calls that are requested alongside a final result |
'early'
|
defer_model_check
|
bool
|
Whether to defer model evaluation until first run |
False
|
input_provider
|
InputProvider | None
|
Provider for human input (tool confirmation / HumanProviders) |
None
|
parallel_init
|
bool
|
Whether to initialize resources in parallel |
True
|
debug
|
bool
|
Whether to enable debug mode |
False
|
Source code in src/llmling_agent/agent/agent.py
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 |
|
_run
async
¶
_run(
*prompts: AnyPromptType | Image | PathLike[str] | ChatMessage[Any],
result_type: type[TResult] | None = None,
model: ModelType = None,
store_history: bool = True,
tool_choice: bool | str | list[str] = True,
usage_limits: UsageLimits | None = None,
message_id: str | None = None,
conversation_id: str | None = None,
wait_for_connections: bool | None = None,
) -> ChatMessage[TResult]
Run agent with prompt and get response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompts
|
AnyPromptType | Image | PathLike[str] | ChatMessage[Any]
|
User query or instruction |
()
|
result_type
|
type[TResult] | None
|
Optional type for structured responses |
None
|
model
|
ModelType
|
Optional model override |
None
|
store_history
|
bool
|
Whether the message exchange should be added to the context window |
True
|
tool_choice
|
bool | str | list[str]
|
Control tool usage: - True: Allow all tools - False: No tools - str: Use specific tool - list[str]: Allow specific tools |
True
|
usage_limits
|
UsageLimits | None
|
Optional usage limits for the model |
None
|
message_id
|
str | None
|
Optional message id for the returned message. Automatically generated if not provided. |
None
|
conversation_id
|
str | None
|
Optional conversation id for the returned message. |
None
|
wait_for_connections
|
bool | None
|
Whether to wait for connected agents to complete |
None
|
Returns:
Type | Description |
---|---|
ChatMessage[TResult]
|
Result containing response and run information |
Raises:
Type | Description |
---|---|
UnexpectedModelBehavior
|
If the model fails or behaves unexpectedly |
Source code in src/llmling_agent/agent/agent.py
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 |
|
clear_history
¶
clear_history()
Clear both internal and pydantic-ai history.
Source code in src/llmling_agent/agent/agent.py
1089 1090 1091 1092 1093 |
|
from_callback
classmethod
¶
from_callback(
callback: ProcessorCallback[str],
*,
name: str | None = None,
debug: bool = False,
**kwargs: Any,
) -> Agent[None]
Create an agent from a processing callback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback
|
ProcessorCallback[str]
|
Function to process messages. Can be: - sync or async - with or without context - must return str for pipeline compatibility |
required |
name
|
str | None
|
Optional name for the agent |
None
|
debug
|
bool
|
Whether to enable debug mode |
False
|
kwargs
|
Any
|
Additional arguments for agent |
{}
|
Source code in src/llmling_agent/agent/agent.py
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 |
|
is_busy
¶
is_busy() -> bool
Check if agent is currently processing tasks.
Source code in src/llmling_agent/agent/agent.py
635 636 637 |
|
register_worker
¶
register_worker(
worker: AnyAgent[Any, Any],
*,
name: str | None = None,
reset_history_on_run: bool = True,
pass_message_history: bool = False,
share_context: bool = False,
) -> ToolInfo
Register another agent as a worker tool.
Source code in src/llmling_agent/agent/agent.py
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 |
|
reset
async
¶
reset()
Reset agent state (conversation history and tool states).
Source code in src/llmling_agent/agent/agent.py
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 |
|
run_in_background
async
¶
run_in_background(
*prompt: AnyPromptType | Image | PathLike[str],
max_count: int | None = None,
interval: float = 1.0,
block: bool = False,
**kwargs: Any,
) -> ChatMessage[TResult] | None
Run agent continuously in background with prompt or dynamic prompt function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
AnyPromptType | Image | PathLike[str]
|
Static prompt or function that generates prompts |
()
|
max_count
|
int | None
|
Maximum number of runs (None = infinite) |
None
|
interval
|
float
|
Seconds between runs |
1.0
|
block
|
bool
|
Whether to block until completion |
False
|
**kwargs
|
Any
|
Arguments passed to run() |
{}
|
Source code in src/llmling_agent/agent/agent.py
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 |
|
run_iter
async
¶
run_iter(
*prompt_groups: Sequence[AnyPromptType | Image | PathLike[str]],
result_type: type[TResult] | None = None,
model: ModelType = None,
store_history: bool = True,
wait_for_connections: bool | None = None,
) -> AsyncIterator[ChatMessage[TResult]]
Run agent sequentially on multiple prompt groups.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt_groups
|
Sequence[AnyPromptType | Image | PathLike[str]]
|
Groups of prompts to process sequentially |
()
|
result_type
|
type[TResult] | None
|
Optional type for structured responses |
None
|
model
|
ModelType
|
Optional model override |
None
|
store_history
|
bool
|
Whether to store in conversation history |
True
|
wait_for_connections
|
bool | None
|
Whether to wait for connected agents |
None
|
Yields:
Type | Description |
---|---|
AsyncIterator[ChatMessage[TResult]]
|
Response messages in sequence |
Example
questions = [ ["What is your name?"], ["How old are you?", image1], ["Describe this image", image2], ] async for response in agent.run_iter(*questions): print(response.content)
Source code in src/llmling_agent/agent/agent.py
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 |
|
run_job
async
¶
run_job(
job: Job[TDeps, str | None],
*,
store_history: bool = True,
include_agent_tools: bool = True,
) -> ChatMessage[str]
Execute a pre-defined task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job
|
Job[TDeps, str | None]
|
Job configuration to execute |
required |
store_history
|
bool
|
Whether the message exchange should be added to the context window |
True
|
include_agent_tools
|
bool
|
Whether to include agent tools |
True
|
Returns: Job execution result
Raises:
Type | Description |
---|---|
JobError
|
If task execution fails |
ValueError
|
If task configuration is invalid |
Source code in src/llmling_agent/agent/agent.py
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 |
|
run_stream
async
¶
run_stream(
*prompt: AnyPromptType | Image | PathLike[str],
result_type: type[TResult] | None = None,
model: ModelType = None,
tool_choice: bool | str | list[str] = True,
store_history: bool = True,
usage_limits: UsageLimits | None = None,
message_id: str | None = None,
conversation_id: str | None = None,
wait_for_connections: bool | None = None,
) -> AsyncIterator[StreamingResponseProtocol[TResult]]
Run agent with prompt and get a streaming response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
AnyPromptType | Image | PathLike[str]
|
User query or instruction |
()
|
result_type
|
type[TResult] | None
|
Optional type for structured responses |
None
|
model
|
ModelType
|
Optional model override |
None
|
tool_choice
|
bool | str | list[str]
|
Control tool usage: - True: Allow all tools - False: No tools - str: Use specific tool - list[str]: Allow specific tools |
True
|
store_history
|
bool
|
Whether the message exchange should be added to the context window |
True
|
usage_limits
|
UsageLimits | None
|
Optional usage limits for the model |
None
|
message_id
|
str | None
|
Optional message id for the returned message. Automatically generated if not provided. |
None
|
conversation_id
|
str | None
|
Optional conversation id for the returned message. |
None
|
wait_for_connections
|
bool | None
|
Whether to wait for connected agents to complete |
None
|
Returns:
Type | Description |
---|---|
AsyncIterator[StreamingResponseProtocol[TResult]]
|
A streaming result to iterate over. |
Raises:
Type | Description |
---|---|
UnexpectedModelBehavior
|
If the model fails or behaves unexpectedly |
Source code in src/llmling_agent/agent/agent.py
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 |
|
run_sync
¶
run_sync(
*prompt: AnyPromptType | Image | PathLike[str],
result_type: type[TResult] | None = None,
deps: TDeps | None = None,
model: ModelType = None,
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 |
()
|
result_type
|
type[TResult] | None
|
Optional type for structured responses |
None
|
deps
|
TDeps | None
|
Optional dependencies for the agent |
None
|
model
|
ModelType
|
Optional model override |
None
|
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/agent/agent.py
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 |
|
set_model
¶
set_model(model: ModelType)
Set the model for this agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
ModelType
|
New model to use (name or instance) |
required |
Emits
model_changed signal with the new model
Source code in src/llmling_agent/agent/agent.py
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 |
|
set_result_type
¶
set_result_type(
result_type: type[TResult] | str | ResponseDefinition | None,
*,
tool_name: str | None = None,
tool_description: str | None = None,
)
Set or update the result type for this agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result_type
|
type[TResult] | str | ResponseDefinition | None
|
New result type, can be: - A Python type for validation - Name of a response definition - Response definition instance - None to reset to unstructured mode |
required |
tool_name
|
str | None
|
Optional override for tool name |
None
|
tool_description
|
str | None
|
Optional override for tool description |
None
|
Source code in src/llmling_agent/agent/agent.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
|
share
async
¶
share(
target: AnyAgent[TDeps, Any],
*,
tools: list[str] | None = None,
resources: list[str] | None = None,
history: bool | int | None = None,
token_limit: int | None = None,
)
Share capabilities and knowledge with another agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
AnyAgent[TDeps, Any]
|
Agent to share with |
required |
tools
|
list[str] | None
|
List of tool names to share |
None
|
resources
|
list[str] | None
|
List of resource names to share |
None
|
history
|
bool | int | None
|
Share conversation history: - True: Share full history - int: Number of most recent messages to share - None: Don't share history |
None
|
token_limit
|
int | None
|
Optional max tokens for history |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If requested items don't exist |
RuntimeError
|
If runtime not available for resources |
Source code in src/llmling_agent/agent/agent.py
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 |
|
stop
async
¶
stop()
Stop continuous execution if running.
Source code in src/llmling_agent/agent/agent.py
1069 1070 1071 1072 1073 1074 |
|
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 agent state.
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/agent/agent.py
1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 |
|
to_structured
¶
to_structured(
result_type: None,
*,
tool_name: str | None = None,
tool_description: str | None = None,
) -> Self
to_structured(
result_type: type[TResult] | str | ResponseDefinition,
*,
tool_name: str | None = None,
tool_description: str | None = None,
) -> StructuredAgent[TDeps, TResult]
to_structured(
result_type: type[TResult] | str | ResponseDefinition | None,
*,
tool_name: str | None = None,
tool_description: str | None = None,
) -> StructuredAgent[TDeps, TResult] | Self
Convert this agent to a structured agent.
If result_type is None, returns self unchanged (no wrapping). Otherwise creates a StructuredAgent wrapper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result_type
|
type[TResult] | str | ResponseDefinition | None
|
Type for structured responses. Can be: - A Python type (Pydantic model) - Name of response definition from context - Complete response definition - None to skip wrapping |
required |
tool_name
|
str | None
|
Optional override for result tool name |
None
|
tool_description
|
str | None
|
Optional override for result tool description |
None
|
Returns:
Type | Description |
---|---|
StructuredAgent[TDeps, TResult] | Self
|
Either StructuredAgent wrapper or self unchanged |
from llmling_agent.agent import StructuredAgent
Source code in src/llmling_agent/agent/agent.py
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 |
|
to_tool
¶
to_tool(
*,
name: str | None = None,
reset_history_on_run: bool = True,
pass_message_history: bool = False,
share_context: bool = False,
parent: AnyAgent[Any, Any] | None = None,
) -> ToolInfo
Create a tool from this agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str | None
|
Optional tool name override |
None
|
reset_history_on_run
|
bool
|
Clear agent's history before each run |
True
|
pass_message_history
|
bool
|
Pass parent's message history to agent |
False
|
share_context
|
bool
|
Whether to pass parent's context/deps |
False
|
parent
|
AnyAgent[Any, Any] | None
|
Optional parent agent for history/context sharing |
None
|
Source code in src/llmling_agent/agent/agent.py
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 |
|
wait
async
¶
wait() -> ChatMessage[TResult]
Wait for background execution to complete.
Source code in src/llmling_agent/agent/agent.py
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 |
|
AgentConfig
¶
Bases: NodeConfig
Configuration for a single agent in the system.
Defines an agent's complete configuration including its model, environment, capabilities, and behavior settings. Each agent can have its own: - Language model configuration - Environment setup (tools and resources) - Response type definitions - System prompts and default user prompts - Role-based capabilities
The configuration can be loaded from YAML or created programmatically.
Source code in src/llmling_agent/models/agents.py
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 |
|
avatar
class-attribute
instance-attribute
¶
avatar: str | None = None
URL or path to agent's avatar image
capabilities
class-attribute
instance-attribute
¶
capabilities: Capabilities = Field(default_factory=Capabilities)
Current agent's capabilities.
config_file_path
class-attribute
instance-attribute
¶
config_file_path: str | None = None
Config file path for resolving environment.
end_strategy
class-attribute
instance-attribute
¶
end_strategy: EndStrategy = 'early'
The strategy for handling multiple tool calls when a final result is found
environment
class-attribute
instance-attribute
¶
environment: str | AgentEnvironment | None = None
Environments configuration (path or object)
inherits
class-attribute
instance-attribute
¶
inherits: str | None = None
Name of agent config to inherit from
knowledge
class-attribute
instance-attribute
¶
knowledge: Knowledge | None = None
Knowledge sources for this agent.
library_system_prompts
class-attribute
instance-attribute
¶
System prompts for the agent from the library
model
class-attribute
instance-attribute
¶
model: str | AnyModelConfig | None = None
The model to use for this agent. Can be either a simple model name string (e.g. 'openai:gpt-4') or a structured model definition.
provider
class-attribute
instance-attribute
¶
provider: ProviderConfig | Literal['pydantic_ai', 'human', 'litellm'] = 'pydantic_ai'
Provider configuration or shorthand type
requires_tool_confirmation
class-attribute
instance-attribute
¶
requires_tool_confirmation: ToolConfirmationMode = 'per_tool'
How to handle tool confirmation: - "always": Always require confirmation for all tools - "never": Never require confirmation (ignore tool settings) - "per_tool": Use individual tool settings
result_retries
class-attribute
instance-attribute
¶
result_retries: int | None = None
Max retries for result validation
result_tool_description
class-attribute
instance-attribute
¶
result_tool_description: str | None = None
Custom description for the result tool
result_tool_name
class-attribute
instance-attribute
¶
result_tool_name: str = 'final_result'
Name of the tool used for structured responses
result_type
class-attribute
instance-attribute
¶
result_type: str | ResponseDefinition | None = None
Name of the response definition to use
retries
class-attribute
instance-attribute
¶
retries: int = 1
Number of retries for failed operations (maps to pydantic-ai's retries)
session
class-attribute
instance-attribute
¶
session: str | SessionQuery | MemoryConfig | None = None
Session configuration for conversation recovery.
system_prompts
class-attribute
instance-attribute
¶
System prompts for the agent
tools
class-attribute
instance-attribute
¶
A list of tools to register with this agent.
toolsets
class-attribute
instance-attribute
¶
Toolset configurations for extensible tool collections.
user_prompts
class-attribute
instance-attribute
¶
Default user prompts for the agent
workers
class-attribute
instance-attribute
¶
workers: list[WorkerConfig] = Field(default_factory=list)
Worker agents which will be available as tools.
_resolve_environment_path
staticmethod
¶
Resolve environment path from config store or relative path.
Source code in src/llmling_agent/models/agents.py
387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
get_config
¶
get_config() -> Config
Get configuration for this agent.
Source code in src/llmling_agent/models/agents.py
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 |
|
get_environment_path
¶
get_environment_path() -> str | None
Get environment file path if available.
Source code in src/llmling_agent/models/agents.py
377 378 379 380 381 382 383 384 385 |
|
get_provider
¶
get_provider() -> AgentProvider
Get resolved provider instance.
Creates provider instance based on configuration: - Full provider config: Use as-is - Shorthand type: Create default provider config
Source code in src/llmling_agent/models/agents.py
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 |
|
get_session_config
¶
get_session_config() -> MemoryConfig
Get resolved memory configuration.
Source code in src/llmling_agent/models/agents.py
277 278 279 280 281 282 283 284 285 286 287 |
|
get_system_prompts
¶
get_system_prompts() -> list[BasePrompt]
Get all system prompts as BasePrompts.
Source code in src/llmling_agent/models/agents.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
get_tool_provider
¶
get_tool_provider() -> ResourceProvider | None
Get tool provider for this agent.
Source code in src/llmling_agent/models/agents.py
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 |
|
get_toolsets
async
¶
get_toolsets() -> list[ResourceProvider]
Get all resource providers for this agent.
Source code in src/llmling_agent/models/agents.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
handle_model_types
classmethod
¶
Convert model inputs to appropriate format.
Source code in src/llmling_agent/models/agents.py
220 221 222 223 224 225 226 227 228 |
|
is_structured
¶
is_structured() -> bool
Check if this config defines a structured agent.
Source code in src/llmling_agent/models/agents.py
175 176 177 |
|
normalize_workers
classmethod
¶
Convert string workers to WorkerConfig.
Source code in src/llmling_agent/models/agents.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
render_system_prompts
¶
Render system prompts with context.
Source code in src/llmling_agent/models/agents.py
343 344 345 346 347 348 |
|
validate_result_type
classmethod
¶
Convert result type and apply its settings.
Source code in src/llmling_agent/models/agents.py
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 |
|
AgentContext
dataclass
¶
Bases: NodeContext[TDeps]
Runtime context for agent execution.
Generically typed with AgentContext[Type of Dependencies]
Source code in src/llmling_agent/agent/context.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 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 |
|
model_settings
class-attribute
instance-attribute
¶
Model-specific settings.
runtime
class-attribute
instance-attribute
¶
runtime: RuntimeConfig | None = None
Reference to the runtime configuration.
create_default
classmethod
¶
create_default(
name: str,
capabilities: Capabilities | None = None,
deps: TDeps | None = None,
pool: AgentPool | None = None,
input_provider: InputProvider | None = None,
) -> AgentContext[TDeps]
Create a default agent context with minimal privileges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the agent |
required |
capabilities
|
Capabilities | None
|
Optional custom capabilities (defaults to minimal access) |
None
|
deps
|
TDeps | None
|
Optional dependencies for the agent |
None
|
pool
|
AgentPool | None
|
Optional pool the agent is part of |
None
|
input_provider
|
InputProvider | None
|
Optional input provider for the agent |
None
|
Source code in src/llmling_agent/agent/context.py
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 |
|
handle_confirmation
async
¶
Handle tool execution confirmation.
Returns True if: - No confirmation handler is set - Handler confirms the execution
Source code in src/llmling_agent/agent/context.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
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 |
|
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
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 |
|
__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
188 189 190 191 192 193 194 195 196 197 198 199 |
|
__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 |
|
_connect_nodes
¶
_connect_nodes()
Set up connections defined in manifest.
Source code in src/llmling_agent/delegation/pool.py
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 |
|
_create_teams
¶
_create_teams()
Create all teams in two phases to allow nesting.
Source code in src/llmling_agent/delegation/pool.py
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 |
|
_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
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
|
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
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 |
|
cleanup
async
¶
cleanup()
Clean up all agents.
Source code in src/llmling_agent/delegation/pool.py
201 202 203 204 |
|
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
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 |
|
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
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 |
|
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
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 |
|
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
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 |
|
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
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 |
|
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
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 |
|
list_nodes
¶
List available agent names.
Source code in src/llmling_agent/delegation/pool.py
827 828 829 |
|
run_event_loop
async
¶
run_event_loop()
Run pool in event-watching mode until interrupted.
Source code in src/llmling_agent/delegation/pool.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
|
setup_agent_workers
¶
Set up workers for an agent from configuration.
Source code in src/llmling_agent/delegation/pool.py
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 |
|
track_message_flow
async
¶
track_message_flow() -> AsyncIterator[MessageFlowTracker]
Track message flow during a context.
Source code in src/llmling_agent/delegation/pool.py
373 374 375 376 377 378 379 380 381 |
|
AgentsManifest
¶
Bases: ConfigModel
Complete agent configuration manifest defining all available agents.
This is the root configuration that: - Defines available response types (both inline and imported) - Configures all agent instances and their settings - Sets up custom role definitions and capabilities - Manages environment configurations
A single manifest can define multiple agents that can work independently or collaborate through the orchestrator.
Source code in src/llmling_agent/models/manifest.py
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 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 |
|
INHERIT
class-attribute
instance-attribute
¶
Inheritance references.
agents
class-attribute
instance-attribute
¶
agents: dict[str, AgentConfig] = Field(default_factory=dict)
Mapping of agent IDs to their configurations
conversion
class-attribute
instance-attribute
¶
conversion: ConversionConfig = Field(default_factory=ConversionConfig)
Document conversion configuration.
jobs
class-attribute
instance-attribute
¶
Pre-defined jobs, ready to be used by nodes.
mcp_servers
class-attribute
instance-attribute
¶
List of MCP server configurations:
These MCP servers are used to provide tools and other resources to the nodes.
observability
class-attribute
instance-attribute
¶
observability: ObservabilityConfig = Field(default_factory=ObservabilityConfig)
Observability provider configuration.
pool_server
class-attribute
instance-attribute
¶
pool_server: PoolServerConfig = Field(default_factory=PoolServerConfig)
Pool server configuration.
This MCP server configuration is used for the pool MCP server, which exposes pool functionality to other applications / clients.
prompt_manager
cached
property
¶
prompt_manager: PromptManager
Get prompt manager for this manifest.
responses
class-attribute
instance-attribute
¶
Mapping of response names to their definitions
storage
class-attribute
instance-attribute
¶
storage: StorageConfig = Field(default_factory=StorageConfig)
Storage provider configuration.
teams
class-attribute
instance-attribute
¶
teams: dict[str, TeamConfig] = Field(default_factory=dict)
Mapping of team IDs to their configurations
clone_agent_config
¶
clone_agent_config(
name: str,
new_name: str | None = None,
*,
template_context: dict[str, Any] | None = None,
**overrides: Any,
) -> str
Create a copy of an agent configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of agent to clone |
required |
new_name
|
str | None
|
Optional new name (auto-generated if None) |
None
|
template_context
|
dict[str, Any] | None
|
Variables for template rendering |
None
|
**overrides
|
Any
|
Configuration overrides for the clone |
{}
|
Returns:
Type | Description |
---|---|
str
|
Name of the new agent |
Raises:
Type | Description |
---|---|
KeyError
|
If original agent not found |
ValueError
|
If new name already exists or if overrides invalid |
Source code in src/llmling_agent/models/manifest.py
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 |
|
from_file
classmethod
¶
from_file(path: StrPath) -> Self
Load agent configuration from YAML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
StrPath
|
Path to the configuration file |
required |
Returns:
Type | Description |
---|---|
Self
|
Loaded agent definition |
Raises:
Type | Description |
---|---|
ValueError
|
If loading fails |
Source code in src/llmling_agent/models/manifest.py
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 |
|
get_mcp_servers
¶
get_mcp_servers() -> list[MCPServerConfig]
Get processed MCP server configurations.
Converts string entries to StdioMCPServer configs by splitting into command and arguments.
Returns:
Type | Description |
---|---|
list[MCPServerConfig]
|
List of MCPServerConfig instances |
Raises:
Type | Description |
---|---|
ValueError
|
If string entry is empty |
Source code in src/llmling_agent/models/manifest.py
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 |
|
get_result_type
¶
Get the resolved result type for an agent.
Returns None if no result type is configured.
Source code in src/llmling_agent/models/manifest.py
371 372 373 374 375 376 377 378 379 380 381 382 383 |
|
get_used_providers
¶
Get all providers configured in this manifest.
Source code in src/llmling_agent/models/manifest.py
318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
resolve_inheritance
classmethod
¶
Resolve agent inheritance chains.
Source code in src/llmling_agent/models/manifest.py
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 |
|
set_instrument_libraries
¶
set_instrument_libraries() -> Self
Auto-set libraries to instrument based on used providers.
Source code in src/llmling_agent/models/manifest.py
195 196 197 198 199 200 201 202 203 204 |
|
ChatMessage
dataclass
¶
Common message format for all UI types.
Generically typed with: ChatMessage[Type of Content] The type can either be str or a BaseModel subclass.
Source code in src/llmling_agent/messaging/messages.py
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 |
|
associated_messages
class-attribute
instance-attribute
¶
associated_messages: list[ChatMessage[Any]] = field(default_factory=list)
List of messages which were generated during the the creation of this messsage.
content
instance-attribute
¶
content: TContent
Message content, typed as TContent (either str or BaseModel).
conversation_id
class-attribute
instance-attribute
¶
conversation_id: str | None = None
ID of the conversation this message belongs to.
cost_info
class-attribute
instance-attribute
¶
cost_info: TokenCost | None = None
Token usage and costs for this specific message if available.
forwarded_from
class-attribute
instance-attribute
¶
List of agent names (the chain) that forwarded this message to the sender.
message_id
class-attribute
instance-attribute
¶
Unique identifier for this message.
metadata
class-attribute
instance-attribute
¶
Additional metadata about the message.
model
class-attribute
instance-attribute
¶
model: str | None = None
Name of the model that generated this message.
name
class-attribute
instance-attribute
¶
name: str | None = None
Display name for the message sender in UI.
provider_extra
class-attribute
instance-attribute
¶
Provider specific metadata / extra information.
response_time
class-attribute
instance-attribute
¶
response_time: float | None = None
Time it took the LLM to respond.
timestamp
class-attribute
instance-attribute
¶
When this message was created.
tool_calls
class-attribute
instance-attribute
¶
tool_calls: list[ToolCallInfo] = field(default_factory=list)
List of tool calls made during message generation.
_get_content_str
¶
_get_content_str() -> str
Get string representation of content.
Source code in src/llmling_agent/messaging/messages.py
218 219 220 221 222 223 224 225 226 227 |
|
format
¶
format(
style: FormatStyle = "simple",
*,
template: str | None = None,
variables: dict[str, Any] | None = None,
show_metadata: bool = False,
show_costs: bool = False,
) -> str
Format message with configurable style.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
style
|
FormatStyle
|
Predefined style or "custom" for custom template |
'simple'
|
template
|
str | None
|
Custom Jinja template (required if style="custom") |
None
|
variables
|
dict[str, Any] | None
|
Additional variables for template rendering |
None
|
show_metadata
|
bool
|
Whether to include metadata |
False
|
show_costs
|
bool
|
Whether to include cost information |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
If style is "custom" but no template provided or if style is invalid |
Source code in src/llmling_agent/messaging/messages.py
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 |
|
forwarded
¶
forwarded(previous_message: ChatMessage[Any]) -> Self
Create new message showing it was forwarded from another message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
previous_message
|
ChatMessage[Any]
|
The message that led to this one's creation |
required |
Returns:
Type | Description |
---|---|
Self
|
New message with updated chain showing the path through previous message |
Source code in src/llmling_agent/messaging/messages.py
202 203 204 205 206 207 208 209 210 211 212 |
|
to_text_message
¶
to_text_message() -> ChatMessage[str]
Convert this message to a text-only version.
Source code in src/llmling_agent/messaging/messages.py
214 215 216 |
|
StructuredAgent
¶
Bases: MessageNode[TDeps, TResult]
Wrapper for Agent that enforces a specific result type.
This wrapper ensures the agent always returns results of the specified type. The type can be provided as: - A Python type for validation - A response definition name from the manifest - A complete response definition instance
Source code in src/llmling_agent/agent/structured.py
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 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 |
|
__aenter__
async
¶
__aenter__() -> Self
Enter async context and set up MCP servers.
Called when agent enters its async context. Sets up any configured MCP servers and their tools.
Source code in src/llmling_agent/agent/structured.py
115 116 117 118 119 120 121 122 |
|
__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/agent/structured.py
124 125 126 127 128 129 130 131 |
|
__init__
¶
__init__(
agent: Agent[TDeps] | StructuredAgent[TDeps, TResult] | Callable[..., TResult],
result_type: type[TResult] | str | ResponseDefinition,
*,
tool_name: str | None = None,
tool_description: str | None = None,
)
Initialize structured agent wrapper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent
|
Agent[TDeps] | StructuredAgent[TDeps, TResult] | Callable[..., TResult]
|
Base agent to wrap |
required |
result_type
|
type[TResult] | str | ResponseDefinition
|
Expected result type: - BaseModel / dataclasses - Name of response definition in manifest - Complete response definition instance |
required |
tool_name
|
str | None
|
Optional override for tool name |
None
|
tool_description
|
str | None
|
Optional override for tool description |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If named response type not found in manifest |
Source code in src/llmling_agent/agent/structured.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 |
|
_run
async
¶
_run(
*prompt: AnyPromptType | TResult,
result_type: type[TResult] | None = None,
model: ModelType = None,
tool_choice: bool | str | list[str] = True,
store_history: bool = True,
message_id: str | None = None,
conversation_id: str | None = None,
wait_for_connections: bool | None = None,
) -> ChatMessage[TResult]
Run with fixed result type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
AnyPromptType | TResult
|
Any prompt-compatible object or structured objects of type TResult |
()
|
result_type
|
type[TResult] | None
|
Expected result type: - BaseModel / dataclasses - Name of response definition in manifest - Complete response definition instance |
None
|
model
|
ModelType
|
Optional model override |
None
|
tool_choice
|
bool | str | list[str]
|
Control tool usage: - True: Allow all tools - False: No tools - str: Use specific tool - list[str]: Allow specific tools |
True
|
store_history
|
bool
|
Whether the message exchange should be added to the context window |
True
|
message_id
|
str | None
|
Optional message id for the returned message. Automatically generated if not provided. |
None
|
conversation_id
|
str | None
|
Optional conversation id for the returned message. |
None
|
wait_for_connections
|
bool | None
|
Whether to wait for all connections to complete |
None
|
Source code in src/llmling_agent/agent/structured.py
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 |
|
from_callback
classmethod
¶
from_callback(
callback: ProcessorCallback[TResult], *, name: str | None = None, **kwargs: Any
) -> StructuredAgent[None, TResult]
Create a structured agent from a processing callback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback
|
ProcessorCallback[TResult]
|
Function to process messages. Can be: - sync or async - with or without context - with explicit return type |
required |
name
|
str | None
|
Optional name for the agent |
None
|
**kwargs
|
Any
|
Additional arguments for agent |
{}
|
Example
class AnalysisResult(BaseModel):
sentiment: float
topics: list[str]
def analyze(msg: str) -> AnalysisResult:
return AnalysisResult(sentiment=0.8, topics=["tech"])
analyzer = StructuredAgent.from_callback(analyze)
Source code in src/llmling_agent/agent/structured.py
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 |
|
is_busy
¶
is_busy() -> bool
Check if agent is currently processing tasks.
Source code in src/llmling_agent/agent/structured.py
396 397 398 |
|
run_iter
async
¶
run_iter(
*prompt_groups: Sequence[AnyPromptType | Image | PathLike[str]], **kwargs: Any
) -> AsyncIterator[ChatMessage[Any]]
Forward run_iter to wrapped agent.
Source code in src/llmling_agent/agent/structured.py
271 272 273 274 275 276 277 278 |
|
run_job
async
¶
run_job(
job: Job[TDeps, TResult],
*,
store_history: bool = True,
include_agent_tools: bool = True,
) -> ChatMessage[TResult]
Execute a pre-defined job ensuring type compatibility.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job
|
Job[TDeps, TResult]
|
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 |
---|---|
ChatMessage[TResult]
|
Task execution result |
Raises:
Type | Description |
---|---|
JobError
|
If job execution fails or types don't match |
ValueError
|
If job configuration is invalid |
Source code in src/llmling_agent/agent/structured.py
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 |
|
validate_against
async
¶
Check if agent's response satisfies stricter criteria.
Source code in src/llmling_agent/agent/structured.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
Team
¶
Group of agents that can execute together.
Source code in src/llmling_agent/delegation/team.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 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 |
|
__prompt__
¶
__prompt__() -> str
Format team info for prompts.
Source code in src/llmling_agent/delegation/team.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[list[Any]]
Run all agents in parallel and return combined message.
Source code in src/llmling_agent/delegation/team.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
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
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 |
|
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
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 |
|
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
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 |
|
TeamRun
¶
Bases: BaseTeam[TDeps, TResult]
Handles team operations with monitoring.
Source code in src/llmling_agent/delegation/teamrun.py
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 |
|
__prompt__
¶
__prompt__() -> str
Format team info for prompts.
Source code in src/llmling_agent/delegation/teamrun.py
87 88 89 90 91 |
|
_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
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 |
|
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
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 |
|
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
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
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
154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
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
288 289 290 291 292 293 294 295 296 297 298 299 |
|
ToolInfo
dataclass
¶
Information about a registered tool.
Source code in src/llmling_agent/tools/base.py
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 |
|
agent_name
class-attribute
instance-attribute
¶
agent_name: str | None = None
The agent name as an identifier for agent-as-a-tool.
cache_enabled
class-attribute
instance-attribute
¶
cache_enabled: bool = False
Whether to enable caching for this tool.
enabled
class-attribute
instance-attribute
¶
enabled: bool = True
Whether the tool is currently enabled
metadata
class-attribute
instance-attribute
¶
Additional tool metadata
priority
class-attribute
instance-attribute
¶
priority: int = 100
Priority for tool execution (lower = higher priority)
requires_capability
class-attribute
instance-attribute
¶
requires_capability: str | None = None
Optional capability required to use this tool
requires_confirmation
class-attribute
instance-attribute
¶
requires_confirmation: bool = False
Whether tool execution needs explicit confirmation
source
class-attribute
instance-attribute
¶
source: ToolSource = 'runtime'
Where the tool came from.
execute
async
¶
Execute tool, handling both sync and async cases.
Source code in src/llmling_agent/tools/base.py
151 152 153 154 |
|
format_info
¶
Format complete tool information.
Source code in src/llmling_agent/tools/base.py
138 139 140 141 142 143 144 145 146 147 148 149 |
|
from_autogen_tool
classmethod
¶
from_autogen_tool(
tool: Any,
*,
name_override: str | None = None,
description_override: str | None = None,
schema_override: OpenAIFunctionDefinition | None = None,
**kwargs: Any,
) -> Self
Create a tool from a AutoGen tool.
Source code in src/llmling_agent/tools/base.py
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 |
|
from_code
classmethod
¶
Create a tool from a code string.
Source code in src/llmling_agent/tools/base.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
from_crewai_tool
classmethod
¶
from_crewai_tool(
tool: Any,
*,
name_override: str | None = None,
description_override: str | None = None,
schema_override: OpenAIFunctionDefinition | None = None,
**kwargs: Any,
) -> Self
Allows importing crewai tools.
Source code in src/llmling_agent/tools/base.py
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 |
|
from_langchain_tool
classmethod
¶
from_langchain_tool(
tool: Any,
*,
name_override: str | None = None,
description_override: str | None = None,
schema_override: OpenAIFunctionDefinition | None = None,
**kwargs: Any,
) -> Self
Create a tool from a LangChain tool.
Source code in src/llmling_agent/tools/base.py
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 |
|
matches_filter
¶
Check if tool matches state filter.
Source code in src/llmling_agent/tools/base.py
111 112 113 114 115 116 117 118 119 |
|