resource_providers
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| AggregatingResourceProvider llmling_agent.resource_providers.aggregating Provider that combines resources from multiple providers. |
||
| MCPResourceProvider llmling_agent.resource_providers.mcp_provider Resource provider for a single MCP server. |
||
| PlanProvider llmling_agent.resource_providers.plan_provider Provides plan-related tools for agent planning and task management. |
||
| ResourceProvider llmling_agent.resource_providers.base Base class for resource providers. |
||
| StaticResourceProvider llmling_agent.resource_providers.static Provider for pre-configured tools, prompts and resources. |
🛈 DocStrings¶
Resource provider implementations.
AggregatingResourceProvider
¶
Bases: ResourceProvider
Provider that combines resources from multiple providers.
Source code in src/llmling_agent/resource_providers/aggregating.py
18 19 20 21 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 | |
__init__
¶
__init__(providers: list[ResourceProvider], name: str = 'aggregating') -> None
Initialize provider with list of providers to aggregate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
providers
|
list[ResourceProvider]
|
Resource providers to aggregate (stores reference to list) |
required |
name
|
str
|
Name for this provider |
'aggregating'
|
Source code in src/llmling_agent/resource_providers/aggregating.py
21 22 23 24 25 26 27 28 29 30 | |
get_prompts
async
¶
get_prompts() -> list[BasePrompt]
Get prompts from all providers.
Source code in src/llmling_agent/resource_providers/aggregating.py
36 37 38 | |
get_request_parts
async
¶
get_request_parts(name: str, arguments: dict[str, str] | None = None) -> list[ModelRequestPart]
Try to get prompt from first provider that has it.
Source code in src/llmling_agent/resource_providers/aggregating.py
44 45 46 47 48 49 50 51 52 53 54 | |
get_resources
async
¶
get_resources() -> list[ResourceInfo]
Get resources from all providers.
Source code in src/llmling_agent/resource_providers/aggregating.py
40 41 42 | |
get_tools
async
¶
Get tools from all providers.
Source code in src/llmling_agent/resource_providers/aggregating.py
32 33 34 | |
MCPResourceProvider
¶
Bases: ResourceProvider
Resource provider for a single MCP server.
Source code in src/llmling_agent/resource_providers/mcp_provider.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 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 | |
get_prompts
async
¶
get_prompts() -> list[MCPClientPrompt]
Get cached prompts, refreshing if necessary.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
173 174 175 176 177 178 | |
get_resources
async
¶
get_resources() -> list[ResourceInfo]
Get cached resources, refreshing if necessary.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
200 201 202 203 204 205 | |
get_tools
async
¶
Get cached tools, refreshing if necessary.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
144 145 146 147 148 149 | |
refresh_prompts_cache
async
¶
refresh_prompts_cache() -> None
Refresh the prompts cache by fetching from client.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
refresh_resources_cache
async
¶
refresh_resources_cache() -> None
Refresh the resources cache by fetching from client.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
refresh_tools_cache
async
¶
refresh_tools_cache() -> None
Refresh the tools cache by fetching from client.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
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 | |
PlanProvider
¶
Bases: ResourceProvider
Provides plan-related tools for agent planning and task management.
This provider creates tools for managing agent plans and tasks, emitting domain events that can be handled by protocol adapters.
Source code in src/llmling_agent/resource_providers/plan_provider.py
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 | |
__init__
¶
__init__() -> None
Initialize plan provider.
Source code in src/llmling_agent/resource_providers/plan_provider.py
56 57 58 59 | |
add_plan_entry
async
¶
add_plan_entry(
agent_ctx: AgentContext,
content: str,
priority: PlanEntryPriority = "medium",
index: int | None = None,
) -> str
Add a new plan entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_ctx
|
AgentContext
|
Agent execution context |
required |
content
|
str
|
Description of what this task aims to accomplish |
required |
priority
|
PlanEntryPriority
|
Relative importance (high/medium/low) |
'medium'
|
index
|
int | None
|
Optional position to insert at (default: append to end) |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Success message indicating entry was added |
Source code in src/llmling_agent/resource_providers/plan_provider.py
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 | |
get_plan
async
¶
get_plan(agent_ctx: AgentContext) -> str
Get the current plan formatted as markdown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_ctx
|
AgentContext
|
Agent execution context |
required |
Returns:
| Type | Description |
|---|---|
str
|
Markdown-formatted plan with all entries and their status |
Source code in src/llmling_agent/resource_providers/plan_provider.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 | |
get_tools
async
¶
Get plan management tools.
Source code in src/llmling_agent/resource_providers/plan_provider.py
61 62 63 64 65 66 67 68 | |
remove_plan_entry
async
¶
remove_plan_entry(agent_ctx: AgentContext, index: int) -> str
Remove a plan entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_ctx
|
AgentContext
|
Agent execution context |
required |
index
|
int
|
Position of entry to remove (0-based) |
required |
Returns:
| Type | Description |
|---|---|
str
|
Success message indicating entry was removed |
Source code in src/llmling_agent/resource_providers/plan_provider.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
update_plan_entry
async
¶
update_plan_entry(
agent_ctx: AgentContext,
index: int,
content: str | None = None,
status: PlanEntryStatus | None = None,
priority: PlanEntryPriority | None = None,
) -> str
Update an existing plan entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_ctx
|
AgentContext
|
Agent execution context |
required |
index
|
int
|
Position of entry to update (0-based) |
required |
content
|
str | None
|
New task description |
None
|
status
|
PlanEntryStatus | None
|
New execution status |
None
|
priority
|
PlanEntryPriority | None
|
New priority level |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Success message indicating what was updated |
Source code in src/llmling_agent/resource_providers/plan_provider.py
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 | |
ResourceProvider
¶
Base class for resource providers.
Provides tools, prompts, and other resources to agents. Default implementations return empty lists - override as needed.
Source code in src/llmling_agent/resource_providers/base.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 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 | |
__aenter__
async
¶
__aenter__() -> Self
Async context entry if required.
Source code in src/llmling_agent/resource_providers/base.py
41 42 43 | |
__aexit__
async
¶
__aexit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None
Async context cleanup if required.
Source code in src/llmling_agent/resource_providers/base.py
45 46 47 48 49 50 51 | |
__init__
¶
__init__(name: str, owner: str | None = None) -> None
Initialize the resource provider.
Source code in src/llmling_agent/resource_providers/base.py
35 36 37 38 39 | |
create_tool
¶
create_tool(
fn: Callable[..., Any],
read_only: bool | None = None,
destructive: bool | None = None,
idempotent: bool | None = None,
open_world: bool | None = None,
requires_confirmation: bool = False,
metadata: dict[str, Any] | None = None,
category: ToolKind | None = None,
name_override: str | None = None,
description_override: str | None = None,
schema_override: OpenAIFunctionDefinition | None = None,
) -> Tool
Create a tool from a function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable[..., Any]
|
Function to create a tool from |
required |
read_only
|
bool | None
|
Whether the tool is read-only |
None
|
destructive
|
bool | None
|
Whether the tool is destructive |
None
|
idempotent
|
bool | None
|
Whether the tool is idempotent |
None
|
open_world
|
bool | None
|
Whether the tool is open-world |
None
|
requires_confirmation
|
bool
|
Whether the tool requires confirmation |
False
|
metadata
|
dict[str, Any] | None
|
Metadata for the tool |
None
|
category
|
ToolKind | None
|
Category of the tool |
None
|
name_override
|
str | None
|
Override the name of the tool |
None
|
description_override
|
str | None
|
Override the description of the tool |
None
|
schema_override
|
OpenAIFunctionDefinition | None
|
Override the schema of the tool |
None
|
Returns:
| Type | Description |
|---|---|
Tool
|
Tool created from the function |
Source code in src/llmling_agent/resource_providers/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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
get_prompts
async
¶
get_prompts() -> list[BasePrompt]
Get available prompts. Override to provide prompts.
Source code in src/llmling_agent/resource_providers/base.py
69 70 71 | |
get_request_parts
async
¶
get_request_parts(name: str, arguments: dict[str, str] | None = None) -> list[ModelRequestPart]
Get a prompt formatted with arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the prompt to format |
required |
arguments
|
dict[str, str] | None
|
Optional arguments for prompt formatting |
None
|
Returns:
| Type | Description |
|---|---|
list[ModelRequestPart]
|
Single chat message with merged content |
Raises:
| Type | Description |
|---|---|
KeyError
|
If prompt not found |
ValueError
|
If formatting fails |
Source code in src/llmling_agent/resource_providers/base.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 | |
get_resources
async
¶
get_resources() -> list[ResourceInfo]
Get available resources. Override to provide resources.
Source code in src/llmling_agent/resource_providers/base.py
73 74 75 | |
get_skill_instructions
async
¶
get_skill_instructions(skill_name: str) -> str
Get full instructions for a specific skill.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skill_name
|
str
|
Name of the skill to get instructions for |
required |
Returns:
| Type | Description |
|---|---|
str
|
The full skill instructions for execution |
Raises:
| Type | Description |
|---|---|
KeyError
|
If skill not found |
Source code in src/llmling_agent/resource_providers/base.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
get_skills
async
¶
Get available skills. Override to provide skills.
Source code in src/llmling_agent/resource_providers/base.py
77 78 79 | |
get_tool
async
¶
get_tool(tool_name: str) -> Tool
Get specific tool.
Source code in src/llmling_agent/resource_providers/base.py
60 61 62 63 64 65 66 67 | |
StaticResourceProvider
¶
Bases: ResourceProvider
Provider for pre-configured tools, prompts and resources.
Allows creating a provider that serves a fixed set of resources passed during initialization. Useful for converting static configurations to the common ResourceProvider interface.
Source code in src/llmling_agent/resource_providers/static.py
21 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 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 | |
__init__
¶
__init__(
name: str = "static",
tools: Sequence[Tool] | None = None,
prompts: Sequence[BasePrompt] | None = None,
resources: Sequence[ResourceInfo] | None = None,
) -> None
Initialize provider with static resources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the provider |
'static'
|
tools
|
Sequence[Tool] | None
|
Optional list of tools to serve |
None
|
prompts
|
Sequence[BasePrompt] | None
|
Optional list of prompts to serve |
None
|
resources
|
Sequence[ResourceInfo] | None
|
Optional list of resources to serve |
None
|
Source code in src/llmling_agent/resource_providers/static.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
add_prompt
¶
add_prompt(prompt: BasePrompt) -> None
Add a prompt to this provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
BasePrompt
|
Prompt to add |
required |
Source code in src/llmling_agent/resource_providers/static.py
84 85 86 87 88 89 90 | |
add_resource
¶
add_resource(resource: ResourceInfo) -> None
Add a resource to this provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
ResourceInfo
|
Resource to add |
required |
Source code in src/llmling_agent/resource_providers/static.py
107 108 109 110 111 112 113 | |
add_tool
¶
add_tool(tool: Tool) -> None
Add a tool to this provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
Tool
|
Tool to add |
required |
Source code in src/llmling_agent/resource_providers/static.py
61 62 63 64 65 66 67 | |
get_prompts
async
¶
get_prompts() -> list[BasePrompt]
Get pre-configured prompts.
Source code in src/llmling_agent/resource_providers/static.py
53 54 55 | |
get_resources
async
¶
get_resources() -> list[ResourceInfo]
Get pre-configured resources.
Source code in src/llmling_agent/resource_providers/static.py
57 58 59 | |
get_tools
async
¶
Get pre-configured tools.
Source code in src/llmling_agent/resource_providers/static.py
49 50 51 | |
register_tool
¶
register_tool(
tool: ToolType | Tool,
*,
name_override: str | None = None,
description_override: str | None = None,
enabled: bool = True,
source: ToolSource = "dynamic",
requires_confirmation: bool = False,
metadata: dict[str, str] | None = None
) -> Tool
Register a new tool with custom settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
ToolType | Tool
|
Tool to register (callable, Tool instance, or import path) |
required |
name_override
|
str | None
|
Optional name override for the tool |
None
|
description_override
|
str | None
|
Optional description override for the tool |
None
|
enabled
|
bool
|
Whether tool is initially enabled |
True
|
source
|
ToolSource
|
Tool source (runtime/agent/builtin/dynamic) |
'dynamic'
|
requires_confirmation
|
bool
|
Whether tool needs confirmation |
False
|
metadata
|
dict[str, str] | None
|
Additional tool metadata |
None
|
Returns:
| Type | Description |
|---|---|
Tool
|
Created Tool instance |
Source code in src/llmling_agent/resource_providers/static.py
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 | |
register_worker
¶
register_worker(
worker: MessageNode[Any, Any],
*,
name: str | None = None,
reset_history_on_run: bool = True,
pass_message_history: bool = False,
parent: Agent[Any, Any] | None = None
) -> Tool
Register an agent as a worker tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
worker
|
MessageNode[Any, Any]
|
Agent to register as worker |
required |
name
|
str | None
|
Optional name override for the worker tool |
None
|
reset_history_on_run
|
bool
|
Whether to clear history before each run |
True
|
pass_message_history
|
bool
|
Whether to pass parent's message history |
False
|
parent
|
Agent[Any, Any] | None
|
Optional parent agent for history/context sharing |
None
|
Source code in src/llmling_agent/resource_providers/static.py
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 | |
remove_prompt
¶
remove_prompt(name: str) -> bool
Remove a prompt by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of prompt to remove |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if prompt was found and removed, False otherwise |
Source code in src/llmling_agent/resource_providers/static.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
remove_resource
¶
remove_resource(name: str) -> bool
Remove a resource by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of resource to remove |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if resource was found and removed, False otherwise |
Source code in src/llmling_agent/resource_providers/static.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
remove_tool
¶
remove_tool(name: str) -> bool
Remove a tool by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of tool to remove |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if tool was found and removed, False otherwise |
Source code in src/llmling_agent/resource_providers/static.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
tool
¶
tool(func: Callable[..., Any]) -> Callable[..., Any]
tool(
*,
name: str | None = None,
description: str | None = None,
enabled: bool = True,
requires_confirmation: bool = False,
metadata: dict[str, str] | None = None,
**kwargs: Any
) -> Callable[[Callable[..., Any]], Callable[..., Any]]
tool(
func: Callable[..., Any] | None = None,
*,
name: str | None = None,
description: str | None = None,
enabled: bool = True,
requires_confirmation: bool = False,
metadata: dict[str, str] | None = None,
**kwargs: Any
) -> Callable[..., Any] | Callable[[Callable[..., Any]], Callable[..., Any]]
Decorator to register a function as a tool.
Can be used with or without parameters:
# Without parameters
@provider.tool
def my_function(x: int) -> str:
return str(x)
# With parameters
@provider.tool(name="custom_name", description="Custom description")
def another_function(y: str) -> str:
return y.upper()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any] | None
|
Function to register (when used without parentheses) |
None
|
name
|
str | None
|
Override for tool name |
None
|
description
|
str | None
|
Override for tool description |
None
|
enabled
|
bool
|
Whether tool is initially enabled |
True
|
requires_confirmation
|
bool
|
Whether execution needs confirmation |
False
|
metadata
|
dict[str, str] | None
|
Additional tool metadata |
None
|
**kwargs
|
Any
|
Additional arguments passed to Tool.from_callable |
{}
|
Source code in src/llmling_agent/resource_providers/static.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |