Learning Modes
Control when and how agents learn.
Learning modes control when and how a Learning Machine captures information. Each store can use a different mode.
| Mode | How it works | Tradeoff |
|---|---|---|
| Always | Extraction runs automatically after each response | Extra LLM call per interaction |
| Agentic | Agent receives tools and decides what to save | May miss implicit information |
| Propose | Agent proposes learnings, user confirms before saving | Requires user interaction |
Always Mode
Extraction happens automatically in the background. No agent tools involved.
1from kern.agent import Agent2from kern.db.postgres import PostgresDb3from kern.learn import LearningMachine, LearningMode, UserProfileConfig4from kern.models.openai import OpenAIResponses56agent = Agent(7 model=OpenAIResponses(id="gpt-5.2"),8 db=PostgresDb(db_url="postgresql+psycopg://ai:ai@localhost:5532/ai"),9 learning=LearningMachine(10 user_profile=UserProfileConfig(mode=LearningMode.ALWAYS),11 ),12)1314# Profile info extracted automatically - no tool calls visible15agent.print_response(16 "I'm Alice Chen, but please call me Ali.",17 user_id="alice@example.com",18)Best for: User Profile, User Memory, Session Context, Entity Memory
Agentic Mode
The agent receives tools and decides when to save.
1from kern.learn import LearningMachine, LearningMode, UserProfileConfig23agent = Agent(4 model=OpenAIResponses(id="gpt-5.2"),5 db=db,6 learning=LearningMachine(7 user_profile=UserProfileConfig(mode=LearningMode.AGENTIC),8 ),9)1011# Agent decides to call update_profile tool12agent.print_response(13 "Remember that I prefer dark mode interfaces.",14 user_id="alice@example.com",15)Best for: Learned Knowledge, Decision Log
Tools by Store
| Store | Tools |
|---|---|
| User Profile | update_profile |
| User Memory | update_user_memory |
| Entity Memory | search_entities, create_entity, update_entity, add_fact, update_fact, delete_fact, add_event, add_relationship |
| Learned Knowledge | search_learnings, save_learning |
| Decision Log | log_decision, record_outcome, search_decisions |
Propose Mode
The agent proposes learnings. User must confirm before saving.
1from kern.learn import LearningMachine, LearningMode, LearnedKnowledgeConfig23agent = Agent(4 model=OpenAIResponses(id="gpt-5.2"),5 db=db,6 learning=LearningMachine(7 knowledge=knowledge,8 learned_knowledge=LearnedKnowledgeConfig(mode=LearningMode.PROPOSE),9 ),10)1112# Agent proposes, user confirms13agent.print_response(14 "That's a great insight about API rate limits - we should remember that.",15 user_id="alice@example.com",16)Note: Propose mode is currently intended for Learned Knowledge.
Best for: High-stakes knowledge, regulated environments, quality control
Combining Modes
Use different modes for different stores:
1from kern.learn import (2 LearningMachine,3 LearningMode,4 UserProfileConfig,5 UserMemoryConfig,6 LearnedKnowledgeConfig,7)89agent = Agent(10 model=OpenAIResponses(id="gpt-5.2"),11 db=db,12 learning=LearningMachine(13 user_profile=UserProfileConfig(mode=LearningMode.ALWAYS), # Automatic14 user_memory=UserMemoryConfig(mode=LearningMode.ALWAYS), # Automatic15 learned_knowledge=LearnedKnowledgeConfig(mode=LearningMode.AGENTIC), # Agent-driven16 ),17)Defaults by Store
| Store | Default mode | Reason |
|---|---|---|
| User Profile | Always | Names and preferences should be captured consistently |
| User Memory | Always | Observations accumulate passively |
| Session Context | Always | Session state needs continuous tracking |
| Entity Memory | Always | Continuous extraction captures entity facts/events from normal conversations |
| Learned Knowledge | Agentic | Agent decides what insights are worth saving |
| Decision Log | Always (DecisionLogConfig()), Agentic (decision_log=True) | Supports both automatic logging and explicit logging workflows |
Choosing a Mode
| Scenario | Mode |
|---|---|
| Capture user names and preferences | Always |
| Build user memory automatically | Always |
| Track session progress | Always |
| Agent-driven knowledge capture | Agentic |
| Build entity knowledge graphs | Always |
| Audit agent decisions | Agentic |
| High-value collective knowledge | Propose |
| Compliance-sensitive learning | Propose |