mcp-mesh 0.6.1__py3-none-any.whl → 0.6.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- _mcp_mesh/__init__.py +1 -1
- _mcp_mesh/engine/llm_config.py +10 -1
- _mcp_mesh/engine/mesh_llm_agent.py +51 -33
- _mcp_mesh/engine/mesh_llm_agent_injector.py +72 -9
- _mcp_mesh/engine/provider_handlers/claude_handler.py +322 -42
- _mcp_mesh/engine/provider_handlers/openai_handler.py +65 -9
- _mcp_mesh/engine/response_parser.py +54 -15
- _mcp_mesh/pipeline/api_heartbeat/api_dependency_resolution.py +54 -21
- _mcp_mesh/pipeline/mcp_heartbeat/dependency_resolution.py +43 -26
- {mcp_mesh-0.6.1.dist-info → mcp_mesh-0.6.3.dist-info}/METADATA +1 -1
- {mcp_mesh-0.6.1.dist-info → mcp_mesh-0.6.3.dist-info}/RECORD +14 -14
- {mcp_mesh-0.6.1.dist-info → mcp_mesh-0.6.3.dist-info}/WHEEL +1 -1
- mesh/decorators.py +39 -2
- {mcp_mesh-0.6.1.dist-info → mcp_mesh-0.6.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -228,11 +228,10 @@ class APIDependencyResolutionStep(PipelineStep):
|
|
|
228
228
|
|
|
229
229
|
# Import here to avoid circular imports
|
|
230
230
|
from ...engine.dependency_injector import get_global_injector
|
|
231
|
-
from ...engine.full_mcp_proxy import EnhancedFullMCPProxy,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
)
|
|
231
|
+
from ...engine.full_mcp_proxy import (EnhancedFullMCPProxy,
|
|
232
|
+
FullMCPProxy)
|
|
233
|
+
from ...engine.mcp_client_proxy import (EnhancedMCPClientProxy,
|
|
234
|
+
MCPClientProxy)
|
|
236
235
|
|
|
237
236
|
injector = get_global_injector()
|
|
238
237
|
|
|
@@ -289,13 +288,16 @@ class APIDependencyResolutionStep(PipelineStep):
|
|
|
289
288
|
# Import here to avoid circular imports
|
|
290
289
|
import os
|
|
291
290
|
|
|
292
|
-
from ...engine.self_dependency_proxy import
|
|
293
|
-
|
|
291
|
+
from ...engine.self_dependency_proxy import \
|
|
292
|
+
SelfDependencyProxy
|
|
293
|
+
from ...engine.unified_mcp_proxy import \
|
|
294
|
+
EnhancedUnifiedMCPProxy
|
|
294
295
|
|
|
295
296
|
# Get current agent ID for self-dependency detection
|
|
296
297
|
current_agent_id = None
|
|
297
298
|
try:
|
|
298
|
-
from ...engine.decorator_registry import
|
|
299
|
+
from ...engine.decorator_registry import \
|
|
300
|
+
DecoratorRegistry
|
|
299
301
|
|
|
300
302
|
config = DecoratorRegistry.get_resolved_agent_config()
|
|
301
303
|
current_agent_id = config["agent_id"]
|
|
@@ -328,18 +330,48 @@ class APIDependencyResolutionStep(PipelineStep):
|
|
|
328
330
|
)
|
|
329
331
|
|
|
330
332
|
if is_self_dependency:
|
|
331
|
-
#
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
333
|
+
# Create self-dependency proxy with WRAPPER function (not original)
|
|
334
|
+
# The wrapper has dependency injection logic, so calling it ensures
|
|
335
|
+
# the target function's dependencies are also injected properly.
|
|
336
|
+
wrapper_func = None
|
|
337
|
+
if dep_function_name in mesh_tools:
|
|
338
|
+
wrapper_func = mesh_tools[dep_function_name].function
|
|
339
|
+
self.logger.debug(
|
|
340
|
+
f"🔍 Found wrapper for '{dep_function_name}' in DecoratorRegistry"
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
if wrapper_func:
|
|
344
|
+
new_proxy = SelfDependencyProxy(
|
|
345
|
+
wrapper_func, dep_function_name
|
|
346
|
+
)
|
|
347
|
+
self.logger.info(
|
|
348
|
+
f"🔄 API SELF-DEPENDENCY: Using wrapper for '{capability}' "
|
|
349
|
+
f"(local call with full DI support)"
|
|
350
|
+
)
|
|
351
|
+
else:
|
|
352
|
+
# Fallback to original function if wrapper not found
|
|
353
|
+
original_func = injector.find_original_function(
|
|
354
|
+
dep_function_name
|
|
355
|
+
)
|
|
356
|
+
if original_func:
|
|
357
|
+
new_proxy = SelfDependencyProxy(
|
|
358
|
+
original_func, dep_function_name
|
|
359
|
+
)
|
|
360
|
+
self.logger.warning(
|
|
361
|
+
f"⚠️ API SELF-DEPENDENCY: Using original function for '{capability}' "
|
|
362
|
+
f"(wrapper not found, DI may not work for nested deps)"
|
|
363
|
+
)
|
|
364
|
+
else:
|
|
365
|
+
self.logger.warning(
|
|
366
|
+
f"⚠️ API SELF-DEPENDENCY: Cannot create SelfDependencyProxy for '{capability}', "
|
|
367
|
+
f"falling back to HTTP (may cause issues)"
|
|
368
|
+
)
|
|
369
|
+
# Fall back to unified proxy (same as cross-service)
|
|
370
|
+
new_proxy = EnhancedUnifiedMCPProxy(
|
|
371
|
+
endpoint,
|
|
372
|
+
dep_function_name,
|
|
373
|
+
kwargs_config=kwargs_config,
|
|
374
|
+
)
|
|
343
375
|
else:
|
|
344
376
|
# Create cross-service proxy using unified proxy (same as MCP pipeline)
|
|
345
377
|
new_proxy = EnhancedUnifiedMCPProxy(
|
|
@@ -450,7 +482,8 @@ class APIDependencyResolutionStep(PipelineStep):
|
|
|
450
482
|
Proxy instance
|
|
451
483
|
"""
|
|
452
484
|
from ...engine.full_mcp_proxy import EnhancedFullMCPProxy, FullMCPProxy
|
|
453
|
-
from ...engine.mcp_client_proxy import EnhancedMCPClientProxy,
|
|
485
|
+
from ...engine.mcp_client_proxy import (EnhancedMCPClientProxy,
|
|
486
|
+
MCPClientProxy)
|
|
454
487
|
|
|
455
488
|
if proxy_type == "FullMCPProxy":
|
|
456
489
|
# Use enhanced proxy if kwargs available
|
|
@@ -255,12 +255,14 @@ class DependencyResolutionStep(PipelineStep):
|
|
|
255
255
|
# Get current agent ID for self-dependency detection
|
|
256
256
|
import os
|
|
257
257
|
|
|
258
|
-
from ...engine.self_dependency_proxy import
|
|
258
|
+
from ...engine.self_dependency_proxy import \
|
|
259
|
+
SelfDependencyProxy
|
|
259
260
|
|
|
260
261
|
# Get current agent ID from DecoratorRegistry (single source of truth)
|
|
261
262
|
current_agent_id = None
|
|
262
263
|
try:
|
|
263
|
-
from ...engine.decorator_registry import
|
|
264
|
+
from ...engine.decorator_registry import \
|
|
265
|
+
DecoratorRegistry
|
|
264
266
|
|
|
265
267
|
config = DecoratorRegistry.get_resolved_agent_config()
|
|
266
268
|
current_agent_id = config["agent_id"]
|
|
@@ -293,36 +295,51 @@ class DependencyResolutionStep(PipelineStep):
|
|
|
293
295
|
)
|
|
294
296
|
|
|
295
297
|
if is_self_dependency:
|
|
296
|
-
# Create self-dependency proxy with
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
if
|
|
301
|
-
|
|
302
|
-
|
|
298
|
+
# Create self-dependency proxy with WRAPPER function (not original)
|
|
299
|
+
# The wrapper has dependency injection logic, so calling it ensures
|
|
300
|
+
# the target function's dependencies are also injected properly.
|
|
301
|
+
wrapper_func = None
|
|
302
|
+
if dep_function_name in mesh_tools:
|
|
303
|
+
wrapper_func = mesh_tools[dep_function_name].function
|
|
304
|
+
self.logger.debug(
|
|
305
|
+
f"🔍 Found wrapper for '{dep_function_name}' in DecoratorRegistry"
|
|
303
306
|
)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
307
|
+
|
|
308
|
+
if wrapper_func:
|
|
309
|
+
new_proxy = SelfDependencyProxy(
|
|
310
|
+
wrapper_func, dep_function_name
|
|
308
311
|
)
|
|
309
312
|
self.logger.info(
|
|
310
|
-
f"🔄
|
|
313
|
+
f"🔄 SELF-DEPENDENCY: Using wrapper for '{capability}' "
|
|
314
|
+
f"(local call with full DI support)"
|
|
311
315
|
)
|
|
312
316
|
else:
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
)
|
|
317
|
-
# Use unified proxy for fallback
|
|
318
|
-
new_proxy = EnhancedUnifiedMCPProxy(
|
|
319
|
-
endpoint,
|
|
320
|
-
dep_function_name,
|
|
321
|
-
kwargs_config=kwargs_config,
|
|
322
|
-
)
|
|
323
|
-
self.logger.debug(
|
|
324
|
-
f"🔧 Created EnhancedUnifiedMCPProxy (fallback): {kwargs_config}"
|
|
317
|
+
# Fallback to original function if wrapper not found
|
|
318
|
+
original_func = injector.find_original_function(
|
|
319
|
+
dep_function_name
|
|
325
320
|
)
|
|
321
|
+
if original_func:
|
|
322
|
+
new_proxy = SelfDependencyProxy(
|
|
323
|
+
original_func, dep_function_name
|
|
324
|
+
)
|
|
325
|
+
self.logger.warning(
|
|
326
|
+
f"⚠️ SELF-DEPENDENCY: Using original function for '{capability}' "
|
|
327
|
+
f"(wrapper not found, DI may not work for nested deps)"
|
|
328
|
+
)
|
|
329
|
+
else:
|
|
330
|
+
self.logger.error(
|
|
331
|
+
f"❌ Cannot create SelfDependencyProxy for '{capability}': "
|
|
332
|
+
f"neither wrapper nor original function '{dep_function_name}' found, falling back to HTTP"
|
|
333
|
+
)
|
|
334
|
+
# Use unified proxy for fallback
|
|
335
|
+
new_proxy = EnhancedUnifiedMCPProxy(
|
|
336
|
+
endpoint,
|
|
337
|
+
dep_function_name,
|
|
338
|
+
kwargs_config=kwargs_config,
|
|
339
|
+
)
|
|
340
|
+
self.logger.debug(
|
|
341
|
+
f"🔧 Created EnhancedUnifiedMCPProxy (fallback): {kwargs_config}"
|
|
342
|
+
)
|
|
326
343
|
else:
|
|
327
344
|
# Create cross-service proxy using unified proxy
|
|
328
345
|
new_proxy = EnhancedUnifiedMCPProxy(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp-mesh
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
4
4
|
Summary: Kubernetes-native platform for distributed MCP applications
|
|
5
5
|
Project-URL: Homepage, https://github.com/dhyansraj/mcp-mesh
|
|
6
6
|
Project-URL: Documentation, https://github.com/dhyansraj/mcp-mesh/tree/main/docs
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
_mcp_mesh/__init__.py,sha256=
|
|
1
|
+
_mcp_mesh/__init__.py,sha256=4Pk7c0F7B-b6m0mHql0kvKWn6HEFWJmd-mRFEkin6VY,2719
|
|
2
2
|
_mcp_mesh/engine/__init__.py,sha256=2ennzbo7yJcpkXO9BqN69TruLjJfmJY4Y5VEsG644K4,3630
|
|
3
3
|
_mcp_mesh/engine/async_mcp_client.py,sha256=UcbQjxtgVfeRw6DHTZhAzN1gkcKlTg-lUPEePRPQWAU,6306
|
|
4
4
|
_mcp_mesh/engine/base_injector.py,sha256=qzRLZqFP2VvEFagVovkpdldvDmm3VwPHm6tHwV58a2k,5648
|
|
@@ -6,12 +6,12 @@ _mcp_mesh/engine/decorator_registry.py,sha256=sb4Ng2y0hZovFzmrLdRCiwIEdwCm57WUD9
|
|
|
6
6
|
_mcp_mesh/engine/dependency_injector.py,sha256=1bjeJ7pHUPEF_IoTF-7_Wm1pDLHphtfcFfSrUPWrWI4,31230
|
|
7
7
|
_mcp_mesh/engine/full_mcp_proxy.py,sha256=PlRv7GSKqn5riOCqeCVulVdtq3z1Ug76mOkwMsOFHXw,25297
|
|
8
8
|
_mcp_mesh/engine/http_wrapper.py,sha256=T9VQ2LZbGgCzyOVXVwdqas7-W3Wid0EwRboFUpdYWtM,20718
|
|
9
|
-
_mcp_mesh/engine/llm_config.py,sha256=
|
|
9
|
+
_mcp_mesh/engine/llm_config.py,sha256=95bOsGWro5E1JGq7oZtEYhVdrzcIJqjht_r5vEdJVz4,2049
|
|
10
10
|
_mcp_mesh/engine/llm_errors.py,sha256=h7BiI14u-jL8vtvBfFbFDDrN7gIw8PQjXIl5AP1SBuA,3276
|
|
11
11
|
_mcp_mesh/engine/mcp_client_proxy.py,sha256=eJStwy_VQJexYYD8bOh_m4Ld3Bb8Ae_dt8N1CC41qBc,17625
|
|
12
|
-
_mcp_mesh/engine/mesh_llm_agent.py,sha256=
|
|
13
|
-
_mcp_mesh/engine/mesh_llm_agent_injector.py,sha256=
|
|
14
|
-
_mcp_mesh/engine/response_parser.py,sha256=
|
|
12
|
+
_mcp_mesh/engine/mesh_llm_agent.py,sha256=CcS2WX0ku1DSwUSx0H9YdV7oIiPNMs1jbxSPJvScRao,24679
|
|
13
|
+
_mcp_mesh/engine/mesh_llm_agent_injector.py,sha256=isufzCBExli8tdLUZOaPuea3uQs3C_yeVXbOVSF0YIU,27270
|
|
14
|
+
_mcp_mesh/engine/response_parser.py,sha256=NsOuGD7HJ0BFiiDUCp9v9cjLzVaU86HShVKzsrNnulk,8786
|
|
15
15
|
_mcp_mesh/engine/self_dependency_proxy.py,sha256=OkKt0-B_ADnJlWtHiHItoZCBZ7Su0iz2unEPFfXvrs4,3302
|
|
16
16
|
_mcp_mesh/engine/session_aware_client.py,sha256=mc9eh-aCvUvfllORiXTf_X8_jPqV-32QdWKlr8tHLkU,10600
|
|
17
17
|
_mcp_mesh/engine/session_manager.py,sha256=MCr0_fXBaUjXM51WU5EhDkiGvBdfzYQFVNb9DCXXL0A,10418
|
|
@@ -21,9 +21,9 @@ _mcp_mesh/engine/tool_schema_builder.py,sha256=SQCxQIrSfdLu9-dLqiFurQLK7dhl0dc0x
|
|
|
21
21
|
_mcp_mesh/engine/unified_mcp_proxy.py,sha256=SmhLWXdjmgvJWOLGQk-cXrvYjGSzx98HzL0Q5jpMNIY,36326
|
|
22
22
|
_mcp_mesh/engine/provider_handlers/__init__.py,sha256=LLTCOgnuM3dlogbLmrpiMK3oB5L22eAmDC4BfxJ-L2I,593
|
|
23
23
|
_mcp_mesh/engine/provider_handlers/base_provider_handler.py,sha256=J-SPFFFG1eFSUVvfsv7y4EuNM4REjSxaYWC5E_lC6Pc,4195
|
|
24
|
-
_mcp_mesh/engine/provider_handlers/claude_handler.py,sha256=
|
|
24
|
+
_mcp_mesh/engine/provider_handlers/claude_handler.py,sha256=CCmlsWiCfIcgrLbAZzeSnl0g2pq0uDffT8zOj4F-sPQ,15727
|
|
25
25
|
_mcp_mesh/engine/provider_handlers/generic_handler.py,sha256=ewcwxWMmNEFEeBJ_2m16Oc3SnhCKpc0PVDtKy7TsLv0,5153
|
|
26
|
-
_mcp_mesh/engine/provider_handlers/openai_handler.py,sha256=
|
|
26
|
+
_mcp_mesh/engine/provider_handlers/openai_handler.py,sha256=rpHvnOfZkk73uICgU4pKe-BsWts4cQeykm_UXkAA3Rk,7754
|
|
27
27
|
_mcp_mesh/engine/provider_handlers/provider_handler_registry.py,sha256=d2G3vndANzTiNl2ApfJuE2bmOlUI88y42144PjVst4s,5605
|
|
28
28
|
_mcp_mesh/generated/.openapi-generator-ignore,sha256=5opOTZ_fahF3ctMAmN-i3PzJXM0d9Tnji_uAET2ZyEw,162
|
|
29
29
|
_mcp_mesh/generated/.openapi-generator/FILES,sha256=Jpd-j6le0SjEvwdAJ51SWdZrlOUrUAFLtQ4sCHZVdKk,2571
|
|
@@ -78,7 +78,7 @@ _mcp_mesh/generated/mcp_mesh_registry_client/models/standardized_dependency.py,s
|
|
|
78
78
|
_mcp_mesh/generated/mcp_mesh_registry_client/models/trace_event.py,sha256=9Q_8WaVl0MxswRnHpkqq9GKnvOW54HW4tkrTM9oda14,4461
|
|
79
79
|
_mcp_mesh/pipeline/__init__.py,sha256=9Aplh4m1z-rYTQys0JQLYlq9wTPdI72eSOhUPqcnvpA,1557
|
|
80
80
|
_mcp_mesh/pipeline/api_heartbeat/__init__.py,sha256=IXTLoQLAPqQEWZ8VMWc5W_cQJkDv95rlVGXyXoQDjHk,473
|
|
81
|
-
_mcp_mesh/pipeline/api_heartbeat/api_dependency_resolution.py,sha256=
|
|
81
|
+
_mcp_mesh/pipeline/api_heartbeat/api_dependency_resolution.py,sha256=Q96auBnbypPnxTjiThtKMIezuZ_hUj30JaPNOZc87ng,24096
|
|
82
82
|
_mcp_mesh/pipeline/api_heartbeat/api_fast_heartbeat_check.py,sha256=PY4bbuZgxy3r0ccuBl-OuJvcPSMhyGz4FomxwYFhuvM,4821
|
|
83
83
|
_mcp_mesh/pipeline/api_heartbeat/api_health_check.py,sha256=kDmFeOG_4tyqyJSBZjPcc7xTzGpP4vq6ObW_WBqXvzM,5130
|
|
84
84
|
_mcp_mesh/pipeline/api_heartbeat/api_heartbeat_orchestrator.py,sha256=uBswzWOBzU8p_C0AE2DF8UwIWG4rP2zecHfPqKzNuC0,10367
|
|
@@ -94,7 +94,7 @@ _mcp_mesh/pipeline/api_startup/middleware_integration.py,sha256=ybImXZlmIR6yA-wY
|
|
|
94
94
|
_mcp_mesh/pipeline/api_startup/route_collection.py,sha256=UjA-F5_RbGVU5TfDT19Np5_x2PtYkNn2mGFyivDsk24,2031
|
|
95
95
|
_mcp_mesh/pipeline/api_startup/route_integration.py,sha256=aMT7p7cwK8N3tZBRqeGQF8upc7tU-Exj6Dz0a4cSBhU,13441
|
|
96
96
|
_mcp_mesh/pipeline/mcp_heartbeat/__init__.py,sha256=nRNjZ3VD_9bPLQuJ6Nc02gE7KSLcMP7TMquB0hP6hHs,844
|
|
97
|
-
_mcp_mesh/pipeline/mcp_heartbeat/dependency_resolution.py,sha256=
|
|
97
|
+
_mcp_mesh/pipeline/mcp_heartbeat/dependency_resolution.py,sha256=vW-qrpneBLxxQtUEwEjE7aUTv5cIO9rjDg3Bxv7nj4I,18846
|
|
98
98
|
_mcp_mesh/pipeline/mcp_heartbeat/fast_heartbeat_check.py,sha256=2SKHHFTxlYwad_D8a6E7NNtWfH89jBrIO5dQAwM3Xdw,4468
|
|
99
99
|
_mcp_mesh/pipeline/mcp_heartbeat/heartbeat_orchestrator.py,sha256=DYX35H3edra_1qbnNzjmtnYit0oVLDIHidLoQUjeULU,12556
|
|
100
100
|
_mcp_mesh/pipeline/mcp_heartbeat/heartbeat_pipeline.py,sha256=BzoZK9PmE6vQEt8vs8_oiKBiTa9ba3IruBHebnvWaGI,11767
|
|
@@ -140,10 +140,10 @@ _mcp_mesh/tracing/trace_context_helper.py,sha256=6tEkwjWFqMBe45zBlhacktmIpzJWTF9
|
|
|
140
140
|
_mcp_mesh/tracing/utils.py,sha256=t9lJuTH7CeuzAiiAaD0WxsJMFJPdzZFR0w6-vyR9f2E,3849
|
|
141
141
|
_mcp_mesh/utils/fastmcp_schema_extractor.py,sha256=M54ffesC-56zl_fNJHj9dZxElDQaWFf1MXdSLCuFStg,17253
|
|
142
142
|
mesh/__init__.py,sha256=0zequaBtd_9NLOLsr9sNONuwWa_fT_-G4LnJ1CHTEY0,3808
|
|
143
|
-
mesh/decorators.py,sha256=
|
|
143
|
+
mesh/decorators.py,sha256=QTd1wJ8XV0Pfjq2ejyXjyeXBtyodbj1gbs5WKG9AFTs,55632
|
|
144
144
|
mesh/helpers.py,sha256=c3FhSy9U4KBHEH6WH6MjCVrPMw9li5JAgBLUTIoamz4,9472
|
|
145
145
|
mesh/types.py,sha256=9TqbJSxlybLQaPVjugcKwPiIrVnJEzqAOvPRhlX1zmo,15559
|
|
146
|
-
mcp_mesh-0.6.
|
|
147
|
-
mcp_mesh-0.6.
|
|
148
|
-
mcp_mesh-0.6.
|
|
149
|
-
mcp_mesh-0.6.
|
|
146
|
+
mcp_mesh-0.6.3.dist-info/METADATA,sha256=6xLJu280gn5O2D1OUOZYAwOVGtQVf0g2tHDk3XnRXz8,4879
|
|
147
|
+
mcp_mesh-0.6.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
148
|
+
mcp_mesh-0.6.3.dist-info/licenses/LICENSE,sha256=_EBQHRQThv9FPOLc5eFOUdeeRO0mYwChC7cx60dM1tM,1078
|
|
149
|
+
mcp_mesh-0.6.3.dist-info/RECORD,,
|
mesh/decorators.py
CHANGED
|
@@ -989,6 +989,39 @@ def set_shutdown_context(context: dict[str, Any]):
|
|
|
989
989
|
set_global_shutdown_context(context)
|
|
990
990
|
|
|
991
991
|
|
|
992
|
+
def _get_llm_agent_for_injection(
|
|
993
|
+
wrapper: Any, param_name: str, kwargs: dict, func_name: str
|
|
994
|
+
) -> Any:
|
|
995
|
+
"""
|
|
996
|
+
Get the appropriate LLM agent for injection based on template mode.
|
|
997
|
+
|
|
998
|
+
Handles both template-based (per-call context) and non-template (cached) modes.
|
|
999
|
+
|
|
1000
|
+
Args:
|
|
1001
|
+
wrapper: The wrapper function with _mesh_llm_* attributes
|
|
1002
|
+
param_name: Name of the LLM parameter to inject
|
|
1003
|
+
kwargs: Current call kwargs (may contain context value)
|
|
1004
|
+
func_name: Function name for logging
|
|
1005
|
+
|
|
1006
|
+
Returns:
|
|
1007
|
+
MeshLlmAgent instance (either per-call with context or cached)
|
|
1008
|
+
"""
|
|
1009
|
+
config = getattr(wrapper, "_mesh_llm_config", {})
|
|
1010
|
+
is_template = config.get("is_template", False)
|
|
1011
|
+
context_param_name = config.get("context_param")
|
|
1012
|
+
create_context_agent = getattr(wrapper, "_mesh_create_context_agent", None)
|
|
1013
|
+
|
|
1014
|
+
if is_template and context_param_name and create_context_agent:
|
|
1015
|
+
# Template mode: create per-call agent with context
|
|
1016
|
+
context_value = kwargs.get(context_param_name)
|
|
1017
|
+
if context_value is not None:
|
|
1018
|
+
logger.debug(f"🎯 Created per-call LLM agent with context for {func_name}")
|
|
1019
|
+
return create_context_agent(context_value)
|
|
1020
|
+
|
|
1021
|
+
# Non-template mode or no context provided: use cached agent
|
|
1022
|
+
return wrapper._mesh_llm_agent
|
|
1023
|
+
|
|
1024
|
+
|
|
992
1025
|
def llm(
|
|
993
1026
|
filter: dict[str, Any] | list[dict[str, Any] | str] | str | None = None,
|
|
994
1027
|
*,
|
|
@@ -1247,7 +1280,9 @@ def llm(
|
|
|
1247
1280
|
"""Wrapper that injects both MeshLlmAgent and DI parameters."""
|
|
1248
1281
|
# Inject LLM parameter if not provided or if it's None
|
|
1249
1282
|
if param_name not in kwargs or kwargs.get(param_name) is None:
|
|
1250
|
-
kwargs[param_name] =
|
|
1283
|
+
kwargs[param_name] = _get_llm_agent_for_injection(
|
|
1284
|
+
combined_injection_wrapper, param_name, kwargs, func.__name__
|
|
1285
|
+
)
|
|
1251
1286
|
# Then call the original wrapper (which handles DI injection)
|
|
1252
1287
|
return original_call(*args, **kwargs)
|
|
1253
1288
|
|
|
@@ -1310,7 +1345,9 @@ def llm(
|
|
|
1310
1345
|
"""Wrapper that injects MeshLlmAgent parameter."""
|
|
1311
1346
|
# Inject llm parameter if not provided or if it's None
|
|
1312
1347
|
if param_name not in kwargs or kwargs.get(param_name) is None:
|
|
1313
|
-
kwargs[param_name] =
|
|
1348
|
+
kwargs[param_name] = _get_llm_agent_for_injection(
|
|
1349
|
+
llm_injection_wrapper, param_name, kwargs, func.__name__
|
|
1350
|
+
)
|
|
1314
1351
|
return func(*args, **kwargs)
|
|
1315
1352
|
|
|
1316
1353
|
# Create update method for heartbeat - updates the wrapper, not func
|
|
File without changes
|