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.
@@ -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, FullMCPProxy
232
- from ...engine.mcp_client_proxy import (
233
- EnhancedMCPClientProxy,
234
- MCPClientProxy,
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 SelfDependencyProxy
293
- from ...engine.unified_mcp_proxy import EnhancedUnifiedMCPProxy
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 DecoratorRegistry
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
- # Note: Self-dependencies are unusual for API services but we handle them
332
- self.logger.warning(
333
- f"⚠️ API SELF-DEPENDENCY detected for '{capability}' - "
334
- f"this is unusual for API services. Consider refactoring."
335
- )
336
- # For API services, we don't have access to original functions in the same way
337
- # Fall back to unified proxy (same as cross-service)
338
- new_proxy = EnhancedUnifiedMCPProxy(
339
- endpoint,
340
- dep_function_name,
341
- kwargs_config=kwargs_config,
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, MCPClientProxy
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 SelfDependencyProxy
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 DecoratorRegistry
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 cached function reference
297
- original_func = injector.find_original_function(
298
- dep_function_name
299
- )
300
- if original_func:
301
- new_proxy = SelfDependencyProxy(
302
- original_func, dep_function_name
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
- self.logger.warning(
305
- f"⚠️ SELF-DEPENDENCY: Using direct function call for '{capability}' "
306
- f"instead of HTTP to avoid deadlock. Consider refactoring to "
307
- f"eliminate self-dependencies if possible."
307
+
308
+ if wrapper_func:
309
+ new_proxy = SelfDependencyProxy(
310
+ wrapper_func, dep_function_name
308
311
  )
309
312
  self.logger.info(
310
- f"🔄 Updated to SelfDependencyProxy: '{capability}'"
313
+ f"🔄 SELF-DEPENDENCY: Using wrapper for '{capability}' "
314
+ f"(local call with full DI support)"
311
315
  )
312
316
  else:
313
- self.logger.error(
314
- f"❌ Cannot create SelfDependencyProxy for '{capability}': "
315
- f"original function '{dep_function_name}' not found, falling back to HTTP"
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.1
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=clPVaqkd4Zh5UgF9PBvxKDtvAoWj5PIizG_AxykX15g,2719
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=UOOfQbhYcljT9TsJJg_edwpk_5H4ZXQ6L1QARgiy8oc,1649
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=h83F7ZJWGv048tnXmNsD8HnmA0_t7D-aEWuCfke7psI,24038
13
- _mcp_mesh/engine/mesh_llm_agent_injector.py,sha256=Mh4dndOMfd_K-XWFSuuPFHo6u4tHyyTKq4GjdvX6mu8,24777
14
- _mcp_mesh/engine/response_parser.py,sha256=4_yEnxvHGvfgo7oqikgpjEjHuZRpBqBPJ_1QTH9YZOs,6943
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=woTDtrDgv0UlXgbDxnOxE92i7VWTDWCG5NRwZitm6Cs,4875
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=YKLnY1epdnoFDOm8LsuwGOIvkyJ4bSaEdArNxyHyaYQ,5511
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=jo5SmI52T7Vz9yEz5O78SHYh-HyJtpzdOxoa5EylHsI,22011
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=qQ1KhrRYroYL2nnjLufXsXaaAO593GnuvJrRy_Ws97k,17764
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=iCneI4xgihw1cc22mx0K-OnMIOLbh47EtwgTvPGTRzk,54126
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.1.dist-info/METADATA,sha256=sZTDo2nBovUuMEgTpPX0Su81EnyUR3XHSsxEuh52g0w,4879
147
- mcp_mesh-0.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
148
- mcp_mesh-0.6.1.dist-info/licenses/LICENSE,sha256=_EBQHRQThv9FPOLc5eFOUdeeRO0mYwChC7cx60dM1tM,1078
149
- mcp_mesh-0.6.1.dist-info/RECORD,,
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,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
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] = combined_injection_wrapper._mesh_llm_agent
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] = llm_injection_wrapper._mesh_llm_agent
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