agentleFS
Kastalien-ResearchKastalien-Research/thoughtbox/.agents/skills/thoughtbox-evolution/SKILL.md

thoughtbox:evolution

Skill64 starsChanged 4 months agoMITView on GitHub

A-Mem thought evolution — check which prior thoughts should be updated when a significant new insight arrives. Spawns a lightweight subagent to classify prior thoughts as UPDATE or NO_UPDATE, then applies revisions. Use during long reasoning sessions when you reach a synthesis, make a decision, or discover something that changes earlier assumptions. Triggers on "this changes what I thought earlier", "update prior reasoning", "evolve thoughts", or automatically on conclusion/synthesis thoughts in sessions >10 thoughts.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run evolution checks when the new thought:

    line 16
  2. Distinctive:

    Don't run for every thought — only on significant ones (synthesis, conclusions, decisions, revisions).

    line 22
  3. Distinctive:

    If the new insight creates, invalidates, or modifies a knowledge entity:

    line 84

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Thought Evolution (A-Mem Pattern)

When you add a new insight to a reasoning session, earlier thoughts don't automatically update. Thought 1 might say "consider rate limiting" while thought 15 decides "use sliding window algorithm" — but thought 1 doesn't know about the sliding window decision. This skill checks which prior thoughts should evolve.

Based on the A-Mem paper (arxiv.org/abs/2502.12110): when new memory is added, find related existing memories and update their context.

When to Trigger

Run evolution checks when the new thought:

  • Resolves ambiguity from earlier thoughts
  • Contradicts an earlier assumption
  • Adds implementation detail to a high-level earlier thought
  • Synthesizes multiple earlier threads into a conclusion

Don't run for every thought — only on significant ones (synthesis, conclusions, decisions, revisions).

Workflow

Phase 1: Retrieve Session Content

// thoughtbox_execute
async () => {
  const session = await tb.session.get("current-session-id");
  return session.thoughts.map((t, i) => ({
    number: t.thoughtNumber,
    content: t.thought.slice(0, 200)  // Truncate for efficiency
  }));
}

Phase 2: Spawn Evolution Checker

Dispatch a Haiku subagent for cost efficiency (~400 tokens in subagent context, ~50 tokens returned):

Spawn subagent (model: haiku):
  "Evaluate which prior thoughts should be updated based on a new insight.

   NEW INSIGHT:
   [Your new thought content]

   PRIOR THOUGHTS:
   S1: [thought 1 content]
   S2: [thought 2 content]
   ...

   For each thought, respond ONLY with:
   S1: [UPDATE|NO_UPDATE] - [brief reason if UPDATE]
   S2: [UPDATE|NO_UPDATE] - [brief reason if UPDATE]
   ...

   Be selective. Only suggest UPDATE if the new insight meaningfully enriches
   the prior thought's context. Keyword overlap alone is not enough."

Phase 3: Apply Revisions

For each thought marked UPDATE, create a revision:

async () => {
  await tb.thought({
    thought: "EVOLVED: [original content] — Now contextualized: [how new insight relates]",
    thoughtType: "reasoning",
    isRevision: true,
    revisesThought: 1,  // The thought number being updated
    thoughtNumber: 20,  // Current thought number (advances the chain)
    totalThoughts: 25,
    nextThoughtNeeded: true
  });
}

Phase 4: Update Knowledge Graph (If Applicable)

If the new insight creates, invalidates, or modifies a knowledge entity:

async () => {
  // Add observation to existing entity
  await tb.knowledge.addObservation({
    entity_id: "entity-uuid",
    content: "Updated understanding: sliding window chosen over fixed buckets (see session XYZ, thought 15)"
  });
}

Evolution Criteria

A thought should be updated if the new insight:

CriterionExample
Resolves ambiguityOld: "consider rate limiting" → New: "using sliding window"
Adds implementation detailOld: "need caching" → New: "Redis with 5-min TTL"
Contradicts or refinesOld: "JWT approach" → New: "JWTs won't work here"
Creates connectionOld: "auth is separate" → New: "auth and rate limiting share session store"

A thought should NOT be updated if:

  • Connection is trivial (just keyword overlap)
  • Old thought already implies the new insight
  • Old thought is completely unrelated

Sliding Window Optimization

For long sessions (>30 thoughts), don't check all prior thoughts — check only the last 10-15 or use the most relevant ones:

async () => {
  const session = await tb.session.get("session-id");
  // Only check recent thoughts, not the entire history
  const recentThoughts = session.thoughts.slice(-15);
  return recentThoughts;
}

Cost

  • Haiku subagent: ~400 tokens per check
  • Your context: ~50 tokens (just the UPDATE/NO_UPDATE list)
  • Break-even: always cheaper than manual review for sessions >3 thoughts

See thoughtbox://prompts/evolution-check for the full pattern reference.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.