agora.core.learning

Knowledge flywheel — structured learnings with confidence decay.

Position: the retry-memory layer. When a task fails a postcondition the runtime records a Learning (a failure trace + a corrective hint) and injects it into the model’s next-turn prompt — the mechanism that turns a raw failure into context on retry, rather than letting the model repeat it blind.

Invariants: confidence is bounded to [0, MAX_CONFIDENCE]; a learning below CONFIDENCE_THRESHOLD is considered stale and dropped; reinforcement adds REINFORCE_BOOST and time subtracts DECAY_RATE — so a hint that keeps proving useful survives and one that stops mattering ages out on its own.

Functions

decay_learnings(learnings)

Apply confidence decay uniformly.

filter_active(learnings)

Learnings above the confidence threshold, sorted descending by confidence.

format_learnings_for_context(learnings)

Format learnings as a prompt context block, grouped by category.

reinforce(learning)

Boost confidence when a learning is referenced again; cap at MAX_CONFIDENCE.

Classes

Learning

A failure trace lifted from a postcondition into the next agent prompt.

class agora.core.learning.Learning[source]

Bases: object

A failure trace lifted from a postcondition into the next agent prompt.

Learnings are the framework’s loopback mechanism: when a task fails a postcondition, the orchestrator synthesises a Learning from the (task_id, predicate_name, reason) tuple via agora.fleet.auto_learning.synthesize_failure_learning() and injects it into the agent’s system prompt for the retry. confidence is boosted by reinforce() when the same failure recurs and decays over time via decay_learnings(); only learnings with confidence above CONFIDENCE_THRESHOLD (0.3) are surfaced to the model.

id: str
category: LearningCategory
content: str
confidence: float
task_ref: str
reinforcement_count: int = 0
created_at: str = ''
last_reinforced_at: str = ''
__init__(id, category, content, confidence, task_ref, reinforcement_count=0, created_at='', last_reinforced_at='')
agora.core.learning.decay_learnings(learnings)[source]

Apply confidence decay uniformly. Floor at 0.0.

agora.core.learning.filter_active(learnings)[source]

Learnings above the confidence threshold, sorted descending by confidence.

agora.core.learning.reinforce(learning)[source]

Boost confidence when a learning is referenced again; cap at MAX_CONFIDENCE.

agora.core.learning.format_learnings_for_context(learnings)[source]

Format learnings as a prompt context block, grouped by category.