@@ -1159,6 +1159,36 @@ def agent_tool(
11591159# ── Utilities ───────────────────────────────────────────────────────────
11601160
11611161
1162+ def _entry_resolves_to (entry_func : Any , original : Callable [..., Any ],
1163+ func : Callable [..., Any ]) -> bool :
1164+ """True if a ``_decorated_functions`` entry refers to *original*/*func*.
1165+
1166+ A plain identity check is not enough: once a ``@worker_task`` function is
1167+ used as an agent tool, ``ToolRegistry.register_tool_workers`` re-registers
1168+ the same task name with a spawn-safe ``ToolWorkerEntry`` wrapper, which
1169+ carries the original either directly (``fn_direct``) or by qualified name
1170+ (``fn_ref``). Walk the ``__wrapped__`` chain and those carriers.
1171+ """
1172+ obj = entry_func
1173+ for _ in range (8 ): # bounded — wrapper chains are shallow
1174+ if obj is None :
1175+ return False
1176+ if obj is original or obj is func :
1177+ return True
1178+ fn_direct = getattr (obj , "fn_direct" , None )
1179+ if fn_direct is not None and (fn_direct is original or fn_direct is func ):
1180+ return True
1181+ fn_ref = getattr (obj , "fn_ref" , None )
1182+ if (
1183+ fn_ref is not None
1184+ and getattr (fn_ref , "module" , None ) == getattr (original , "__module__" , None )
1185+ and getattr (fn_ref , "qualname" , None ) == getattr (original , "__qualname__" , None )
1186+ ):
1187+ return True
1188+ obj = getattr (obj , "__wrapped__" , None )
1189+ return False
1190+
1191+
11621192def _try_worker_task (func : Callable [..., Any ]) -> Optional [ToolDef ]:
11631193 """Try to build a :class:`ToolDef` from a ``@worker_task``-decorated function.
11641194
@@ -1174,7 +1204,7 @@ def _try_worker_task(func: Callable[..., Any]) -> Optional[ToolDef]:
11741204 original = getattr (func , "__wrapped__" , func )
11751205
11761206 for (task_name , _domain ), entry in _decorated_functions .items ():
1177- if entry ["func" ] is original or entry [ " func" ] is func :
1207+ if _entry_resolves_to ( entry ["func" ], original , func ) :
11781208 from conductor .ai .agents ._internal .schema_utils import schema_from_function
11791209
11801210 description = inspect .getdoc (original ) or ""
0 commit comments