@@ -62,7 +62,7 @@ export function getCurrentConfig(): LearningConfig | null {
6262 */
6363export function learning ( options : {
6464 agent : string ;
65- client : AgenticLearning ;
65+ client ? : AgenticLearning ;
6666 captureOnly ?: boolean ;
6767 memory ?: string [ ] ;
6868 model ?: string ;
@@ -79,9 +79,12 @@ export function learning(options: {
7979 // Save the previous context (for nested contexts)
8080 const previousStore = learningContext . getStore ( ) ;
8181
82+ // Create default client if not provided
83+ const client = options . client || new ( require ( './client' ) . AgenticLearning ) ( ) ;
84+
8285 const config : LearningConfig = {
8386 agentName : options . agent ,
84- client : options . client ,
87+ client : client ,
8588 captureOnly : options . captureOnly || false ,
8689 memory : options . memory || [ ] ,
8790 model : options . model ,
@@ -127,7 +130,7 @@ export function learning(options: {
127130export async function withLearning < T > (
128131 options : {
129132 agent : string ;
130- client : AgenticLearning ;
133+ client ? : AgenticLearning ;
131134 captureOnly ?: boolean ;
132135 memory ?: string [ ] ;
133136 model ?: string ;
@@ -141,9 +144,12 @@ export async function withLearning<T>(
141144 interceptorsInstalled = true ;
142145 }
143146
147+ // Create default client if not provided
148+ const client = options . client || new ( require ( './client' ) . AgenticLearning ) ( ) ;
149+
144150 const config : LearningConfig = {
145151 agentName : options . agent ,
146- client : options . client ,
152+ client : client ,
147153 captureOnly : options . captureOnly || false ,
148154 memory : options . memory || [ ] ,
149155 model : options . model ,
0 commit comments