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. |
||
AgentPool llmling_agent.delegation.pool Pool of initialized agents. |
||
AgentPoolView llmling_agent.chat_session.base User's view and control point for interacting with an agent in a pool. |
||
AgentRouter llmling_agent.delegation.router Base class for routing messages between agents. |
||
AgentsManifest llmling_agent.models.agents Complete agent configuration manifest defining all available agents. |
||
AwaitResponseDecision llmling_agent.delegation.router Forward message and wait for response. |
||
CallbackRouter llmling_agent.delegation.router Router using callback function for decisions. |
||
ChatMessage llmling_agent.models.messages Common message format for all UI types. |
||
Decision llmling_agent.delegation.router Base class for all routing decisions. |
||
EndDecision llmling_agent.delegation.router End the conversation. |
||
RouteDecision llmling_agent.delegation.router Forward message without waiting for response. |
||
RuleRouter llmling_agent.delegation.router Router using predefined rules. |
||
SlashedAgent llmling_agent.agent.slashed_agent Wraps an agent with slash command support. |
||
StructuredAgent llmling_agent.agent.structured Wrapper for Agent that enforces a specific result type. |
||
SystemPrompt llmling_agent.models.prompts System prompt configuration for agent behavior control. |
🛈 DocStrings¶
Agent configuration and creation.
Agent
¶
Bases: 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
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 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 |
|
__aenter__
async
¶
__aenter__() -> Self
Enter async context and set up MCP servers.
Source code in src/llmling_agent/agent/agent.py
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 |
|
__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
293 294 295 296 297 298 299 300 301 302 303 304 |
|
__init__
¶
__init__(
runtime: RuntimeConfig | Config | StrPath | None = None,
*,
context: AgentContext[TDeps] | None = None,
agent_type: AgentType = "ai",
session: SessionIdType | SessionQuery = None,
model: ModelType = None,
system_prompt: str | Sequence[str] = (),
name: str = "llmling-agent",
description: str | None = None,
tools: Sequence[ToolType] | None = None,
mcp_servers: list[str | MCPServerConfig] | None = None,
retries: int = 1,
result_retries: int | None = None,
tool_choice: bool | str | list[str] = True,
end_strategy: EndStrategy = "early",
defer_model_check: bool = False,
enable_db_logging: bool = True,
confirmation_callback: ConfirmationCallback | None = None,
debug: bool = False,
**kwargs,
)
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
|
agent_type
|
AgentType
|
Agent type to use (ai: PydanticAIProvider, human: HumanProvider) |
'ai'
|
session
|
SessionIdType | SessionQuery
|
Optional id or Session query to recover a conversation |
None
|
model
|
ModelType
|
The default model to use (defaults to GPT-4) |
None
|
system_prompt
|
str | Sequence[str]
|
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
|
mcp_servers
|
list[str | MCPServerConfig] | None
|
MCP servers to connect to |
None
|
retries
|
int
|
Default number of retries for failed operations |
1
|
result_retries
|
int | None
|
Max retries for result validation (defaults to retries) |
None
|
tool_choice
|
bool | str | list[str]
|
Ability to set a fixed tool or temporarily disable tools usage. |
True
|
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
|
kwargs
|
Additional arguments for PydanticAI agent |
{}
|
|
enable_db_logging
|
bool
|
Whether to enable logging for the agent |
True
|
confirmation_callback
|
ConfirmationCallback | None
|
Callback for confirmation prompts |
None
|
debug
|
bool
|
Whether to enable debug mode |
False
|
Source code in src/llmling_agent/agent/agent.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 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 |
|
__or__
¶
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
322 323 324 325 326 327 328 329 330 331 332 333 |
|
__rshift__
¶
Connect agent to another agent or group.
Example
agent >> other_agent # Connect to single agent agent >> (agent2 | agent3) # Connect to group agent >> "other_agent" # Connect by name (needs pool)
Source code in src/llmling_agent/agent/agent.py
312 313 314 315 316 317 318 319 320 |
|
clear_history
¶
clear_history()
Clear both internal and pydantic-ai history.
Source code in src/llmling_agent/agent/agent.py
1183 1184 1185 1186 1187 |
|
disconnect_all
async
¶
disconnect_all()
Disconnect from all agents.
Source code in src/llmling_agent/agent/agent.py
722 723 724 725 |
|
get_token_limits
async
¶
get_token_limits() -> TokenLimits | None
Get token limits for the current model.
Source code in src/llmling_agent/agent/agent.py
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 |
|
is_busy
¶
is_busy() -> bool
Check if agent is currently processing tasks.
Source code in src/llmling_agent/agent/agent.py
767 768 769 |
|
open
async
classmethod
¶
open(
config_path: StrPath | Config | None = None,
*,
result_type: None = None,
model: ModelType = None,
session: SessionIdType | SessionQuery = None,
system_prompt: str | Sequence[str] = (),
name: str = "llmling-agent",
retries: int = 1,
result_retries: int | None = None,
end_strategy: EndStrategy = "early",
defer_model_check: bool = False,
**kwargs: Any,
) -> AbstractAsyncContextManager[Agent[TDeps]]
open(
config_path: StrPath | Config | None = None,
*,
result_type: type[TResult],
model: ModelType = None,
session: SessionIdType | SessionQuery = None,
system_prompt: str | Sequence[str] = (),
name: str = "llmling-agent",
retries: int = 1,
result_retries: int | None = None,
end_strategy: EndStrategy = "early",
defer_model_check: bool = False,
**kwargs: Any,
) -> AbstractAsyncContextManager[StructuredAgent[TDeps, TResult]]
open(
config_path: StrPath | Config | None = None,
*,
result_type: type[TResult] | None = None,
model: ModelType = None,
session: SessionIdType | SessionQuery = None,
system_prompt: str | Sequence[str] = (),
name: str = "llmling-agent",
retries: int = 1,
result_retries: int | None = None,
end_strategy: EndStrategy = "early",
defer_model_check: bool = False,
**kwargs: Any,
) -> AsyncIterator[Agent[TDeps] | StructuredAgent[TDeps, TResult]]
Open and configure an agent with an auto-managed runtime configuration.
This is a convenience method that combines RuntimeConfig.open with agent creation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_path
|
StrPath | Config | None
|
Path to the runtime configuration file or a Config instance (defaults to Config()) |
None
|
result_type
|
type[TResult] | None
|
Optional type for structured responses |
None
|
model
|
ModelType
|
The default model to use (defaults to GPT-4) |
None
|
session
|
SessionIdType | SessionQuery
|
Optional id or Session query to recover a conversation |
None
|
system_prompt
|
str | Sequence[str]
|
Static system prompts to use for this agent |
()
|
name
|
str
|
Name of the agent for logging |
'llmling-agent'
|
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
|
**kwargs
|
Any
|
Additional arguments for PydanticAI agent |
{}
|
Yields:
Type | Description |
---|---|
AsyncIterator[Agent[TDeps] | StructuredAgent[TDeps, TResult]]
|
Configured Agent instance |
Example
async with Agent.open("config.yml") as agent:
result = await agent.run("Hello!")
print(result.data)
Source code in src/llmling_agent/agent/agent.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 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
|
open_agent
async
classmethod
¶
open_agent(
config: StrPath | AgentsManifest,
agent_name: str,
*,
deps: TDeps | None = None,
result_type: None = None,
model: str | None = None,
session: SessionIdType | SessionQuery = None,
model_settings: dict[str, Any] | None = None,
tools: list[ToolType] | None = None,
tool_choice: bool | str | list[str] = True,
end_strategy: EndStrategy = "early",
) -> AbstractAsyncContextManager[Agent[TDeps]]
open_agent(
config: StrPath | AgentsManifest,
agent_name: str,
*,
deps: TDeps | None = None,
result_type: type[TResult],
model: str | None = None,
session: SessionIdType | SessionQuery = None,
model_settings: dict[str, Any] | None = None,
tools: list[ToolType] | None = None,
tool_choice: bool | str | list[str] = True,
end_strategy: EndStrategy = "early",
) -> AbstractAsyncContextManager[StructuredAgent[TDeps, TResult]]
open_agent(
config: StrPath | AgentsManifest,
agent_name: str,
*,
deps: TDeps | None = None,
result_type: type[TResult] | None = None,
model: str | ModelType = None,
session: SessionIdType | SessionQuery = None,
model_settings: dict[str, Any] | None = None,
tools: list[ToolType] | None = None,
tool_choice: bool | str | list[str] = True,
end_strategy: EndStrategy = "early",
retries: int = 1,
result_tool_name: str = "final_result",
result_tool_description: str | None = None,
result_retries: int | None = None,
system_prompt: str | Sequence[str] | None = None,
enable_db_logging: bool = True,
) -> AsyncIterator[Agent[TDeps] | StructuredAgent[TDeps, TResult]]
Open and configure a specific agent from configuration.
Source code in src/llmling_agent/agent/agent.py
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 |
|
pass_results_to
¶
pass_results_to(
other: AnyAgent[Any, Any] | Team[Any] | str,
prompt: str | None = None,
connection_type: ConnectionType = "run",
priority: int = 0,
delay: timedelta | None = None,
) -> Talk | TeamTalk
Forward results to another agent or all agents in a team.
Source code in src/llmling_agent/agent/agent.py
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 |
|
register_worker
¶
register_worker(
worker: Agent[Any],
*,
name: str | None = None,
reset_history_on_run: bool = True,
pass_message_history: bool = False,
share_context: bool = False,
) -> ToolInfo
Register another agent as a worker tool.
Source code in src/llmling_agent/agent/agent.py
1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 |
|
run
async
¶
run(
*prompt: AnyPromptType,
result_type: type[TResult] | None = None,
deps: TDeps | None = None,
model: ModelType = None,
store_history: bool = True,
) -> ChatMessage[TResult]
Run agent with prompt and get response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
AnyPromptType
|
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:
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
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 |
|
run_continuous
async
¶
run_continuous(
prompt: AnyPromptType,
*,
max_count: int | None = None,
interval: float = 1.0,
block: bool = False,
**kwargs: Any,
) -> ChatMessage[TResult] | None
Run agent continuously with prompt or dynamic prompt function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
AnyPromptType
|
Static prompt or function that generates prompts |
required |
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
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 |
|
run_stream
async
¶
run_stream(
*prompt: AnyPromptType,
result_type: type[TResult] | None = None,
deps: TDeps | None = None,
model: ModelType = None,
store_history: bool = True,
) -> AsyncIterator[StreamedRunResult[AgentContext[TDeps], TResult]]
Run agent with prompt and get a streaming response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
AnyPromptType
|
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:
Type | Description |
---|---|
AsyncIterator[StreamedRunResult[AgentContext[TDeps], 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
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 |
|
run_sync
¶
run_sync(
*prompt: AnyPromptType,
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
|
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
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 |
|
run_task
async
¶
run_task(
task: AgentTask[TDeps, TResult],
*,
store_history: bool = True,
include_agent_tools: bool = True,
) -> ChatMessage[TResult]
Execute a pre-defined task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
AgentTask[TDeps, TResult]
|
Task 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: Task execution result
Raises:
Type | Description |
---|---|
TaskError
|
If task execution fails |
ValueError
|
If task configuration is invalid |
Source code in src/llmling_agent/agent/agent.py
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 |
|
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
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 |
|
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
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
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,
) -> 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
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 |
|
stop
async
¶
stop()
Stop continuous execution if running.
Source code in src/llmling_agent/agent/agent.py
1176 1177 1178 1179 1180 1181 |
|
stop_passing_results_to
¶
Stop forwarding results to another agent.
Source code in src/llmling_agent/agent/agent.py
763 764 765 |
|
to_agent_tool
¶
to_agent_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,
) -> LLMCallableTool
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
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 |
|
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
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 |
|
wait_for_chain
async
¶
Wait for this agent and all connected agents to complete their tasks.
Source code in src/llmling_agent/agent/agent.py
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 |
|
AgentConfig
¶
Bases: BaseModel
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
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 |
|
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.
description
class-attribute
instance-attribute
¶
description: str | None = None
Optional description of the agent's purpose
enable_db_logging
class-attribute
instance-attribute
¶
enable_db_logging: bool = True
Enable session database logging.
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
Environment configuration (path or object)
forward_to
class-attribute
instance-attribute
¶
Targets to forward results to.
include_role_prompts
class-attribute
instance-attribute
¶
include_role_prompts: bool = True
Whether to include default prompts based on the agent's role.
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.
mcp_servers
class-attribute
instance-attribute
¶
List of MCP server configurations: - str entries are converted to StdioMCPServer - MCPServerConfig for full server configuration
model
class-attribute
instance-attribute
¶
model: str | AnyModel | 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.
model_settings
class-attribute
instance-attribute
¶
Additional settings to pass to the model
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 | None = None
Session configuration for conversation recovery.
system_prompts
class-attribute
instance-attribute
¶
System prompts for the agent
triggers
class-attribute
instance-attribute
¶
Event sources that activate this agent
type
class-attribute
instance-attribute
¶
type: ProviderConfig | Literal['ai', 'human', 'litellm'] = 'ai'
Provider configuration or shorthand type
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.
get_agent_kwargs
¶
Get kwargs for Agent constructor.
Returns:
Type | Description |
---|---|
dict[str, Any]
|
dict[str, Any]: Kwargs to pass to Agent |
Source code in src/llmling_agent/models/agents.py
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 |
|
get_config
¶
get_config() -> Config
Get configuration for this agent.
Source code in src/llmling_agent/models/agents.py
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 |
|
get_environment_display
¶
get_environment_display() -> str
Get human-readable environment description.
Source code in src/llmling_agent/models/agents.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
|
get_environment_path
¶
get_environment_path() -> str | None
Get environment file path if available.
Source code in src/llmling_agent/models/agents.py
358 359 360 361 362 363 364 365 366 |
|
get_mcp_servers
¶
get_mcp_servers() -> list[MCPServerConfig]
Get processed MCP server configurations.
Converts string entries to StdioMCPServer configs by splitting into command and arguments.
Returns:
Type | Description |
---|---|
list[MCPServerConfig]
|
List of MCPServerConfig instances |
Raises:
Type | Description |
---|---|
ValueError
|
If string entry is empty |
Source code in src/llmling_agent/models/agents.py
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 |
|
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
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 |
|
get_session_query
¶
get_session_query() -> SessionQuery | None
Get session query from config.
Source code in src/llmling_agent/models/agents.py
258 259 260 261 262 263 264 |
|
handle_model_types
classmethod
¶
Convert model inputs to appropriate format.
Source code in src/llmling_agent/models/agents.py
245 246 247 248 249 250 251 252 253 254 255 256 |
|
is_structured
¶
is_structured() -> bool
Check if this config defines a structured agent.
Source code in src/llmling_agent/models/agents.py
193 194 195 |
|
normalize_workers
classmethod
¶
Convert string workers to WorkerConfig.
Source code in src/llmling_agent/models/agents.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
render_system_prompts
¶
Render system prompts with context.
Source code in src/llmling_agent/models/agents.py
324 325 326 327 328 329 |
|
resolve_paths
classmethod
¶
Store config file path for later use.
Source code in src/llmling_agent/models/agents.py
396 397 398 399 400 401 402 403 |
|
validate_result_type
classmethod
¶
Convert result type and apply its settings.
Source code in src/llmling_agent/models/agents.py
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 |
|
AgentPool
¶
Bases: BaseRegistry[str, AnyAgent[Any, Any]]
Pool of initialized agents.
Each agent maintains its own runtime environment based on its configuration.
Source code in src/llmling_agent/delegation/pool.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 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 |
|
agents
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
155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
__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
169 170 171 172 173 174 175 176 |
|
__init__
¶
__init__(
manifest: AgentsManifest,
*,
agents_to_load: list[str] | None = None,
connect_agents: bool = True,
confirmation_callback: ConfirmationCallback | None = None,
)
Initialize agent pool with immediate agent creation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
manifest
|
AgentsManifest
|
Agent configuration manifest |
required |
agents_to_load
|
list[str] | None
|
Optional list of agent names to initialize If None, all agents from manifest are loaded |
None
|
connect_agents
|
bool
|
Whether to set up forwarding connections |
True
|
confirmation_callback
|
ConfirmationCallback | None
|
Handler callback for tool / step confirmations. |
None
|
Source code in src/llmling_agent/delegation/pool.py
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 |
|
cleanup
async
¶
cleanup()
Clean up all agents.
Source code in src/llmling_agent/delegation/pool.py
178 179 180 181 182 183 184 |
|
clone_agent
async
¶
clone_agent(
agent: Agent[TDeps] | str,
new_name: str | None = None,
*,
model_override: str | None = None,
system_prompts: list[str] | None = None,
template_context: dict[str, Any] | None = None,
) -> Agent[TDeps]
Create a copy of an agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent
|
Agent[TDeps] | str
|
Agent instance or name to clone |
required |
new_name
|
str | None
|
Optional name for the clone |
None
|
model_override
|
str | None
|
Optional different model |
None
|
system_prompts
|
list[str] | None
|
Optional different prompts |
None
|
template_context
|
dict[str, Any] | None
|
Variables for template rendering |
None
|
Returns:
Type | Description |
---|---|
Agent[TDeps]
|
The new agent instance |
Source code in src/llmling_agent/delegation/pool.py
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 |
|
controlled_conversation
async
¶
controlled_conversation(
initial_agent: str | Agent[Any] = "starter",
initial_prompt: str = "Hello!",
decision_callback: DecisionCallback = interactive_controller,
)
Start a controlled conversation between agents.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
initial_agent
|
str | Agent[Any]
|
Agent instance or name to start with |
'starter'
|
initial_prompt
|
str
|
First message to start conversation |
'Hello!'
|
decision_callback
|
DecisionCallback
|
Callback for routing decisions |
interactive_controller
|
Source code in src/llmling_agent/delegation/pool.py
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
|
create_agent
async
¶
create_agent(name: str, config: AgentConfig, *, temporary: bool = True) -> Agent[Any]
Create and register a new agent in the pool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the new agent |
required |
config
|
AgentConfig
|
Agent configuration |
required |
temporary
|
bool
|
If True, agent won't be added to manifest |
True
|
Returns:
Type | Description |
---|---|
Agent[Any]
|
Created and initialized agent |
Raises:
Type | Description |
---|---|
ValueError
|
If agent name already exists |
RuntimeError
|
If agent initialization fails |
Source code in src/llmling_agent/delegation/pool.py
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 |
|
create_group
¶
create_group(
agents: Sequence[str | AnyAgent[TDeps, Any]] | None = None,
*,
model_override: str | None = None,
environment_override: StrPath | Config | None = None,
shared_prompt: str | None = None,
shared_deps: TDeps | None = None,
) -> Team[TDeps]
Create a group from agent names or instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agents
|
Sequence[str | AnyAgent[TDeps, Any]] | None
|
List of agent names or instances (all if None) |
None
|
model_override
|
str | None
|
Optional model to use for all agents |
None
|
environment_override
|
StrPath | Config | None
|
Optional environment for all agents |
None
|
shared_prompt
|
str | None
|
Optional prompt for all agents |
None
|
shared_deps
|
TDeps | None
|
Optional shared dependencies |
None
|
Source code in src/llmling_agent/delegation/pool.py
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 |
|
get_agent
¶
get_agent(
agent: str | Agent[Any],
*,
deps: TDeps,
return_type: type[TResult],
model_override: str | None = None,
session: SessionIdType | SessionQuery = None,
environment_override: StrPath | Config | None = None,
) -> StructuredAgent[TDeps, TResult]
get_agent(
agent: str | Agent[Any],
*,
deps: TDeps,
model_override: str | None = None,
session: SessionIdType | SessionQuery = None,
environment_override: StrPath | Config | None = None,
) -> Agent[TDeps]
get_agent(
agent: str | Agent[Any],
*,
deps: TDeps | None = None,
return_type: type[TResult] | None = None,
model_override: str | None = None,
session: SessionIdType | SessionQuery = None,
environment_override: StrPath | Config | None = None,
) -> AnyAgent[TDeps, TResult]
Get or wrap an agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent
|
str | Agent[Any]
|
Either agent name or instance |
required |
deps
|
TDeps | None
|
Dependencies for the agent |
None
|
return_type
|
type[TResult] | None
|
Optional type to make agent structured |
None
|
model_override
|
str | None
|
Optional model override |
None
|
session
|
SessionIdType | SessionQuery
|
Optional session ID or Session query to recover conversation |
None
|
environment_override
|
StrPath | Config | None
|
Optional environment configuration: - Path to environment file - Complete Config instance - None to use agent's default environment |
None
|
Returns:
Type | Description |
---|---|
AnyAgent[TDeps, TResult]
|
Either regular Agent or StructuredAgent depending on return_type |
Raises:
Type | Description |
---|---|
KeyError
|
If agent name not found |
ValueError
|
If environment configuration is invalid |
Source code in src/llmling_agent/delegation/pool.py
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 |
|
list_agents
¶
List available agent names.
Source code in src/llmling_agent/delegation/pool.py
600 601 602 |
|
open
async
classmethod
¶
open(
config_path: StrPath | AgentsManifest[TDeps, TResult] | None = None,
*,
agents: list[str] | None = None,
connect_agents: bool = True,
confirmation_callback: ConfirmationCallback | None = None,
) -> AsyncIterator[AgentPool]
Open an agent pool from configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_path
|
StrPath | AgentsManifest[TDeps, TResult] | None
|
Path to agent configuration file or manifest |
None
|
agents
|
list[str] | None
|
Optional list of agent names to initialize |
None
|
connect_agents
|
bool
|
Whether to set up forwarding connections |
True
|
confirmation_callback
|
ConfirmationCallback | None
|
Callback to confirm agent tool selection |
None
|
Yields:
Type | Description |
---|---|
AsyncIterator[AgentPool]
|
Configured agent pool |
Source code in src/llmling_agent/delegation/pool.py
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 |
|
setup_agent_workers
¶
Set up workers for an agent from configuration.
Source code in src/llmling_agent/delegation/pool.py
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
|
start_supervision
¶
start_supervision() -> OptionalAwaitable[None]
Start supervision interface.
Can be called either synchronously or asynchronously:
Sync usage:¶
start_supervision(pool)
Async usage:¶
await start_supervision(pool)
Source code in src/llmling_agent/delegation/pool.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
AgentPoolView
¶
User's view and control point for interacting with an agent in a pool.
This class provides a focused way to interact with one primary agent that is part of a larger agent pool. Through this view, users can: 1. Interact with the primary agent directly 2. Manage connections to other agents in the pool 3. Control tool availability and settings 4. Handle commands and responses
Think of it as looking at the agent pool through the lens of one specific agent, while still being able to utilize the pool's collaborative capabilities.
Source code in src/llmling_agent/chat_session/base.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 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 |
|
SessionReset
dataclass
¶
Emitted when session is reset.
Source code in src/llmling_agent/chat_session/base.py
53 54 55 56 57 58 59 60 |
|
__init__
¶
Initialize chat session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent
|
AnyAgent[Any, Any]
|
The LLMling agent to use |
required |
pool
|
AgentPool | None
|
Optional agent pool for multi-agent interactions |
None
|
wait_chain
|
bool
|
Whether to wait for chain completion |
True
|
Source code in src/llmling_agent/chat_session/base.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
add_command
¶
add_command(command: str)
Add command to history.
Source code in src/llmling_agent/chat_session/base.py
176 177 178 179 180 181 182 183 |
|
cleanup
async
¶
cleanup()
Clean up session resources.
Source code in src/llmling_agent/chat_session/base.py
171 172 173 174 |
|
clear
async
¶
clear()
Clear chat history.
Source code in src/llmling_agent/chat_session/base.py
198 199 200 |
|
connect_to
async
¶
Connect to another agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
str
|
Name of target agent |
required |
wait
|
bool | None
|
Override session's wait_chain setting |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If target agent not found or pool not available |
Source code in src/llmling_agent/chat_session/base.py
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 |
|
create
async
classmethod
¶
create(
agent: Agent[Any], *, pool: AgentPool | None = None, wait_chain: bool = True
) -> AgentPoolView
Create and initialize a new agent pool view.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent
|
Agent[Any]
|
The primary agent to interact with |
required |
pool
|
AgentPool | None
|
Optional agent pool for multi-agent interactions |
None
|
wait_chain
|
bool
|
Whether to wait for chain completion |
True
|
Returns:
Type | Description |
---|---|
AgentPoolView
|
Initialized AgentPoolView |
Source code in src/llmling_agent/chat_session/base.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
get_commands
¶
Get command history ordered by newest first.
Source code in src/llmling_agent/chat_session/base.py
185 186 187 188 189 190 191 192 193 194 195 196 |
|
handle_command
async
¶
Handle a slash command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command_str
|
str
|
Command string without leading slash |
required |
output
|
OutputWriter
|
Output writer implementation |
required |
metadata
|
dict[str, Any] | None
|
Optional interface-specific metadata |
None
|
Source code in src/llmling_agent/chat_session/base.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
|
initialize
async
¶
initialize()
Initialize async resources and load data.
Source code in src/llmling_agent/chat_session/base.py
158 159 160 161 162 163 164 165 166 167 168 169 |
|
reset
async
¶
reset()
Reset session state.
Source code in src/llmling_agent/chat_session/base.py
202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
send_message
async
¶
send_message(
content: str,
*,
stream: Literal[False] = False,
output: OutputWriter | None = None,
metadata: dict[str, Any] | None = None,
) -> ChatMessage[str]
send_message(
content: str,
*,
stream: Literal[True],
output: OutputWriter | None = None,
metadata: dict[str, Any] | None = None,
) -> AsyncIterator[ChatMessage[str]]
send_message(
content: str,
*,
stream: bool = False,
output: OutputWriter | None = None,
metadata: dict[str, Any] | None = None,
) -> ChatMessage[str] | AsyncIterator[ChatMessage[str]]
Send a message and get response(s).
Source code in src/llmling_agent/chat_session/base.py
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 |
|
AgentRouter
¶
Base class for routing messages between agents.
Source code in src/llmling_agent/delegation/router.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
decide
async
¶
Make routing decision for message.
Source code in src/llmling_agent/delegation/router.py
107 108 109 |
|
get_end_decision
¶
Create decision to end routing.
Source code in src/llmling_agent/delegation/router.py
123 124 125 |
|
get_route_decision
¶
Create decision to route without waiting.
Source code in src/llmling_agent/delegation/router.py
119 120 121 |
|
get_wait_decision
¶
Create decision to route and wait for response.
Source code in src/llmling_agent/delegation/router.py
111 112 113 114 115 116 117 |
|
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/agents.py
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 |
|
agents
class-attribute
instance-attribute
¶
agents: dict[str, AgentConfig] = Field(default_factory=dict)
Mapping of agent IDs to their configurations
mcp_servers
class-attribute
instance-attribute
¶
List of MCP server configurations: - str entries are converted to StdioMCPServer - MCPServerConfig for full server configuration
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.
tasks
class-attribute
instance-attribute
¶
Pre-defined tasks, ready to be used by agents.
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/agents.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 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 |
|
create_pool
async
¶
create_pool(
*,
agents_to_load: list[str] | None = None,
connect_agents: bool = True,
session_id: SessionIdType = None,
) -> AgentPool
Create an agent pool from this manifest.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agents_to_load
|
list[str] | None
|
Optional list of agents to initialize |
None
|
connect_agents
|
bool
|
Whether to set up forwarding connections |
True
|
session_id
|
SessionIdType
|
Optional session ID for conversation recovery |
None
|
Returns:
Type | Description |
---|---|
AgentPool
|
Configured agent pool |
Source code in src/llmling_agent/models/agents.py
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 |
|
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/agents.py
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 |
|
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/agents.py
690 691 692 693 694 695 696 697 698 699 700 701 702 |
|
open_agent
async
¶
open_agent(
agent_name: str,
*,
model: str | None = None,
session: SessionIdType | SessionQuery = None,
) -> AsyncIterator[AnyAgent[TDeps, Any]]
Open and configure a specific agent from configuration.
Creates the agent in the context of a single-agent pool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent_name
|
str
|
Name of the agent to load |
required |
model
|
str | None
|
Optional model override |
None
|
session
|
SessionIdType | SessionQuery
|
Optional ID or SessionQuery to recover a previous state |
None
|
Example
manifest = AgentsManifest[Any, str].from_file("agents.yml") async with manifest.open_agent("my-agent") as agent: result = await agent.run("Hello!")
Source code in src/llmling_agent/models/agents.py
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 |
|
resolve_inheritance
classmethod
¶
Resolve agent inheritance chains.
Source code in src/llmling_agent/models/agents.py
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 |
|
AwaitResponseDecision
¶
Bases: Decision
Forward message and wait for response.
Source code in src/llmling_agent/delegation/router.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
talk_back
class-attribute
instance-attribute
¶
talk_back: bool = False
Whether to send response back to original agent.
type
class-attribute
instance-attribute
¶
type: Literal['await_response'] = Field('await_response', init=False)
Type discriminator for await decisions.
execute
async
¶
execute(message: ChatMessage[Any], source_agent: AnyAgent[Any, Any], pool: AgentPool)
Forward message and wait for response.
Source code in src/llmling_agent/delegation/router.py
76 77 78 79 80 81 82 83 84 85 86 |
|
CallbackRouter
¶
Bases: AgentRouter
Router using callback function for decisions.
Source code in src/llmling_agent/delegation/router.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
decide
async
¶
decide(message: TMessage) -> Decision
Execute callback and handle sync/async appropriately.
Source code in src/llmling_agent/delegation/router.py
139 140 141 142 143 144 |
|
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/models/messages.py
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 |
|
content
instance-attribute
¶
content: TContent
Message content, typed as TContent (either str or BaseModel).
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.
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
¶
List of tool calls made during message generation.
format
¶
format(
style: Literal["simple", "detailed", "markdown"] = "simple",
*,
show_metadata: bool = False,
show_costs: bool = False,
) -> str
Format message with configurable style.
Source code in src/llmling_agent/models/messages.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
to_gradio_format
¶
Convert to Gradio chatbot format.
Source code in src/llmling_agent/models/messages.py
147 148 149 150 151 152 153 154 155 156 |
|
to_text_message
¶
to_text_message() -> ChatMessage[str]
Convert this message to a text-only version.
Source code in src/llmling_agent/models/messages.py
132 133 134 |
|
Decision
¶
Bases: BaseModel
Base class for all routing decisions.
Source code in src/llmling_agent/delegation/router.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
type
class-attribute
instance-attribute
¶
type: str = Field(init=False)
Discriminator field for decision types.
execute
async
¶
execute(message: ChatMessage[Any], source_agent: AnyAgent[Any, Any], pool: AgentPool)
Execute this routing decision.
Source code in src/llmling_agent/delegation/router.py
34 35 36 37 38 39 40 41 |
|
EndDecision
¶
Bases: Decision
End the conversation.
Source code in src/llmling_agent/delegation/router.py
89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
type
class-attribute
instance-attribute
¶
type: Literal['end'] = Field('end', init=False)
Type discriminator for end decisions.
execute
async
¶
execute(message: ChatMessage[Any], source_agent: AnyAgent[Any, Any], pool: AgentPool)
End the conversation.
Source code in src/llmling_agent/delegation/router.py
95 96 97 98 99 100 101 |
|
RouteDecision
¶
Bases: Decision
Forward message without waiting for response.
Source code in src/llmling_agent/delegation/router.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
type
class-attribute
instance-attribute
¶
type: Literal['route'] = Field('route', init=False)
Type discriminator for routing decisions.
execute
async
¶
execute(message: ChatMessage[Any], source_agent: AnyAgent[Any, Any], pool: AgentPool)
Forward message and continue.
Source code in src/llmling_agent/delegation/router.py
53 54 55 56 57 58 59 60 61 |
|
RuleRouter
¶
Bases: AgentRouter
Router using predefined rules.
Source code in src/llmling_agent/delegation/router.py
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 |
|
decide
async
¶
Make decision based on configured rules.
Source code in src/llmling_agent/delegation/router.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 |
|
SlashedAgent
¶
Wraps an agent with slash command support.
Source code in src/llmling_agent/agent/slashed_agent.py
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 |
|
handle_command
async
¶
handle_command(
command: str,
output: OutputWriter | None = None,
metadata: dict[str, Any] | None = None,
) -> ChatMessage[str]
Handle a slash command.
Source code in src/llmling_agent/agent/slashed_agent.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
run
async
¶
run(
*prompt: AnyPromptType,
result_type: type[TMethodResult],
deps: TDeps | None = None,
model: ModelType = None,
output: OutputWriter | None = None,
metadata: dict[str, Any] | None = None,
) -> ChatMessage[TMethodResult]
run(
*prompt: AnyPromptType,
result_type: None = None,
deps: TDeps | None = None,
model: ModelType = None,
output: OutputWriter | None = None,
metadata: dict[str, Any] | None = None,
) -> ChatMessage[str]
run(
*prompt: AnyPromptType,
result_type: type[Any] | None = None,
deps: TDeps | None = None,
model: ModelType = None,
output: OutputWriter | None = None,
metadata: dict[str, Any] | None = None,
) -> ChatMessage[Any]
Run with slash command support.
Source code in src/llmling_agent/agent/slashed_agent.py
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 |
|
run_stream
async
¶
run_stream(
*prompt: AnyPromptType,
result_type: type[TMethodResult],
deps: TDeps | None = None,
model: ModelType = None,
output: OutputWriter | None = None,
metadata: dict[str, Any] | None = None,
) -> AbstractAsyncContextManager[StreamedRunResult[AgentContext[TDeps], TMethodResult]]
run_stream(
*prompt: AnyPromptType,
result_type: None = None,
deps: TDeps | None = None,
model: ModelType = None,
output: OutputWriter | None = None,
metadata: dict[str, Any] | None = None,
) -> AbstractAsyncContextManager[StreamedRunResult[AgentContext[TDeps], str]]
run_stream(
*prompt: AnyPromptType,
result_type: type[Any] | None = None,
deps: TDeps | None = None,
model: ModelType = None,
output: OutputWriter | None = None,
metadata: dict[str, Any] | None = None,
) -> AsyncIterator[StreamedRunResult[AgentContext[TDeps], Any]]
Stream responses with slash command support.
Source code in src/llmling_agent/agent/slashed_agent.py
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 |
|
StructuredAgent
¶
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
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
__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
86 87 88 89 90 91 92 93 |
|
__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
95 96 97 98 99 100 101 102 |
|
__init__
¶
__init__(
agent: AnyAgent[TDeps, 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
|
AnyAgent[TDeps, 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
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 |
|
run
async
¶
run(
*prompt: AnyPromptType | TResult,
result_type: type[TResult] | None = None,
deps: TDeps | None = None,
model: ModelType = 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
|
deps
|
TDeps | None
|
Optional dependencies for the agent |
None
|
message_history
|
Optional previous messages for context |
required | |
model
|
ModelType
|
Optional model override |
None
|
usage
|
Optional usage tracking |
required |
Source code in src/llmling_agent/agent/structured.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
SystemPrompt
¶
Bases: BaseModel
System prompt configuration for agent behavior control.
Defines prompts that set up the agent's behavior and context. Supports multiple types: - Static text prompts - Dynamic function-based prompts - Template prompts with variable substitution
Source code in src/llmling_agent/models/prompts.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
interactive_controller
async
¶
interactive_controller(
message: str, pool: AgentPool, agent_router: AgentRouter
) -> Decision
Interactive conversation control through console input.
Source code in src/llmling_agent/delegation/controllers.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|