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.

ModeHow it worksTradeoff
AlwaysExtraction runs automatically after each responseExtra LLM call per interaction
AgenticAgent receives tools and decides what to saveMay miss implicit information
ProposeAgent proposes learnings, user confirms before savingRequires user interaction

Always Mode

Extraction happens automatically in the background. No agent tools involved.

1from kern.agent import Agent
2from kern.db.postgres import PostgresDb
3from kern.learn import LearningMachine, LearningMode, UserProfileConfig
4from kern.models.openai import OpenAIResponses
5
6agent = 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)
13
14# Profile info extracted automatically - no tool calls visible
15agent.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, UserProfileConfig
2
3agent = Agent(
4 model=OpenAIResponses(id="gpt-5.2"),
5 db=db,
6 learning=LearningMachine(
7 user_profile=UserProfileConfig(mode=LearningMode.AGENTIC),
8 ),
9)
10
11# Agent decides to call update_profile tool
12agent.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

StoreTools
User Profileupdate_profile
User Memoryupdate_user_memory
Entity Memorysearch_entities, create_entity, update_entity, add_fact, update_fact, delete_fact, add_event, add_relationship
Learned Knowledgesearch_learnings, save_learning
Decision Loglog_decision, record_outcome, search_decisions

Propose Mode

The agent proposes learnings. User must confirm before saving.

1from kern.learn import LearningMachine, LearningMode, LearnedKnowledgeConfig
2
3agent = 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)
11
12# Agent proposes, user confirms
13agent.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)
8
9agent = Agent(
10 model=OpenAIResponses(id="gpt-5.2"),
11 db=db,
12 learning=LearningMachine(
13 user_profile=UserProfileConfig(mode=LearningMode.ALWAYS), # Automatic
14 user_memory=UserMemoryConfig(mode=LearningMode.ALWAYS), # Automatic
15 learned_knowledge=LearnedKnowledgeConfig(mode=LearningMode.AGENTIC), # Agent-driven
16 ),
17)

Defaults by Store

StoreDefault modeReason
User ProfileAlwaysNames and preferences should be captured consistently
User MemoryAlwaysObservations accumulate passively
Session ContextAlwaysSession state needs continuous tracking
Entity MemoryAlwaysContinuous extraction captures entity facts/events from normal conversations
Learned KnowledgeAgenticAgent decides what insights are worth saving
Decision LogAlways (DecisionLogConfig()), Agentic (decision_log=True)Supports both automatic logging and explicit logging workflows

Choosing a Mode

ScenarioMode
Capture user names and preferencesAlways
Build user memory automaticallyAlways
Track session progressAlways
Agent-driven knowledge captureAgentic
Build entity knowledge graphsAlways
Audit agent decisionsAgentic
High-value collective knowledgePropose
Compliance-sensitive learningPropose