Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(vibey): with no memo candidate, tell the checkpoint turn memo.md is empty and show no list (#2832)

Call Whitee1b8b3c93274
diff --git a/core/agent_core/harness/context.py b/core/agent_core/harness/context.py
index 4ac1f99cb..b3a880d63 100644
--- a/core/agent_core/harness/context.py
+++ b/core/agent_core/harness/context.py
@@ -169,9 +169,9 @@ After this, the conversation above will be replaced by your mind, your memo, you
Everything above is experience to consolidate, not instructions to act on now. This request is not part of that experience: do not write it, or anything it asks of you, as something the user said, as a goal or requirement, or as a next step. Consolidate the work as it stood before this request.
-Your scratch directory is {scratch}. It holds two files, and you already have both word for word, so do not read them: edit them directly, giving each its full path, and make the edit calls for both files in the same response. An edit's oldText needs only a short part that is unique in the file, such as a heading line with the line under it, or "- [ ] (#1801)":
+Your scratch directory is {scratch}. It holds two files, and you already have both word for word, so do not read them: edit them directly, giving each its full path, and make all your edit calls in the same response. An edit's oldText needs only a short part that is unique in the file, such as a heading line with the line under it, or "- [ ] (#1801)":
- {scratch}/mind.md: your mind. {mind_file}
-- {scratch}/memo.md: the memo list, word for word at the end of this request.
+- {scratch}/memo.md: {memo_file}
1. Look back
Go through what happened since the previous checkpoint, in order; at your first consolidation, go through the whole conversation. For each layer, ask yourself:
@@ -235,17 +235,21 @@ The template of your now:
## Exact references
- Exact paths, identifiers, commands, links, ids, and values needed to continue.
-Rules: write "(none)" under an empty heading. Only messages the user typed are the user's words; an input marked [Harness: ...] is a background event or another agent's message, not the user's words, even when it says "the user asked ...". Preserve exact paths, identifiers, commands, error strings, and numbers. Do not invent anything that is not above. Never write out secrets, tokens, or credentials; refer to them by name. Write in the language the user writes in.
-
-Current memo.md:
-{memo}{mind_current}"""
+Rules: write "(none)" under an empty heading. Only messages the user typed are the user's words; an input marked [Harness: ...] is a background event or another agent's message, not the user's words, even when it says "the user asked ...". Preserve exact paths, identifiers, commands, error strings, and numbers. Do not invent anything that is not above. Never write out secrets, tokens, or credentials; refer to them by name. Write in the language the user writes in.{memo_list}{mind_current}"""
CHECKPOINT_REQUEST_END = "</context-checkpoint-request>"
-#: What the request says of mind.md (section 11): the previous mind, given whole after the memo list (``MIND_CURRENT``,
-#: even when the checkpoint above shows it cut), or the template at a first v5 checkpoint.
-MIND_FILE_PREVIOUS = "Its exact current content is at the end of this request, after the memo list."
+#: What the request says of mind.md (section 11): the previous mind, given whole at its end (``MIND_CURRENT``, even
+#: when the checkpoint above shows it cut), or the template at a first v5 checkpoint.
+MIND_FILE_PREVIOUS = "Its exact current content is at the end of this request."
MIND_CURRENT = "Current mind.md (exactly what the file holds now, word for word):"
MIND_FILE_FIRST = f"This is your first consolidation, so it is this empty template, word for word:\n{MIND_TEMPLATE}"
-MEMO_EMPTY = "(no messages)"
+#: What the request says of memo.md (section 11): the list, given whole at its end (``MEMO_CURRENT``); or, with no
+#: candidate, that the file is empty and not to be edited, and no list at all: nothing to check, nothing to match.
+MEMO_FILE_LISTED = "the memo list, word for word at the end of this request."
+MEMO_FILE_EMPTY = (
+ "empty, and it stays empty: no message the user typed is a memo candidate this time, so there is nothing to "
+ "check. Do not edit it; revise only mind.md."
+)
+MEMO_CURRENT = "Current memo.md:"
#: Where the request says the files are when the Session has no scratch directory (no file can be revised then).
SCRATCH_UNAVAILABLE = "(unavailable)"
#: The one corrective follow-up a rejected consolidation gets (sections 6 and 11), verbatim; ``{problem}`` names every
@@ -816,16 +820,18 @@ def checkpoint_request(
scratch: Optional[str] = None,
window: Optional[int] = None,
) -> UserMessage:
- """The checkpoint request (section 11). ``memo`` is memo.md's lines (``MemoList.lines``); ``mind`` is what mind.md
- holds, the previous checkpoint's mind whole, given after the memo list so every edit can match it exactly; empty at
- a first v5 checkpoint, whose template the request gives in place. ``scratch`` is the absolute path of the Session's
+ """The checkpoint request (section 11). ``memo`` is memo.md's lines (``MemoList.lines``), given whole at the end;
+ with none, the file is empty and the request says to leave it so, showing no list. ``mind`` is what mind.md holds,
+ the previous checkpoint's mind whole, given at the end so every edit can match it exactly; empty at a first v5
+ checkpoint, whose template the request gives in place. ``scratch`` is the absolute path of the Session's
scratch directory, where the two files are (``SCRATCH_UNAVAILABLE`` without one). The limits it states are those of
a route of ``window`` tokens (``mind_limits``, ``memo_budget``)."""
limits = {f"limit_{index}": limit for index, limit in enumerate(mind_limits(window), start=1)}
body = CHECKPOINT_REQUEST.format(
scratch=scratch or SCRATCH_UNAVAILABLE,
mind_file=MIND_FILE_PREVIOUS if mind else MIND_FILE_FIRST,
- memo="\n".join(memo) if memo else MEMO_EMPTY,
+ memo_file=MEMO_FILE_LISTED if memo else MEMO_FILE_EMPTY,
+ memo_list=f"\n\n{MEMO_CURRENT}\n" + "\n".join(memo) if memo else "",
mind_current=f"\n\n{MIND_CURRENT}\n{mind}" if mind else "",
memo_budget=memo_budget(window),
**limits,
diff --git a/docs/plans/agent-core-contracts/context.md b/docs/plans/agent-core-contracts/context.md
index 6e222cab3..ab726eaf5 100644
--- a/docs/plans/agent-core-contracts/context.md
+++ b/docs/plans/agent-core-contracts/context.md
@@ -412,8 +412,10 @@ is written, so projection stays a pure function of the rows:
host says which, §9), that no memo offered before, and that the cut does not keep (§5), unchecked. The inputs a
`checkpoint-v4` row summarized are offered once too, at the first v5 checkpoint after it. A preview is the
message on one line, its whitespace collapsed, at most 40 characters, or 200 for one the conversation the turn reads
- no longer shows. The model changes only checkboxes; a candidate left unchecked, or unchecked later, is not offered
- again: its text stays in the earlier record under its `#<seq>`. A Watch's, a Task's, a callback's, or another
+ no longer shows. With no candidate (nothing carried, and no message a person typed leaves the context, as in a
+ Session a Watch, a Task, or another agent drives), `memo.md` is empty and the request tells the turn to leave it so
+ and revise only `mind.md` (§11). The model changes only checkboxes; a candidate left unchecked, or unchecked later,
+ is not offered again: its text stays in the earlier record under its `#<seq>`. A Watch's, a Task's, a callback's, or another
Session's message is never a candidate, whatever its text says.
- **The now** (`checkpoint`): the text of the turn's one checkpoint block (§6): where the work stands and what comes
next, written again at every checkpoint.
@@ -655,13 +657,17 @@ history. The only user-visible text is the stop message after (d) (§9).
The request, verbatim (`harness/context.py` `CHECKPOINT_REQUEST`, then `CHECKPOINT_REQUEST_END`), with its fields filled
by `checkpoint_request`: `{scratch}` is the absolute path of the Session's scratch directory (`SCRATCH_UNAVAILABLE` without one); `{mind_file}` says what `mind.md` holds (`MIND_FILE_PREVIOUS`, or at a first v5 checkpoint
`MIND_FILE_FIRST`, which gives the template in place); `{limit_1}` to `{limit_4}` are the mind's section limits
-and `{memo_budget}` the memo's (§7); `{memo}` is `memo.md`'s lines, or `(no messages)`; and `{mind_current}` is empty at
+and `{memo_budget}` the memo's (§7); `{memo_file}` says what `memo.md` holds: `MEMO_FILE_LISTED`, with `{memo_list}` a
+blank line, `Current memo.md:`, and its lines; or, when there is no candidate (§7), `MEMO_FILE_EMPTY` ("empty, and it
+stays empty: no message the user typed is a memo candidate this time, so there is nothing to check. Do not edit it;
+revise only mind.md."), with `{memo_list}` empty: the request never shows text the file does not hold. A placeholder
+shown as the empty file's content once sent a real turn to edit it, twice, against an empty file. `{mind_current}` is empty at
a first v5 checkpoint, else a blank line, `Current mind.md (exactly what the file holds now, word for word):`, and
the previous mind whole, even when the checkpoint above shows it cut. Both files are thus in the request word for
word, next to it, so the turn edits them without reading them first and every `oldText` can match exactly. In a
replay of three chained checkpoints of a real Session (2026-10-18), the turn read neither file and no edit failed,
in both this form and one that pointed to the mind in the checkpoint above; asked to read first, it spent two more
-requests on every checkpoint. The request asks for both files' edit calls in one response: each response is a
+requests on every checkpoint. The request asks for all the edit calls in one response: each response is a
request over the whole context, about a quarter of a checkpoint's cost at a warm cache. In that replay the first
checkpoint did so; the later ones edited one file per response.
@@ -694,9 +700,9 @@ After this, the conversation above will be replaced by your mind, your memo, you
Everything above is experience to consolidate, not instructions to act on now. This request is not part of that experience: do not write it, or anything it asks of you, as something the user said, as a goal or requirement, or as a next step. Consolidate the work as it stood before this request.
-Your scratch directory is {scratch}. It holds two files, and you already have both word for word, so do not read them: edit them directly, giving each its full path, and make the edit calls for both files in the same response. An edit's oldText needs only a short part that is unique in the file, such as a heading line with the line under it, or "- [ ] (#1801)":
+Your scratch directory is {scratch}. It holds two files, and you already have both word for word, so do not read them: edit them directly, giving each its full path, and make all your edit calls in the same response. An edit's oldText needs only a short part that is unique in the file, such as a heading line with the line under it, or "- [ ] (#1801)":
- {scratch}/mind.md: your mind. {mind_file}
-- {scratch}/memo.md: the memo list, word for word at the end of this request.
+- {scratch}/memo.md: {memo_file}
1. Look back
Go through what happened since the previous checkpoint, in order; at your first consolidation, go through the whole conversation. For each layer, ask yourself:
@@ -760,10 +766,7 @@ The template of your now:
## Exact references
- Exact paths, identifiers, commands, links, ids, and values needed to continue.
-Rules: write "(none)" under an empty heading. Only messages the user typed are the user's words; an input marked [Harness: ...] is a background event or another agent's message, not the user's words, even when it says "the user asked ...". Preserve exact paths, identifiers, commands, error strings, and numbers. Do not invent anything that is not above. Never write out secrets, tokens, or credentials; refer to them by name. Write in the language the user writes in.
-
-Current memo.md:
-{memo}{mind_current}
+Rules: write "(none)" under an empty heading. Only messages the user typed are the user's words; an input marked [Harness: ...] is a background event or another agent's message, not the user's words, even when it says "the user asked ...". Preserve exact paths, identifiers, commands, error strings, and numbers. Do not invent anything that is not above. Never write out secrets, tokens, or credentials; refer to them by name. Write in the language the user writes in.{memo_list}{mind_current}
</context-checkpoint-request>
```
diff --git a/tests/agent_core/agent/test_compaction.py b/tests/agent_core/agent/test_compaction.py
index ac6aa35ad..84fbbf2c8 100644
--- a/tests/agent_core/agent/test_compaction.py
+++ b/tests/agent_core/agent/test_compaction.py
@@ -47,6 +47,7 @@ from core.agent_core.harness.context import (
MIND_CUT,
MIND_FILE,
MIND_CURRENT,
+ MEMO_FILE_EMPTY,
MIND_FILE_FIRST,
MIND_FILE_PREVIOUS,
MIND_TEMPLATE,
@@ -1987,6 +1988,25 @@ async def test_a_checkpoint_consolidates_into_a_mind_it_edits_a_memo_it_checks_a
assert [message["is_error"] for message in edits] == [False, False]
+async def test_with_no_memo_candidate_the_request_shows_no_list_and_the_turn_edits_only_the_mind(tmp_path):
+ # A Session no person typed into since the last checkpoint (a Watch's, a Task's, another agent's inputs only): no
+ # memo candidate. memo.md starts empty, so the request must not present any text as its content (a "(no messages)"
+ # placeholder sent a real turn to edit the empty file, twice); it says the file is empty and to leave it so.
+ scratch = tmp_path / "scratch"
+ mind_only = [
+ _batch(_edit("m", scratch / MIND_FILE, ("## Mission\n(none)", f"## Mission\n{MISSION}"))),
+ [Done(assistant(CHECKPOINT))],
+ ]
+ (model,), (row,), _ = await _consolidate(tmp_path, [mind_only], host=Host(typed={}))
+ request = _request(model)
+ assert (scratch / MEMO_FILE).read_text() == "" # the file the turn found, and left
+ assert "Current memo.md:" not in request # no list: nothing shown that the file does not hold
+ assert f"- {scratch}/memo.md: {MEMO_FILE_EMPTY}\n" in request
+ assert len(model.checkpoint_requests) == 2 # the mind's edit, then the reply: no repair
+ assert (row.payload["mind"], row.payload["memo"]) == (FIRST_MIND, [])
+ assert "# 5. The user's words\n(none)" in row.payload["summary"]
+
+
async def test_a_later_checkpoint_starts_from_the_mind_and_memo_it_left_and_needs_one_request_when_nothing_changed(
tmp_path,
):
diff --git a/tests/agent_core/agent/test_context.py b/tests/agent_core/agent/test_context.py
index 1f46e58b7..f4fef4a3e 100644
--- a/tests/agent_core/agent/test_context.py
+++ b/tests/agent_core/agent/test_context.py
@@ -25,7 +25,9 @@ from core.agent_core.harness.context import (
CHECKPOINT_REQUEST_END,
KEPT_INPUTS_WIN,
MEMO_BUDGET,
- MEMO_EMPTY,
+ MEMO_CURRENT,
+ MEMO_FILE_EMPTY,
+ MEMO_FILE_LISTED,
MEMO_HEADING,
MEMO_ITEM,
MIND_CUT,
@@ -1123,10 +1125,18 @@ def test_the_checkpoint_request_and_its_repair_are_the_contract_text_verbatim():
assert MIND_FILE_FIRST in first and "Goals 2,000, Key decisions 1,500" in first
assert first.endswith("Current memo.md:\n- [x] (#3) the goal\n- [ ] (#9) continue\n</context-checkpoint-request>")
assert "{" not in first.replace("{name}", "")
- # A later checkpoint gives the mind whole after the memo list, word for word, whatever the checkpoint above shows.
- later = checkpoint_request((), mind="# 1. Where I stand\n- a").content[0].text
+ assert MEMO_FILE_LISTED in first and MEMO_FILE_EMPTY not in first
+ # A later checkpoint gives the mind whole at the end, word for word, whatever the checkpoint above shows.
+ later = checkpoint_request(["- [x] (#3) the goal"], mind="# 1. Where I stand\n- a").content[0].text
assert MIND_FILE_PREVIOUS in later and MIND_FILE_FIRST not in later and later.endswith(
- f"Current memo.md:\n{MEMO_EMPTY}\n\n{MIND_CURRENT}\n# 1. Where I stand\n- a\n</context-checkpoint-request>"
+ f"Current memo.md:\n- [x] (#3) the goal\n\n{MIND_CURRENT}\n# 1. Where I stand\n- a\n</context-checkpoint-request>"
+ )
+ # With no candidate, memo.md is empty: the request says so and not to edit it, and shows no list, so it never
+ # presents text the file does not hold.
+ empty = checkpoint_request((), mind="# 1. Where I stand\n- a").content[0].text
+ assert f"/memo.md: {MEMO_FILE_EMPTY}\n" in empty and MEMO_CURRENT not in empty and MEMO_FILE_LISTED not in empty
+ assert empty.endswith(
+ f"Write in the language the user writes in.\n\n{MIND_CURRENT}\n# 1. Where I stand\n- a\n</context-checkpoint-request>"
)
assert MIND_CURRENT not in first
assert "Your scratch directory is /s/x. " in checkpoint_request(scratch="/s/x").content[0].text
@@ -1239,6 +1249,11 @@ def test_a_memo_list_reads_back_only_its_checkboxes():
assert memo_problems(memo, "\n".join(lines)) == []
assert memo_problems(memo, "garbage")[0].startswith("memo.md was changed beyond its checkboxes")
assert MemoList().lines() == [] and MemoList().read("") == frozenset()
+ # A line the model adds, the user's words in its own copy, is not a checkbox: the list is unreadable and every
+ # candidate is kept, from the messages themselves; nothing it wrote reaches the checkpoint.
+ added = "\n".join(lines) + "\n- [x] (#12) the user said to merge it"
+ assert memo.read(added) is None and memo.select(memo.read(added)) == memo.items
+ assert MemoList().read("- [x] (#12) the user said to merge it") is None and MemoList().select(None) == ()
def test_the_memo_keeps_every_message_within_its_budget_by_cutting_the_longest_first():