context-intelligence-session-reconstruction
Skill5 starsChanged 5 days agoMITView on GitHub
Use when local Amplifier session files are missing, broken, or incomplete — rebuilds events.jsonl, transcript.jsonl, and metadata.json from the context-intelligence graph server.
- Reads credentials
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- context-intelligence-derived-metricsSkill
- context-intelligence-eval-designSkill
- context-intelligence-evaluation-methodologySkill
- context-intelligence-gdsSkill
- context-intelligence-graph-querySkill
- context-intelligence-hill-climbingSkill
- context-intelligence-server-data-opsSkill
- context-intelligence-session-navigationSkill
- context-intelligence-tool-designSkill
- transcriptSkill
- workflow-pattern-analysisSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 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.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Use reconstruction when local session files are absent or unusable but the graph server holds the session data:
- Very specific: line 32
Server unreachable: If the graph server is not reachable, reconstruction cannot proceed.
- Distinctive: line 42
Verify with the status subcommand before running reconstruction:
- Very specific: line 64
Only sessions that were active while hook-context-intelligence was configured will have data in the graph.
- Distinctive: line 132
After reconstruction, verify the output files were written correctly:
≈ “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.
Files
Context Intelligence Session Reconstruction
Local Amplifier session files (events.jsonl, transcript.jsonl, metadata.json) can be reconstructed from the context-intelligence Neo4j graph server when the local files are missing, broken, or incomplete. This skill covers when and how to run the reconstruction tool safely.
When to Use
Use reconstruction when local session files are absent or unusable but the graph server holds the session data:
- Missing files: Sessions exist in the graph but have no local files — for example, after a disk wipe, new machine setup, or accidental deletion
- Broken resume:
amplifier resumeshows "unnamed", "unknown", or empty session names — reconstructingmetadata.jsonpopulates bundle, model, and session name fields - Unknown bundles: Sessions that show no bundle information in the resume list — reconstruction extracts bundle info from the graph's
session_startblob
When NOT to Use
- Server unreachable: If the graph server is not reachable, reconstruction cannot proceed. Verify server reachability first with
python scripts/context-intelligence.py status. If the server is down, fall back tosession-navigatorfor local file navigation. - Pre-hook sessions: Sessions that predate the
hook-context-intelligencehook have no data in the graph. Reconstruction cannot create files for these sessions — there is no source data to read from. - Real-time data: Reconstruction reads a snapshot of what is stored in the graph. It is not a live stream. Do not use it to monitor an active session or capture events as they happen.
Prerequisites
1. Graph server must be reachable
Verify with the status subcommand before running reconstruction:
python scripts/context-intelligence.py statusA healthy server responds with "status": "ok". If the server is unreachable, this command will report the error. Do not proceed with reconstruction until status is ok.
2. API key must be configured
Three methods — use whichever fits your environment:
| Method | How |
| Environment variable | export AMPLIFIER_CONTEXT_INTELLIGENCE_API_KEY=<key> |
| CLI flag | Pass --api-key <key> to any subcommand |
| Settings file | Add context_intelligence_api_key: <key> to ~/.amplifier/settings.yaml |
The CLI resolves in this order: flag → env var → ~/.amplifier/settings.yaml.
3. Sessions must have been captured by the hook
Only sessions that were active while hook-context-intelligence was configured will have data in the graph. Pre-hook sessions cannot be reconstructed.
Usage Patterns
All patterns use:
python scripts/context-intelligence.py reconstruct [OPTIONS]Fix broken resume list (fastest, recommended first)
Reconstructs only metadata.json without touching events.jsonl or transcript.jsonl. Use this when amplifier resume shows unnamed or unknown sessions.
python scripts/context-intelligence.py reconstruct --metadata-onlyPreview what would be written (dry run)
Shows what files would be created or updated without writing anything. Add --verbose for detailed per-session output.
python scripts/context-intelligence.py reconstruct --dry-run --verboseReconstruct a single session
Limits reconstruction to one session by ID or prefix. Use when you know exactly which session needs repair.
python scripts/context-intelligence.py reconstruct --session <session-id-or-prefix> --forceThe --force flag overwrites any existing files for that session. Omit --force to skip files that already exist.
Full reconstruction — skip existing files
Reconstructs all sessions in the project, skipping sessions where files already exist. Safe to run repeatedly.
python scripts/context-intelligence.py reconstructFull reconstruction — overwrite all files
Reconstructs all sessions and overwrites existing files. Use only when explicitly requested or when existing files are known to be corrupt.
python scripts/context-intelligence.py reconstruct --forceReconstruct with raw LLM data (large output)
The --resolve-blobs flag inlines full blob payloads into events.jsonl, including complete LLM request/response bodies. This produces significantly larger files (~19MB for a typical long session with many LLM turns).
python scripts/context-intelligence.py reconstruct --resolve-blobsUse
--resolve-blobsonly when you need access to raw LLM input/output. For most use cases — resume list repair, event counts, delegation trees — reconstructing without blobs is sufficient and much faster.
Verification
After reconstruction, verify the output files were written correctly:
Check line counts for events and transcript:
CONTEXT_INTELLIGENCE_ROOT="${AMPLIFIER_CONTEXT_INTELLIGENCE_BASE_PATH:-$HOME/.amplifier/projects}"
wc -l "$CONTEXT_INTELLIGENCE_ROOT"/{workspace}/sessions/{session-id}/context-intelligence/events.jsonl
wc -l "$CONTEXT_INTELLIGENCE_ROOT"/{workspace}/sessions/{session-id}/context-intelligence/transcript.jsonlA reconstructed events.jsonl should have at least a few lines (session start, prompts, tool calls). Zero lines indicates the session had no recoverable events.
Validate metadata JSON is well-formed:
CONTEXT_INTELLIGENCE_ROOT="${AMPLIFIER_CONTEXT_INTELLIGENCE_BASE_PATH:-$HOME/.amplifier/projects}"
cat "$CONTEXT_INTELLIGENCE_ROOT"/{workspace}/sessions/{session-id}/context-intelligence/metadata.json | python3 -m json.toolThis confirms the file is valid JSON. Check that bundle, model, and session_id fields are populated.
Confirm sessions appear in the resume list:
amplifier session listSessions with successfully reconstructed metadata.json should now appear with names, bundle info, and model rather than "unknown" or empty fields.
Known Limitations
- Streaming events not recoverable (~39%):
content_block:startandcontent_block:endevents are not stored in the graph — they account for approximately 39% of hook-logging events. Reconstructedevents.jsonlfiles will be missing these events. This does not affect session content, only streaming telemetry. - Delegate events may be incomplete:
delegate:agent_spawnedanddelegate:agent_completedevents depend ondata_delegate_*graph properties that may be null for sessions that were in progress when captured. These events may appear with partial data in the reconstructed files. - Session names are approximations: Session names are generated at runtime by
hooks-session-namingfrom the first user prompt. That output is not stored in the graph. Reconstruction generates names from the same source (the first prompt), but the exact phrasing may differ from the original session name. - Pre-hook sessions have no graph data: Sessions that predate the
hook-context-intelligencehook have no entries in the graph. Reconstruction will produce empty output for these sessions — there is no data to read. Usesession-navigatorto work with pre-hook sessions directly from local JSONL files if they still exist on disk.
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
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.

