@@ -395,7 +395,6 @@ export class AgentServer {
395395 private warmAutoPublishResolved = false ;
396396 private installedSkillBundles = new Set < string > ( ) ;
397397 private installedSkillBundleInfo = new Map < string , InstalledSkillBundle > ( ) ;
398- private alwaysOnSkillsActivatedSessionId : string | null = null ;
399398 private installingSkillBundles = new Map < string , Promise < void > > ( ) ;
400399 // Guards against concurrent session initialization. autoInitializeSession() and
401400 // the GET /events SSE handler can both call initializeSession() — the SSE connection
@@ -2839,44 +2838,8 @@ export class AgentServer {
28392838 runId : string ,
28402839 artifacts : TaskRunArtifact [ ] ,
28412840 ) : LocalSkillPromptContext | null {
2842- const alwaysOnSkills = artifacts
2843- . filter (
2844- ( artifact ) =>
2845- artifact . type === "skill_bundle" &&
2846- artifact . metadata ?. always_on === true ,
2847- )
2848- . sort ( ( left , right ) =>
2849- `${ left . metadata ?. skill_source } :${ left . metadata ?. skill_name } ` . localeCompare (
2850- `${ right . metadata ?. skill_source } :${ right . metadata ?. skill_name } ` ,
2851- ) ,
2852- )
2853- . map ( ( artifact ) =>
2854- this . installedSkillBundleInfo . get (
2855- this . getInstalledSkillBundleInfoKey (
2856- runId ,
2857- artifact . metadata ?. skill_name ?? "" ,
2858- ) ,
2859- ) ,
2860- )
2861- . filter ( ( skill ) : skill is InstalledSkillBundle => ! ! skill ) ;
2862- const sessionId = this . session ?. acpSessionId ;
2863- const shouldActivateAlwaysOnSkills =
2864- alwaysOnSkills . length > 0 &&
2865- ! ! sessionId &&
2866- this . alwaysOnSkillsActivatedSessionId !== sessionId ;
2867- const alwaysOnContext = shouldActivateAlwaysOnSkills
2868- ? [
2869- "Always-on skills apply for the entire session. Before proceeding, read each SKILL.md below from the filesystem in the listed order and follow its instructions for the entire session." ,
2870- ...alwaysOnSkills . map (
2871- ( skill ) => `- /${ skill . skillName } : ${ skill . skillRoot } /SKILL.md` ,
2872- ) ,
2873- ] . join ( "\n" )
2874- : null ;
2875- if ( shouldActivateAlwaysOnSkills && sessionId ) {
2876- this . alwaysOnSkillsActivatedSessionId = sessionId ;
2877- }
28782841 if ( contentBlocks . length === 0 ) {
2879- return alwaysOnContext ? { context : alwaysOnContext } : null ;
2842+ return null ;
28802843 }
28812844
28822845 const textBlockIndex = contentBlocks . findIndex (
@@ -2891,23 +2854,6 @@ export class AgentServer {
28912854 : null ;
28922855
28932856 if ( invocation ) {
2894- const invokedAlwaysOnSkill = alwaysOnSkills . find (
2895- ( skill ) => skill . skillName === invocation . skillName ,
2896- ) ;
2897- if ( invokedAlwaysOnSkill ) {
2898- const invokedContext = this . buildInstalledSkillPrompt (
2899- invokedAlwaysOnSkill ,
2900- invocation . args ,
2901- this . getCoInstalledSkillBundles ( runId , invocation . skillName ) ,
2902- false ,
2903- ) ;
2904- return {
2905- skillName : invocation . skillName ,
2906- context : alwaysOnContext
2907- ? `${ alwaysOnContext } \n\n${ invokedContext } `
2908- : invokedContext ,
2909- } ;
2910- }
29112857 const hasMatchingArtifact = artifacts . some (
29122858 ( artifact ) =>
29132859 artifact . type === "skill_bundle" &&
@@ -2919,16 +2865,13 @@ export class AgentServer {
29192865 )
29202866 : undefined ;
29212867 if ( installedSkill ) {
2922- const invokedContext = this . buildInstalledSkillPrompt (
2923- installedSkill ,
2924- invocation . args ,
2925- this . getCoInstalledSkillBundles ( runId , invocation . skillName ) ,
2926- ) ;
29272868 return {
29282869 skillName : invocation . skillName ,
2929- context : alwaysOnContext
2930- ? `${ alwaysOnContext } \n\n${ invokedContext } `
2931- : invokedContext ,
2870+ context : this . buildInstalledSkillPrompt (
2871+ installedSkill ,
2872+ invocation . args ,
2873+ this . getCoInstalledSkillBundles ( runId , invocation . skillName ) ,
2874+ ) ,
29322875 } ;
29332876 }
29342877 }
@@ -2940,17 +2883,7 @@ export class AgentServer {
29402883 )
29412884 . map ( ( block ) => block . text )
29422885 . join ( "\n" ) ;
2943- const attachedContext = this . buildAttachedSkillsPromptContext (
2944- runId ,
2945- artifacts . filter ( ( artifact ) => artifact . metadata ?. always_on !== true ) ,
2946- messageText ,
2947- ) ;
2948- if ( ! alwaysOnContext ) return attachedContext ;
2949- return {
2950- context : attachedContext
2951- ? `${ alwaysOnContext } \n\n${ attachedContext . context } `
2952- : alwaysOnContext ,
2953- } ;
2886+ return this . buildAttachedSkillsPromptContext ( runId , artifacts , messageText ) ;
29542887 }
29552888
29562889 /**
@@ -3049,19 +2982,14 @@ export class AgentServer {
30492982 skill : InstalledSkillBundle ,
30502983 args : string | undefined ,
30512984 coInstalledSkills : InstalledSkillBundle [ ] = [ ] ,
3052- includeDefinition = true ,
30532985 ) : string {
30542986 return [
30552987 `The user invoked the local skill "/${ skill . skillName } ". Apply these skill instructions for this turn.` ,
30562988 "" ,
3057- ...( includeDefinition
3058- ? [
3059- `--- BEGIN LOCAL SKILL ${ skill . skillName } ---` ,
3060- skill . skillDefinition . trim ( ) ,
3061- `--- END LOCAL SKILL ${ skill . skillName } ---` ,
3062- "" ,
3063- ]
3064- : [ ] ) ,
2989+ `--- BEGIN LOCAL SKILL ${ skill . skillName } ---` ,
2990+ skill . skillDefinition . trim ( ) ,
2991+ `--- END LOCAL SKILL ${ skill . skillName } ---` ,
2992+ "" ,
30652993 `Installed skill path: ${ skill . skillRoot } ` ,
30662994 ...( coInstalledSkills . length > 0
30672995 ? [
0 commit comments