{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c9687540",
   "metadata": {},
   "source": [
    "# CS 839: Memory Under Compaction\n",
    "\n",
    "**A group exercise: what happens when an agent repeatedly compresses its history?**\n",
    "\n",
    "You are managing memory for an agent helping a research group finish a camera-ready paper. The project will unfold in **three rounds**. After each round, maintain two parallel memories:\n",
    "\n",
    "1. **Manual memory:** your group manually performs the compaction.\n",
    "2. **LLM memory:** an API call performs the compaction using a prompt your group controls.\n",
    "\n",
    "Each memory may contain at most **8 records and 120 words**. At the end, a hidden evaluation will score both final memories.\n",
    "\n",
    "What's our goal? As always, we must preserve enough state for an agent to act correctly later."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ff4168b5",
   "metadata": {},
   "source": [
    "## Rules and timing\n",
    "\n",
    "For each round:\n",
    "\n",
    "1. Read only the newly revealed events.\n",
    "2. Update the **manual memory first**, without looking at the LLM's answer (honor system, but it's also more fun this way).\n",
    "3. Run the LLM compaction. You may revise its prompt between rounds.\n",
    "4. Once you move to the next round, treat the previous event log as unavailable. Use only the previous memory plus the new events.\n",
    "\n",
    "**Do not scroll ahead to the evaluation.** Its questions are intentionally hidden."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb7c361c",
   "metadata": {},
   "source": [
    "## 0. Setup\n",
    "\n",
    "Run these cells once. The key is entered with `getpass`, so it will not be displayed in the notebook. We use the OpenAI Responses API."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b376aed0",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Run only if the OpenAI package is not already installed.\n",
    "%pip install -q \"openai>=1.0\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "df23166c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import getpass\n",
    "import os\n",
    "import re\n",
    "\n",
    "try:\n",
    "    from openai import OpenAI\n",
    "except ModuleNotFoundError:\n",
    "    OpenAI = None\n",
    "\n",
    "MODEL = os.getenv(\"CS839_MODEL\", \"gpt-5.6-luna\")\n",
    "SKIP_API = os.getenv(\"CS839_SKIP_API\", \"0\") == \"1\"\n",
    "\n",
    "if not os.getenv(\"OPENAI_API_KEY\") and not SKIP_API:\n",
    "    entered_key = getpass.getpass(\"Paste your team's API key (hidden): \" ).strip()\n",
    "    if entered_key:\n",
    "        os.environ[\"OPENAI_API_KEY\"] = entered_key\n",
    "\n",
    "if os.getenv(\"OPENAI_API_KEY\") and OpenAI is None:\n",
    "    raise RuntimeError(\"The openai package is unavailable. Run the installation cell, then retry.\")\n",
    "\n",
    "client = OpenAI() if os.getenv(\"OPENAI_API_KEY\") and OpenAI else None\n",
    "USAGE_LOG = []\n",
    "\n",
    "print(f\"Model: {MODEL}\")\n",
    "print(\"API client ready.\" if client else \"No key supplied; the manual track still works.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f5203972",
   "metadata": {},
   "outputs": [],
   "source": [
    "MAX_RECORDS = 8\n",
    "MAX_WORDS = 120\n",
    "\n",
    "def memory_lines(memory):\n",
    "    return [line.strip() for line in memory.splitlines() if line.strip()]\n",
    "\n",
    "def budget_report(memory, label=\"Memory\"):\n",
    "    records = len(memory_lines(memory))\n",
    "    words = len(memory.split())\n",
    "    ok = records <= MAX_RECORDS and words <= MAX_WORDS\n",
    "    mark = \"✓\" if ok else \"✗\"\n",
    "    print(f\"{mark} {label}: {records}/{MAX_RECORDS} records, {words}/{MAX_WORDS} words\")\n",
    "    return ok\n",
    "\n",
    "def compact_memory(old_memory, new_events, instructions, round_name):\n",
    "    if client is None:\n",
    "        print(\"API call skipped: no client configured.\")\n",
    "        return \"\"\n",
    "\n",
    "    request = f\"\"\"\n",
    "CURRENT MEMORY\n",
    "{old_memory if old_memory.strip() else '(empty)'}\n",
    "\n",
    "NEW EVENTS\n",
    "{new_events}\n",
    "\n",
    "Update the memory. Return only the new memory: one record per line, no heading.\n",
    "The result must contain at most {MAX_RECORDS} records and {MAX_WORDS} words.\n",
    "\"\"\".strip()\n",
    "\n",
    "    response = client.responses.create(\n",
    "        model=MODEL,\n",
    "        instructions=instructions,\n",
    "        input=request,\n",
    "    )\n",
    "    result = response.output_text.strip()\n",
    "\n",
    "    if response.usage:\n",
    "        usage = {\n",
    "            \"round\": round_name,\n",
    "            \"input_tokens\": response.usage.input_tokens,\n",
    "            \"output_tokens\": response.usage.output_tokens,\n",
    "        }\n",
    "        USAGE_LOG.append(usage)\n",
    "        print(\n",
    "            f\"Tokens: {usage['input_tokens']} input, \"\n",
    "            f\"{usage['output_tokens']} output\"\n",
    "        )\n",
    "\n",
    "    print(\"\\nLLM MEMORY\\n\")\n",
    "    print(result)\n",
    "    budget_report(result, f\"LLM memory after {round_name}\")\n",
    "    return result"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1082469c",
   "metadata": {},
   "source": [
    "### Your compaction prompt\n",
    "\n",
    "This starter prompt is deliberately limited & underspecified. Edit it however you want. Your LLM receives only this instruction, its previous compacted memory, and the newly revealed events.\n",
    "\n",
    "Think about questions such as:\n",
    "\n",
    "- Should old facts be deleted, marked obsolete, or kept?\n",
    "- Should uncertain and confirmed facts be represented differently?\n",
    "- Are negative constraints worth remembering?\n",
    "- Should the memory preserve the origin, current state, next actions, all of the above, etc?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0873f419",
   "metadata": {},
   "outputs": [],
   "source": [
    "COMPACTION_PROMPT = \"\"\"\n",
    "You maintain compact working memory for a research agent. Preserve the information\n",
    "most likely to matter for future decisions and actions.\n",
    "\"\"\".strip()\n",
    "\n",
    "print(COMPACTION_PROMPT)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "85bae24b",
   "metadata": {},
   "source": [
    "# Round 1 — An apparently straightforward project\n",
    "\n",
    "Read the events below. First build the memory manually. Then run the LLM compaction."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a3de0c0c",
   "metadata": {},
   "outputs": [],
   "source": [
    "ROUND_1 = \"\"\"\n",
    "[Mon 09:05 | PI] The camera-ready deadline is Friday at 4:00 PM Central. We must upload both a manuscript and a supplement.\n",
    "[Mon 09:18 | Data lead] The working dataset is /data/screen_v1.csv. It contains 128 experimental rows.\n",
    "[Mon 09:31 | Scientist] NiFe-17 is currently our best catalyst, with 63.2% yield.\n",
    "[Mon 09:34 | Scientist] The in-house Ni-3 baseline achieved 57.8% under the same protocol.\n",
    "[Mon 10:02 | Student] Figure 3 is /paper/figures/figure3_draft.pdf and was generated from screen_v1.csv.\n",
    "[Mon 10:16 | Writer] The working manuscript is /paper/draft_sep18.docx.\n",
    "[Mon 11:07 | Reviewer note] Please compare against the published Pt/C value of 59.8%.\n",
    "[Mon 11:20 | Scientist] Warning: Pt/C used a different temperature and assay. It is useful context but not a direct baseline.\n",
    "[Mon 13:00 | PI] Proposed headline: 'NiFe-17 outperforms all baselines.'\n",
    "[Mon 13:14 | Admin] Thursday's lab meeting moved from 1 PM to 2 PM.\n",
    "\"\"\".strip()\n",
    "\n",
    "print(ROUND_1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "57ecc6f6",
   "metadata": {},
   "source": [
    "## 1A. Manual compaction\n",
    "\n",
    "Write at most eight records, one per line. You are allowed to combine several related events into one record."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "429f2899",
   "metadata": {},
   "outputs": [],
   "source": [
    "MANUAL_MEMORY_R1 = \"\"\"\n",
    "Replace this line with your first memory record.\n",
    "\"\"\".strip()\n",
    "\n",
    "print(MANUAL_MEMORY_R1)\n",
    "budget_report(MANUAL_MEMORY_R1, \"Manual memory after Round 1\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f7348fe6",
   "metadata": {},
   "source": [
    "## 1B. LLM compaction\n",
    "\n",
    "Run this only after committing your manual memory. You may edit `COMPACTION_PROMPT` first."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "37aa802f",
   "metadata": {},
   "outputs": [],
   "source": [
    "LLM_MEMORY_R1 = compact_memory(\n",
    "    old_memory=\"\",\n",
    "    new_events=ROUND_1,\n",
    "    instructions=COMPACTION_PROMPT,\n",
    "    round_name=\"Round 1\",\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5c0508fb",
   "metadata": {},
   "source": [
    "# Round 2 — Corrections and uncertainty\n",
    "\n",
    "Pretend the Round 1 event log is no longer available. Update each memory using only its previous contents and these new events.\n",
    "\n",
    "Again: manual first, LLM second."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1bb812f1",
   "metadata": {},
   "outputs": [],
   "source": [
    "ROUND_2 = \"\"\"\n",
    "[Tue 08:10 | QA] screen_v1.csv included 9 calibration runs mislabeled as independent experiments. Do not use its row count or results.\n",
    "[Tue 08:42 | Data lead] The cleaned dataset is /data/screen_v2.csv with 119 valid runs. It supersedes v1.\n",
    "[Tue 09:05 | Analyst] Reanalysis on v2 puts NiFe-17 at 58.9% yield. The earlier 63.2% value is invalid.\n",
    "[Tue 09:07 | Analyst] NiFe-12 is now the selected candidate at 60.4% ± 1.1%.\n",
    "[Tue 09:25 | Lead] Keep Ni-3 at 57.8% as the primary matched baseline. Pt/C may appear only as cross-study context.\n",
    "[Tue 09:44 | Writer] Replace 'outperforms all baselines' with 'improves over the in-house baseline under matched conditions.' We cannot make a state-of-the-art claim.\n",
    "[Tue 10:16 | Student] Corrected Figure 3 is /paper/figures/figure3_v2.pdf, generated from screen_v2.csv.\n",
    "[Tue 10:40 | Writer] The current manuscript is /paper/camera_ready_v2.docx. draft_sep18.docx is obsolete.\n",
    "[Tue 12:03 | Experimenter] One final replicate, C-118, is scheduled for Thursday. Its result could change the reported mean.\n",
    "[Tue 12:20 | Admin] Lunch on Friday will include a vegetarian option.\n",
    "\"\"\".strip()\n",
    "\n",
    "print(ROUND_2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b544ac58",
   "metadata": {},
   "source": [
    "## 2A. Manual compaction\n",
    "\n",
    "Copy your Round 1 manual memory, then revise it. Do not simply append everything."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "994dc456",
   "metadata": {},
   "outputs": [],
   "source": [
    "MANUAL_MEMORY_R2 = \"\"\"\n",
    "Replace this block with your compacted Round 2 memory.\n",
    "\"\"\".strip()\n",
    "\n",
    "print(MANUAL_MEMORY_R2)\n",
    "budget_report(MANUAL_MEMORY_R2, \"Manual memory after Round 2\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a49744b0",
   "metadata": {},
   "source": [
    "## 2B. LLM compaction\n",
    "\n",
    "You may now revise `COMPACTION_PROMPT`. If the first compaction kept trivia, lost warnings, or represented stale values poorly, try to express a better memory."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "09aaec3a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Optional: revise the policy before running Round 2.\n",
    "# COMPACTION_PROMPT = \"\"\"...\"\"\"\n",
    "\n",
    "LLM_MEMORY_R2 = compact_memory(\n",
    "    old_memory=LLM_MEMORY_R1,\n",
    "    new_events=ROUND_2,\n",
    "    instructions=COMPACTION_PROMPT,\n",
    "    round_name=\"Round 2\",\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f2ed758d",
   "metadata": {},
   "source": [
    "# Round 3 — Final state and a hidden blocker\n",
    "\n",
    "This is the last compaction. The next task is still hidden. Manual first, LLM second."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c41ca096",
   "metadata": {},
   "outputs": [],
   "source": [
    "ROUND_3 = \"\"\"\n",
    "[Thu 10:15 | Experimenter] Replicate C-118 finished, but its contamination control failed. Exclude C-118 from the analysis.\n",
    "[Thu 10:32 | Data lead] Final data are in /data/screen_v3.csv: 118 valid runs after excluding C-118. v2 is now obsolete.\n",
    "[Thu 10:48 | Analyst] Final NiFe-12 result on v3 is 59.9% ± 1.2% yield. This replaces 60.4% ± 1.1%.\n",
    "[Thu 10:51 | Analyst] NiFe-12 is 2.1 percentage points above the matched Ni-3 baseline of 57.8%.\n",
    "[Thu 11:06 | PI] Final claim: 'NiFe-12 improved yield by 2.1 percentage points over Ni-3 under matched conditions.' Avoid 'state of the art.'\n",
    "[Thu 11:22 | Designer] Final Figure 3 is /paper/figures/figure3_final.pdf and was built from v3. Do not submit figure3_v2.pdf.\n",
    "[Thu 12:04 | Writer] Submission manuscript is /paper/camera_ready_final.pdf. Its fonts are embedded and the font check passed. Do not upload the .docx file.\n",
    "[Thu 12:18 | Writer] Supplement candidate is /paper/supplement_final.pdf, but its provenance table still lists C-118 as valid.\n",
    "[Thu 12:21 | Lead] Upload is blocked until C-118 is marked excluded in the supplement and the supplement checksum is rerun.\n",
    "[Thu 13:10 | Collaborator] Great to see the 60.4% result in yesterday's draft!\n",
    "[Thu 13:27 | Admin] Tomorrow's seminar moved from room 105 to room 214.\n",
    "[Thu 14:02 | PI] Deadline is unchanged: Friday at 4:00 PM Central. Manuscript and corrected supplement are both required.\n",
    "\"\"\".strip()\n",
    "\n",
    "print(ROUND_3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "750fc7a3",
   "metadata": {},
   "source": [
    "## 3A. Final manual compaction\n",
    "\n",
    "Produce the manual memory that your agent will carry into the hidden task."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "512a6152",
   "metadata": {},
   "outputs": [],
   "source": [
    "MANUAL_MEMORY_FINAL = \"\"\"\n",
    "Replace this block with your final manual memory.\n",
    "\"\"\".strip()\n",
    "\n",
    "print(MANUAL_MEMORY_FINAL)\n",
    "budget_report(MANUAL_MEMORY_FINAL, \"Final manual memory\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e923043",
   "metadata": {},
   "source": [
    "## 3B. Final LLM compaction\n",
    "\n",
    "One last opportunity to revise the policy. Do not put answers from the event log directly into the prompt; write a general compaction policy that should work on another project too."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4971eeb3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Optional: revise the policy before the final compaction.\n",
    "# COMPACTION_PROMPT = \"\"\"...\"\"\"\n",
    "\n",
    "LLM_MEMORY_FINAL = compact_memory(\n",
    "    old_memory=LLM_MEMORY_R2,\n",
    "    new_events=ROUND_3,\n",
    "    instructions=COMPACTION_PROMPT,\n",
    "    round_name=\"Round 3\",\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ee986920",
   "metadata": {},
   "source": [
    "# Stop: commit both memories\n",
    "\n",
    "Before continuing:\n",
    "\n",
    "- Confirm that `MANUAL_MEMORY_FINAL` contains your real final manual memory.\n",
    "- Confirm that `LLM_MEMORY_FINAL` contains the final API-produced memory.\n",
    "- Do not edit either memory after revealing the evaluation.\n",
    "\n",
    "Then run the next cell."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cbfee331",
   "metadata": {},
   "outputs": [],
   "source": [
    "NEXT_TASK = \"\"\"\n",
    "It is Friday at 2:30 PM. Prepare the final upload checklist and a short status\n",
    "message to the PI. State exactly which scientific result, comparison, claim,\n",
    "manuscript, figure, and supplement should be used; identify anything still\n",
    "blocking submission; and make sure the upload happens before the deadline.\n",
    "\"\"\".strip()\n",
    "\n",
    "print(NEXT_TASK)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "08c6a38c",
   "metadata": {},
   "source": [
    "# Evaluation\n",
    "\n",
    "The scorer checks whether each memory itself contains the information needed for the task. It is intentionally literal: exact numbers and filenames matter in operational memory. There are 10 points.\n",
    "\n",
    "This keyword scorer is not a perfect semantic evaluator. If it misses a genuinely equivalent wording, mark that for class discussion—but do not silently rewrite the memory."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "962010a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "def normalized(text):\n",
    "    text = text.lower().replace(\"±\", \"+/-\")\n",
    "    return re.sub(r\"\\s+\", \" \", text)\n",
    "\n",
    "def contains_all(text, required):\n",
    "    return all(token in text for token in required)\n",
    "\n",
    "def contains_any(text, alternatives):\n",
    "    return any(token in text for token in alternatives)\n",
    "\n",
    "CRITERIA = [\n",
    "    (\"Final dataset and valid-run count\",\n",
    "     lambda t: contains_all(t, [\"screen_v3.csv\", \"118\"])),\n",
    "    (\"Selected catalyst and final result\",\n",
    "     lambda t: contains_all(t, [\"nife-12\", \"59.9\", \"1.2\"])),\n",
    "    (\"Matched baseline and value\",\n",
    "     lambda t: contains_all(t, [\"ni-3\", \"57.8\"])),\n",
    "    (\"Defensible claim boundary\",\n",
    "     lambda t: contains_all(t, [\"2.1\", \"matched\"])),\n",
    "    (\"Pt/C is not a direct comparison\",\n",
    "     lambda t: \"pt/c\" in t and contains_any(t, [\"not direct\", \"not directly\", \"different protocol\", \"context only\", \"cross-study\"])),\n",
    "    (\"Submission manuscript and font status\",\n",
    "     lambda t: contains_all(t, [\"camera_ready_final.pdf\", \"font\"])),\n",
    "    (\"Final Figure 3\",\n",
    "     lambda t: \"figure3_final.pdf\" in t),\n",
    "    (\"Supplement blocker involving C-118\",\n",
    "     lambda t: contains_all(t, [\"supplement_final.pdf\", \"c-118\", \"excluded\"])),\n",
    "    (\"Required checksum action\",\n",
    "     lambda t: \"checksum\" in t),\n",
    "    (\"Deadline and both deliverables\",\n",
    "     lambda t: contains_all(t, [\"friday\", \"4\", \"manuscript\", \"supplement\"]) and contains_any(t, [\"central\", \"ct\"])),\n",
    "]\n",
    "\n",
    "def score_memory(memory, label):\n",
    "    text = normalized(memory)\n",
    "    results = [(name, test(text)) for name, test in CRITERIA]\n",
    "    score = sum(passed for _, passed in results)\n",
    "\n",
    "    print(f\"{label}: {score}/{len(CRITERIA)}\\n\")\n",
    "    for name, passed in results:\n",
    "        print(f\"{'✓' if passed else '✗'} {name}\")\n",
    "    print()\n",
    "    budget_report(memory, label)\n",
    "    return score, results\n",
    "\n",
    "manual_score, manual_results = score_memory(MANUAL_MEMORY_FINAL, \"MANUAL MEMORY\")\n",
    "print(\"\\n\" + \"-\" * 60 + \"\\n\")\n",
    "llm_score, llm_results = score_memory(LLM_MEMORY_FINAL, \"LLM MEMORY\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f52ff22f",
   "metadata": {},
   "source": [
    "## Ground truth and upload checklist\n",
    "\n",
    "Now that both memories have been scored, reveal the intended state:\n",
    "\n",
    "1. Use `/data/screen_v3.csv` with **118 valid runs**.\n",
    "2. Report **NiFe-12: 59.9% ± 1.2% yield**.\n",
    "3. Compare against the matched **Ni-3 baseline: 57.8%**.\n",
    "4. Safe claim: **NiFe-12 improved yield by 2.1 percentage points over Ni-3 under matched conditions.**\n",
    "5. Pt/C at 59.8% is cross-study context, not a direct baseline because it used a different protocol.\n",
    "6. Upload `/paper/camera_ready_final.pdf`; its font check passed.\n",
    "7. Use `/paper/figures/figure3_final.pdf`.\n",
    "8. Use `/paper/supplement_final.pdf`, but first mark C-118 excluded in its provenance table.\n",
    "9. Rerun the supplement checksum after that correction.\n",
    "10. Upload both manuscript and corrected supplement by **Friday at 4:00 PM Central**."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "380a3bdf",
   "metadata": {},
   "outputs": [],
   "source": [
    "if USAGE_LOG:\n",
    "    total_input = sum(row[\"input_tokens\"] for row in USAGE_LOG)\n",
    "    total_output = sum(row[\"output_tokens\"] for row in USAGE_LOG)\n",
    "    print(\"LLM compaction usage\")\n",
    "    for row in USAGE_LOG:\n",
    "        print(f\"- {row['round']}: {row['input_tokens']} input, {row['output_tokens']} output\")\n",
    "    print(f\"Total: {total_input} input, {total_output} output tokens\")\n",
    "else:\n",
    "    print(\"No API usage was recorded.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bbcb4915",
   "metadata": {},
   "source": [
    "# Quick discussion\n",
    "\n",
    "Be ready to report one observation:\n",
    "\n",
    "- Which approach scored better: manual or LLM compaction? Why?\n",
    "- Did either memory retain a stale number or filename?\n",
    "- Did either memory lose a negative constraint such as “not a direct baseline”?\n",
    "- Which fact looked minor when it arrived but mattered for the final task?\n",
    "- What general change to the compaction prompt helped most?\n",
    "- Did repeated compaction fail differently from a one-shot summary?\n",
    "\n",
    "**Takeaway:** good memory is an actively maintained state, not a shorter transcript. Repeated compaction must handle supersession, uncertainty, provenance, constraints, and unfinished actions—not only salience."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
