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. |
||
AudioBase64Content llmling_agent.models.content Audio from base64 data. |
||
AudioURLContent llmling_agent.models.content Audio from URL. |
||
BaseTeam llmling_agent.delegation.base_team Base class for Team and TeamRun. |
||
ChatMessage llmling_agent.messaging.messages Common message format for all UI types. |
||
ImageBase64Content llmling_agent.models.content Image from base64 data. |
||
ImageURLContent llmling_agent.models.content Image from URL. |
||
JSONCode llmling_agent.common_types JSON with syntax validation. |
||
MessageNode llmling_agent.messaging.messagenode Base class for all message processing nodes. |
||
PDFBase64Content llmling_agent.models.content PDF from base64 data. |
||
PDFURLContent llmling_agent.models.content PDF from URL. |
||
PythonCode llmling_agent.common_types Python with syntax validation. |
||
StructuredAgent llmling_agent.agent.structured Wrapper for Agent that enforces a specific result type. |
||
TOMLCode llmling_agent.common_types TOML with syntax validation. |
||
Team llmling_agent.delegation.team Group of agents that can execute together. |
||
TeamRun llmling_agent.delegation.teamrun Handles team operations with monitoring. |
||
Tool llmling_agent.tools.base Information about a registered tool. |
||
ToolCallInfo llmling_agent.tools.tool_call_info Information about an executed tool call. |
||
VideoURLContent llmling_agent.models.content Video from URL. |
||
YAMLCode llmling_agent.common_types YAML with syntax validation. |
🛈 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
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 |
|
AgentReset
dataclass
¶
Emitted when agent is reset.
Source code in src/llmling_agent/agent/agent.py
135 136 137 138 139 140 141 142 |
|
__aenter__
async
¶
__aenter__() -> Self
Enter async context and set up MCP servers.
Source code in src/llmling_agent/agent/agent.py
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 |
|
__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
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
__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
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 |
|
__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
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 |
|
_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: str | list[str] | None = None,
usage_limits: UsageLimits | None = None,
message_id: str | None = None,
conversation_id: str | None = None,
messages: list[ChatMessage[Any]] | 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
|
str | list[str] | None
|
Filter tool choice by name |
None
|
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
|
messages
|
list[ChatMessage[Any]] | None
|
Optional list of messages to replace the conversation history |
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
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 |
|
clear_history
¶
clear_history()
Clear both internal and pydantic-ai history.
Source code in src/llmling_agent/agent/agent.py
1075 1076 1077 1078 1079 |
|
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
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 |
|
is_busy
¶
is_busy() -> bool
Check if agent is currently processing tasks.
Source code in src/llmling_agent/agent/agent.py
639 640 641 |
|
register_worker
¶
register_worker(
worker: MessageNode[Any, Any],
*,
name: str | None = None,
reset_history_on_run: bool = True,
pass_message_history: bool = False,
share_context: bool = False,
) -> Tool
Register another agent as a worker tool.
Source code in src/llmling_agent/agent/agent.py
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 |
|
reset
async
¶
reset()
Reset agent state (conversation history and tool states).
Source code in src/llmling_agent/agent/agent.py
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 |
|
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
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 |
|
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
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 |
|
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
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 |
|
run_stream
async
¶
run_stream(
*prompt: AnyPromptType | Image | PathLike[str],
result_type: type[TResult] | None = None,
model: ModelType = None,
tool_choice: str | list[str] | None = None,
store_history: bool = True,
usage_limits: UsageLimits | None = None,
message_id: str | None = None,
conversation_id: str | None = None,
messages: list[ChatMessage[Any]] | 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
|
str | list[str] | None
|
Filter tool choice by name |
None
|
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
|
messages
|
list[ChatMessage[Any]] | None
|
Optional list of messages to replace the conversation history |
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
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 |
|
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
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 |
|
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
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 |
|
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
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
|
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
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 |
|
stop
async
¶
stop()
Stop continuous execution if running.
Source code in src/llmling_agent/agent/agent.py
1055 1056 1057 1058 1059 1060 |
|
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
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 |
|
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
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 |
|
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,
) -> Tool
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
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 |
|
wait
async
¶
wait() -> ChatMessage[TResult]
Wait for background execution to complete.
Source code in src/llmling_agent/agent/agent.py
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
|
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
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 |
|
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 | ProviderName = '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
¶
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
341 342 343 344 345 346 347 348 349 350 351 352 353 |
|
get_config
¶
get_config() -> Config
Get configuration for this agent.
Source code in src/llmling_agent/models/agents.py
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 |
|
get_environment_path
¶
get_environment_path() -> str | None
Get environment file path if available.
Source code in src/llmling_agent/models/agents.py
331 332 333 334 335 336 337 338 339 |
|
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
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_session_config
¶
get_session_config() -> MemoryConfig
Get resolved memory configuration.
Source code in src/llmling_agent/models/agents.py
231 232 233 234 235 236 237 238 239 240 241 |
|
get_system_prompts
¶
get_system_prompts() -> list[BasePrompt]
Get all system prompts as BasePrompts.
Source code in src/llmling_agent/models/agents.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
get_tool_provider
¶
get_tool_provider() -> ResourceProvider | None
Get tool provider for this agent.
Source code in src/llmling_agent/models/agents.py
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 |
|
get_toolsets
async
¶
get_toolsets() -> list[ResourceProvider]
Get all resource providers for this agent.
Source code in src/llmling_agent/models/agents.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
handle_model_types
classmethod
¶
Convert model inputs to appropriate format.
Source code in src/llmling_agent/models/agents.py
174 175 176 177 178 179 180 181 182 |
|
is_structured
¶
is_structured() -> bool
Check if this config defines a structured agent.
Source code in src/llmling_agent/models/agents.py
144 145 146 |
|
render_system_prompts
¶
Render system prompts with context.
Source code in src/llmling_agent/models/agents.py
297 298 299 300 301 302 |
|
validate_result_type
classmethod
¶
Convert result type and apply its settings.
Source code in src/llmling_agent/models/agents.py
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 |
|
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 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 |
|
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
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 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 |
|
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.
resource_registry
cached
property
¶
resource_registry: ResourceRegistry
Get registry with all configured resources.
resources
class-attribute
instance-attribute
¶
Resource configurations defining available filesystems.
Supports both full config and URI shorthand
resources: docs: "file://./docs" # shorthand data: # full config type: "source" uri: "s3://bucket/data" cached: true
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
¶
Mapping of team IDs to their configurations
ui
class-attribute
instance-attribute
¶
ui: UIConfig = Field(default_factory=StdlibUIConfig)
UI configuration.
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
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 |
|
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
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 |
|
get_mcp_servers
¶
get_mcp_servers() -> list[MCPServerConfig]
Get processed MCP server configurations.
Converts string entries to StdioMCPServerConfig 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
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 |
|
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
473 474 475 476 477 478 479 480 481 482 483 484 485 |
|
get_used_providers
¶
Get all providers configured in this manifest.
Source code in src/llmling_agent/models/manifest.py
420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
normalize_workers
classmethod
¶
Convert string workers to appropriate WorkerConfig for all agents.
Source code in src/llmling_agent/models/manifest.py
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 |
|
resolve_inheritance
classmethod
¶
Resolve agent inheritance chains.
Source code in src/llmling_agent/models/manifest.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 |
|
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
297 298 299 300 301 302 303 304 305 306 |
|
AudioBase64Content
¶
Bases: AudioContent
Audio from base64 data.
Source code in src/llmling_agent/models/content.py
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 |
|
type
class-attribute
instance-attribute
¶
type: Literal['audio_base64'] = Field('audio_base64', init=False)
Base64-encoded audio.
from_bytes
classmethod
¶
Create from raw bytes.
Source code in src/llmling_agent/models/content.py
268 269 270 271 |
|
from_path
classmethod
¶
from_path(path: StrPath) -> Self
Create from file path with auto format detection.
Source code in src/llmling_agent/models/content.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
to_openai_format
¶
Convert to OpenAI API format for audio models.
Source code in src/llmling_agent/models/content.py
262 263 264 265 266 |
|
AudioURLContent
¶
Bases: AudioContent
Audio from URL.
Source code in src/llmling_agent/models/content.py
235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
type
class-attribute
instance-attribute
¶
type: Literal['audio_url'] = Field('audio_url', init=False)
URL-based audio.
to_openai_format
¶
Convert to OpenAI API format for audio models.
Source code in src/llmling_agent/models/content.py
244 245 246 247 |
|
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 |
|
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
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 |
|
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
273 274 275 276 277 278 279 280 281 282 |
|
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
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 |
|
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
257 258 259 260 261 262 263 264 265 266 267 |
|
from_openai_format
classmethod
¶
from_openai_format(
message: dict[str, Any], conversation_id: str | None = None
) -> ChatMessage[str]
Create ChatMessage from OpenAI message format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
dict[str, Any]
|
OpenAI format message dict with role, content etc. |
required |
conversation_id
|
str | None
|
Optional conversation ID to assign |
None
|
Returns:
Type | Description |
---|---|
ChatMessage[str]
|
Converted ChatMessage |
Example
msg = ChatMessage.from_openai_format({ ... "role": "user", ... "content": "Hello!", ... "name": "john" ... })
Source code in src/llmling_agent/messaging/messages.py
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 |
|
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
269 270 271 |
|
ImageBase64Content
¶
Bases: BaseImageContent
Image from base64 data.
Source code in src/llmling_agent/models/content.py
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 |
|
mime_type
class-attribute
instance-attribute
¶
mime_type: str = 'image/jpeg'
MIME type of the image.
type
class-attribute
instance-attribute
¶
type: Literal['image_base64'] = Field('image_base64', init=False)
Base64-encoded image.
from_bytes
classmethod
¶
from_bytes(
data: bytes, *, detail: DetailLevel | None = None, description: str | None = None
) -> ImageBase64Content
Create image content from raw bytes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
bytes
|
Raw image bytes |
required |
detail
|
DetailLevel | None
|
Optional detail level for processing |
None
|
description
|
str | None
|
Optional description of the image |
None
|
Source code in src/llmling_agent/models/content.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
from_pil_image
classmethod
¶
from_pil_image(image: Image) -> ImageBase64Content
Create content from PIL Image.
Source code in src/llmling_agent/models/content.py
133 134 135 136 137 138 |
|
to_openai_format
¶
Convert to OpenAI API format for vision models.
Source code in src/llmling_agent/models/content.py
109 110 111 112 113 |
|
ImageURLContent
¶
Bases: BaseImageContent
Image from URL.
Source code in src/llmling_agent/models/content.py
82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
type
class-attribute
instance-attribute
¶
type: Literal['image_url'] = Field('image_url', init=False)
URL-based image.
to_openai_format
¶
Convert to OpenAI API format for vision models.
Source code in src/llmling_agent/models/content.py
91 92 93 94 |
|
JSONCode
¶
Bases: BaseCode
JSON with syntax validation.
Source code in src/llmling_agent/common_types.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
MessageNode
¶
Bases: MessageEmitter[TDeps, TResult]
Base class for all message processing nodes.
Source code in src/llmling_agent/messaging/messagenode.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
tool_used
class-attribute
instance-attribute
¶
tool_used = Signal(ToolCallInfo)
Signal emitted when node uses a tool.
pre_run
async
¶
pre_run(
*prompt: AnyPromptType | Image | PathLike[str] | ChatMessage,
) -> tuple[ChatMessage[Any], list[Content | str]]
Hook to prepare a MessgeNode run call.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*prompt
|
AnyPromptType | Image | PathLike[str] | ChatMessage
|
The prompt(s) to prepare. |
()
|
Returns:
Type | Description |
---|---|
tuple[ChatMessage[Any], list[Content | str]]
|
A tuple of: - Either incoming message, or a constructed incoming message based on the prompt(s). - A list of prompts to be sent to the model. |
Source code in src/llmling_agent/messaging/messagenode.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 |
|
run
async
¶
run(
*prompt: AnyPromptType | Image | PathLike[str] | ChatMessage,
wait_for_connections: bool | None = None,
store_history: bool = True,
**kwargs: Any,
) -> ChatMessage[TResult]
Execute node with prompts and handle message routing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
AnyPromptType | Image | PathLike[str] | ChatMessage
|
Input prompts |
()
|
wait_for_connections
|
bool | None
|
Whether to wait for forwarded messages |
None
|
store_history
|
bool
|
Whether to store in conversation history |
True
|
**kwargs
|
Any
|
Additional arguments for _run |
{}
|
Source code in src/llmling_agent/messaging/messagenode.py
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 |
|
run_iter
abstractmethod
¶
run_iter(*prompts: Any, **kwargs: Any) -> AsyncIterator[ChatMessage[Any]]
Yield messages during execution.
Source code in src/llmling_agent/messaging/messagenode.py
123 124 125 126 127 128 129 |
|
PDFBase64Content
¶
Bases: BasePDFContent
PDF from base64 data.
Source code in src/llmling_agent/models/content.py
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 |
|
type
class-attribute
instance-attribute
¶
type: Literal['pdf_base64'] = Field('pdf_base64', init=False)
Base64-data based PDF.
from_bytes
classmethod
¶
from_bytes(
data: bytes, *, detail: DetailLevel | None = None, description: str | None = None
) -> Self
Create PDF content from raw bytes.
Source code in src/llmling_agent/models/content.py
212 213 214 215 216 217 218 219 220 221 222 |
|
to_openai_format
¶
Convert to OpenAI API format for PDF handling.
Source code in src/llmling_agent/models/content.py
206 207 208 209 210 |
|
PDFURLContent
¶
Bases: BasePDFContent
PDF from URL.
Source code in src/llmling_agent/models/content.py
182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
type
class-attribute
instance-attribute
¶
type: Literal['pdf_url'] = Field('pdf_url', init=False)
URL-based PDF.
to_openai_format
¶
Convert to OpenAI API format for PDF handling.
Source code in src/llmling_agent/models/content.py
191 192 193 194 |
|
PythonCode
¶
Bases: BaseCode
Python with syntax validation.
Source code in src/llmling_agent/common_types.py
142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
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
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 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
__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
110 111 112 113 114 115 116 117 |
|
__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
119 120 121 122 123 124 125 126 |
|
__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
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 |
|
_run
async
¶
_run(
*prompt: AnyPromptType | TResult,
result_type: type[TResult] | None = None,
model: ModelType = None,
tool_choice: str | list[str] | None = None,
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
|
str | list[str] | None
|
Filter available tools by name |
None
|
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
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 |
|
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
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 |
|
is_busy
¶
is_busy() -> bool
Check if agent is currently processing tasks.
Source code in src/llmling_agent/agent/structured.py
391 392 393 |
|
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
266 267 268 269 270 271 272 273 |
|
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
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 |
|
run_sync
¶
run_sync(*args, **kwargs)
Run agent synchronously.
Source code in src/llmling_agent/agent/structured.py
395 396 397 |
|
validate_against
async
¶
Check if agent's response satisfies stricter criteria.
Source code in src/llmling_agent/agent/structured.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
TOMLCode
¶
Bases: BaseCode
TOML with syntax validation.
Source code in src/llmling_agent/common_types.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
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 |
|
Tool
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 |
|
ToolCallInfo
¶
Bases: BaseModel
Information about an executed tool call.
Source code in src/llmling_agent/tools/tool_call_info.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
agent_tool_name
class-attribute
instance-attribute
¶
agent_tool_name: str | None = None
If this tool is agent-based, the name of that agent.
context_data
class-attribute
instance-attribute
¶
context_data: Any | None = None
Optional context data that was passed to the agent's run() method.
error
class-attribute
instance-attribute
¶
error: str | None = None
Error message if the tool call failed.
message_id
class-attribute
instance-attribute
¶
message_id: str | None = None
ID of the message that triggered this tool call.
timestamp
class-attribute
instance-attribute
¶
When the tool was called.
timing
class-attribute
instance-attribute
¶
timing: float | None = None
Time taken for this specific tool call in seconds.
tool_call_id
class-attribute
instance-attribute
¶
ID provided by the model (e.g. OpenAI function call ID).
format
¶
format(
style: FormatStyle = "simple",
*,
template: str | None = None,
variables: dict[str, Any] | None = None,
show_timing: bool = True,
show_ids: bool = False,
) -> str
Format tool call information with configurable style.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
style
|
FormatStyle
|
Predefined style to use: - simple: Compact single-line format - detailed: Multi-line with all details - markdown: Formatted markdown with syntax highlighting |
'simple'
|
template
|
str | None
|
Optional custom template (required if style="custom") |
None
|
variables
|
dict[str, Any] | None
|
Additional variables for template rendering |
None
|
show_timing
|
bool
|
Whether to include execution timing |
True
|
show_ids
|
bool
|
Whether to include tool_call_id and message_id |
False
|
Returns:
Type | Description |
---|---|
str
|
Formatted tool call information |
Raises:
Type | Description |
---|---|
ValueError
|
If style is invalid or custom template is missing |
Source code in src/llmling_agent/tools/tool_call_info.py
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 |
|
VideoURLContent
¶
Bases: VideoContent
Video from URL.
Source code in src/llmling_agent/models/content.py
301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
type
class-attribute
instance-attribute
¶
type: Literal['video_url'] = Field('video_url', init=False)
URL-based video.
to_openai_format
¶
Convert to OpenAI API format for video models.
Source code in src/llmling_agent/models/content.py
310 311 312 313 |
|
YAMLCode
¶
Bases: BaseCode
YAML with syntax validation.
Source code in src/llmling_agent/common_types.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|