@@ -2693,41 +2693,49 @@ async def process_chat_payload(request, form_data, user, metadata, model):
26932693 # Otherwise, save any tools that filter inlets added for merging later.
26942694 inlet_filter_tools = None if payload_tools is not None else form_data .get ('tools' , None )
26952695
2696- # Skills — extract IDs from message content (<$skillId|label> tags) so
2697- # persisted chats work without relying on the frontend to send skill_ids.
2698- user_skill_ids = set ( form_data . pop ( 'skill_ids' , None ) or [])
2699- user_skill_ids |= extract_skill_ids_from_messages (form_data .get ( 'messages ' , []) )
2700- model_skill_ids = set (model .get ('info' , {}).get ('meta' , {}).get ('skillIds' , []))
2701-
2702- all_skill_ids = user_skill_ids | model_skill_ids
2696+ # Mentioned skills get full content; selected/default skills can be loaded through view_skill.
2697+ mentioned_skill_ids = extract_skill_ids_from_messages ( form_data . get ( 'messages' , []))
2698+ skill_ids = (
2699+ set (form_data .pop ( 'skill_ids ' , None ) or [] )
2700+ | set (model .get ('info' , {}).get ('meta' , {}).get ('skillIds' , []))
2701+ | mentioned_skill_ids
2702+ )
27032703 available_skills = []
2704- if all_skill_ids :
2704+ view_skill_ids = []
2705+ use_builtin_tools = (
2706+ bool (metadata .get ('session_id' ))
2707+ and metadata .get ('params' , {}).get ('function_calling' ) != 'legacy'
2708+ and (model .get ('info' , {}).get ('meta' , {}).get ('capabilities' ) or {}).get ('builtin_tools' , True )
2709+ )
2710+
2711+ if skill_ids :
27052712 from open_webui .models .skills import Skills as SkillsModel
27062713
27072714 accessible_skill_ids = {s .id for s in await SkillsModel .get_skills_by_user_id (user .id , 'read' )}
2708- available_skills = []
2709- for sid in all_skill_ids :
2715+ for sid in skill_ids :
27102716 if sid in accessible_skill_ids :
27112717 s = await SkillsModel .get_skill_by_id (sid )
27122718 if s and s .is_active :
27132719 available_skills .append (s )
27142720
2715- skill_descriptions = ''
2721+ skill_manifest = ''
27162722 for skill in available_skills :
2717- if skill .id in user_skill_ids :
2718- # User-selected: inject full content
2723+ if skill .id in mentioned_skill_ids or not use_builtin_tools :
27192724 form_data ['messages' ] = add_or_update_system_message (
27202725 f'<skill name="{ skill .name } ">\n { skill .content } \n </skill>' ,
27212726 form_data ['messages' ],
27222727 append = True ,
27232728 )
27242729 else :
2725- # Model-attached: name+description only
2726- skill_descriptions += f'<skill>\n <id>{ skill .id } </id>\n <name>{ skill .name } </name>\n <description>{ skill .description or "" } </description>\n </skill>\n '
2730+ view_skill_ids .append (skill .id )
2731+ skill_manifest += (
2732+ f'<skill>\n <id>{ skill .id } </id>\n <name>{ skill .name } </name>\n '
2733+ f'<description>{ skill .description or "" } </description>\n </skill>\n '
2734+ )
27272735
2728- if skill_descriptions :
2736+ if skill_manifest :
27292737 form_data ['messages' ] = add_or_update_system_message (
2730- f'<available_skills>\n { skill_descriptions } </available_skills>' ,
2738+ f'<available_skills>\n { skill_manifest } </available_skills>' ,
27312739 form_data ['messages' ],
27322740 append = True ,
27332741 )
@@ -2916,11 +2924,7 @@ async def tool_function(**kwargs):
29162924 # Inject builtin tools for native function calling based on enabled features and model capability.
29172925 # Only inject when the request originates from the UI (identified by session_id).
29182926 # API callers don't expect hidden tools; they can explicitly request tools via tool_ids.
2919- builtin_tools_enabled = (model .get ('info' , {}).get ('meta' , {}).get ('capabilities' ) or {}).get (
2920- 'builtin_tools' , True
2921- )
2922- has_session = bool (metadata .get ('session_id' ))
2923- if has_session and metadata .get ('params' , {}).get ('function_calling' ) != 'legacy' and builtin_tools_enabled :
2927+ if use_builtin_tools :
29242928 # Add file context to user messages
29252929 chat_id = metadata .get ('chat_id' )
29262930 form_data ['messages' ] = await add_file_context (form_data .get ('messages' , []), chat_id , user )
@@ -2929,7 +2933,7 @@ async def tool_function(**kwargs):
29292933 {
29302934 ** extra_params ,
29312935 '__event_emitter__' : event_emitter ,
2932- '__skill_ids__' : [ s . id for s in available_skills if s . id not in user_skill_ids ] ,
2936+ '__skill_ids__' : view_skill_ids ,
29332937 },
29342938 features ,
29352939 model ,
0 commit comments