Learning Loop
How Org in a Box automatically learns from agent behaviour and proposes reusable skills.
Overview
After every agent session that reaches idle status, the reflection plugin:
- Loads the full session transcript
- Extracts a tool trajectory (ordered sequence of tool calls with input/output summaries)
- Hashes the trajectory using SHA-256
- Generates a reflection via LLM: "What worked? What failed? Any reusable patterns?"
- Stores the trajectory and reflection in the
trajectoriestable with a pgvector embedding - Checks for similar past trajectories (cosine similarity > 0.8, tool overlap ≥ 70%)
- When 3+ similar trajectories exist, auto-proposes a
skill
Trajectory Hashing
Two trajectories are "similar" if:
- Their tool sequences overlap by ≥ 70% (Jaccard-style:
|intersection| / |max(A,B)|) - Their embeddings have cosine similarity > 0.8
This catches the same task approached slightly differently (different tool order, minor phrasing variations) without treating every unique task as a new pattern.
Skill Lifecycle
proposed → promoted → deprecated
| Status | Meaning |
|---|---|
proposed | Auto-created by reflection plugin; not yet active |
promoted | Admin approved; available to all agents in the tenant |
deprecated | Retired; no longer shown to agents |
Transition rules: proposed → promoted, proposed → deprecated, promoted → deprecated. No backwards transitions.
Managing Skills
Via admin API
GET /v1/skills?status=proposed
PATCH /v1/skills/:id/promote
PATCH /v1/skills/:id/deprecate
Via the TUI
/skills proposed # list proposed skills awaiting review
/skills promoted # list active skills
In the web dashboard
The admin panel Skills page shows proposed skills with their source trajectories. Click Promote to make a skill available to agents, or Deprecate to retire it.
What a Skill Contains
{
"name": "competitive-analysis",
"description": "Research 3+ competitors and produce a structured comparison",
"body": "# Skill: Competitive Analysis\n\n## When to use\n...\n\n## Steps\n...",
"triggers": ["compare competitors", "competitive analysis", "market research"],
"status": "promoted",
"version": 1
}
Promoted skills are written to SKILL.md files in the sandbox so opencode can reference them during planning.
Storage
| Table | Description |
|---|---|
trajectories | One row per session; tools JSONB, embedding vector(1536), reflection text |
skills | Versioned skill definitions; source_trajectories array of trajectory IDs |
Disabling
Set OIAB_REFLECTION_DISABLED=true to skip the reflection hook for a session, or remove @orginabox/plugin-reflection from opencode.jsonc.
