Skip to content

[VEPEAGE-000] Session-based procedural skill learning (core of skill-bench-public-repro) - #142

Merged
richard-peng-xia merged 4 commits into
mainfrom
feat/procedural-skill-learning
Oct 28, 2026
Merged

richard-peng-xia merged 4 commits into
mainfrom
feat/procedural-skill-learning

Conversation

@richard-peng-xia

@richard-peng-xia richard-peng-xia commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR holds the core MIRIX part of skill-bench-public-repro (104d601, by nanxingw). The evals/skill_bench harness (ALFWorld / WebShop, ~143k lines) is left out and stays on skill-bench-public-repro, the frozen reproduction branch its README already points to.

New in this PR:

  • Conversation store and session lifecycle:
    • conversation_session tracks each session.
    • task sessions are stored for skill learning and never reach the meta agent.
    • A session ends on an explicit close, on idle, or by the sweeper.
  • Skill learning:
    • The threshold trigger queues skill_learning_runs.
    • The experience distiller turns sessions into experiences, and the skill curator turns experiences into skills in token-budgeted batches.
    • Skill changes are versioned (skill_version / skill_object), and leftover experiences feed an experience pool.
  • Retrieval:
    • BM25 + cosine fused with RRF, then a similarity gate.
    • Every retrieval writes a retrieval_log row.
    • Tenant guards on retrieve and search.
  • Images: a content-addressed image store and remote image fetching with SSRF guards.
  • Security fixes against main:
    • A deleted client API key kept working (the delete was never awaited).
    • file_uri parts led to local file reads on the server.
    • The retrieve endpoints did not check the user's organization.
  • Migrations: 9 SQL migrations plus backfill and re-embed scripts.

Commits

  1. Add session-based procedural skill learning: 104d601 minus evals/skill_bench, byte-identical otherwise, authored by nanxingw.

  2. Fix image release scope and organization deletion: fixes found in review.

    • release_message_images deleted any files row a message referenced by id; it now deletes only image rows MIRIX wrote.
    • is_managed_image_path did not require the scoped layout to sit under the images root.
    • delete_organization_by_id failed on Postgres: the new session and learning tables block the users' cascaded delete through their foreign keys. Added tests/test_organization_delete_pg.py.
  3. Decouple core from the skill_bench harness:

    • Drops the skill-bench extra, the harness test path and its .gitignore entries.
    • The PG e2e test checks the harness's OpenAPI contract only when the harness is in the checkout.
  4. Fit the e2e curator batch in its context window: the e2e test's window goes from 20k to 21k. The long topic's edit step now fits, and the long session still chunks and the curator still batches.

Tests

  • pytest (default config): 2970 passed, 52 skipped, 0 failed.
  • PG integration via scripts/run_pg_integration_tests.sh: all pass (after commit 4 below; before it, tests/test_skill_learning_e2e_pg.py::test_task_sessions_become_retrievable_skills failed).
    • That test also fails on the original 104d601, including in a Python 3.11 env pinned to requirements-lock.txt.
    • Cause: one curator batch peaks at ~14.5k context tokens, above the 20,000 × 0.8 − 1,600 = 14,400 limit. The batch ends context_limit and is returned instead of consumed.
    • Most likely the curator prompt grew after the test was calibrated.

To do before merge

  • Fix the e2e test above: commit 4 raises its CONTEXT_WINDOW to 21k. The test passes 4/4 in a py3.12 env and in a py3.11 env pinned to requirements-lock.txt.
  • Add an upgrade runbook covering:
    • the order of the 9 migrations (today it exists only in _MIGRATION_HINTS);
    • the downtime migrate_skill_retrieval_fields.sql needs (it nulls every skill vector under an ACCESS EXCLUSIVE lock and is not safe for a rolling deploy);
    • then backfill_skill_baseline_versions.py and reembed_skill_retrieval.py.
  • Decide the retrieval gate (0.62 / 0.90) for embedding models other than gemini-embedding-001. Today they get those values with only a warning, which can return zero skills.
  • Release notes for changed defaults:
    • RETRIEVAL_LOG_ENABLED is on and stores raw queries for 30 days.
    • Curator max steps go from 15 to 100, with no per-run cost cap.
    • A session ends only on close or after 48 h idle.
    • Non-Gemini embeddings are chunked at 2,048 tokens.
    • The first auto_dream after the upgrade may distill the whole backlog.
    • Removed env vars (SKILL_EDIT_BUDGET_*, SKILL_EVOLVE_MAX_CHAINING_STEPS, …) are now ignored silently.
  • Release notes for API changes:
    • /memory/add with session_tag=task requires a session_id and skips meta extraction.
    • /memory/retrieve/conversation always makes a topic-extraction LLM call and returns 422 when there is no text or image.
    • DELETE /memory/procedural/{id} is scoped to the user.
    • The skill_list and skill_delete tool signatures changed.

Follow-ups (not blocking):

  • Inline trigger locking on every task write.
  • LIKE '%id%' scans in image release.
  • The startup anti-join over conversation_message.
  • The size of procedural_memory_agent.txt (7 KB to 19.5 KB) and its benchmark-flavoured rules.

After this merges, rebase skill-bench-public-repro onto main so that it carries only the harness.

🤖 Generated with Claude Code

nanxingw and others added 3 commits October 27, 2026 10:27
Implement session-based skill learning, curation, versioned storage and
retrieval: the conversation store and session lifecycle, the experience
distiller and skill curator, skill history, hybrid skill retrieval with a
similarity gate, retrieval logs, database migrations and tests.

Core part of 104d601 (branch skill-bench-public-repro), without the
evals/skill_bench harness, which stays on that branch.
- release_message_images drops only files rows MIRIX wrote for an image
  (a managed path or a remote image recorded by address); a row a message
  referenced by id (database_image_id) is never deleted.
- is_managed_image_path requires the scoped layout to sit under the images
  root, as the legacy layout already did.
- delete_organization_by_id clears the session store and skill learning rows
  (conversation_session/_message, skill_experience, skill_learning_run,
  retrieval_log, skill_session_feedback) before the cascaded user delete,
  which otherwise fails on their foreign keys on Postgres.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The evals/skill_bench harness stays on skill-bench-public-repro, so main's
configuration no longer refers to it: drop the skill-bench extra, the
harness test path and its .gitignore entries. The PG e2e test checks the
harness's OpenAPI contract only when the harness is in the checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Oct 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ richard-peng-xia
❌ nanxingw
You have signed the CLA already but the status is still pending? Let us recheck it.

The batch whose curator step edits the long topic's skill (12 long triggers
in the call) peaked at ~14.5k tokens, above floor(20,000 x 0.8) - 1,600 =
14,400, so it ended on context_limit and was returned instead of consumed.
A 21k window keeps the long session chunked and the curator batching while
that step fits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@richard-peng-xia
richard-peng-xia merged commit 39e2411 into main Oct 28, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants