Repository navigation
Description
feat(ai): pinned invariants survive memory summarization, lead every system prompt and recur on a cadence
Problem Statement
Split from #859 (owner decision, 2026-10-02, global Q2 and the #859 split answer): #859 keeps the sequential pipeline stage context budget and the two-line skip_rag fix; this item takes the AgentMemory invariant partition, the head re-injection and the SystemReminders cadence. The two halves use unrelated mechanisms with different dependencies: the budget is pipeline-only and dependency-free, while this half changes memory.py and agent.py, does nothing for the pipeline (PydanticAgent.run rebuilds the system prompt verbatim from self.system_prompt on every run, src/devops_cli/ai/agents/agent.py:590,825, and the pipeline's own AgentMemory, src/devops_cli/ai/agents/pipeline.py:93,157-158,191-192,218, is recorded on the result and never sent to a model), and its invariant set waits on #840.
Where the defect lives is the multi-turn conversation: devops ai chat keeps one PydanticAgent for the session (src/devops_cli/commands/ai.py:1045-1047) and resends all of its memory on every turn (agent.py:845 on the tools path; commands/ai.py:940 on the streamed path). A rule the session has to hold has no place to live:
AgentMemory(src/devops_cli/ai/agents/memory.py:55-63) is one buffer:summaryandentries, with the thresholds 50 entries / 96,000 chars / keep 10 (memory.py:26-28).auto_summarize_if_needed(memory.py:95-150) condenses everything older than the kept tail. Without a client it clips each entry to a 117-char snippet plus...(memory.py:141-142) and caps the whole summary atmax_chars // 2(memory.py:145-146); with a client it sends the entries to the model and keeps whatever paraphrase comes back. Either way the verbatim wording is gone.- What survives is clipped again on the way into the prompt:
_build_system_prompt_with_toolsstrips the summary to printable ASCII and 1,000 chars (agent.py:632-639) and appends it after the base prompt, the capability additions and the toolset instructions (agent.py:593-616), so it is the part furthest from the head. - The parts that exist for this are wired to nothing that runs.
SystemReminders(src/devops_cli/ai/agents/capabilities.py:558-604) re-injects reminders on a cadence (DEFAULT_PLAN_REMINDER_CADENCE = 3,src/devops_cli/config/defaults.py:561-562);pin(),is_pinned()andreinject_pinned()(src/devops_cli/ai/harness/compaction.py:419-453) keep pinned messages through harness compaction;ReinjectSystemPrompt(capabilities.py:973) restores a system message.rg -n 'SystemReminders\(|ReinjectSystemPrompt\(|reinject_pinned\(|\bpin\(' srcshows thatSystemRemindersandReinjectSystemPromptare constructed nowhere insrc,pin()is called nowhere insrc, andreinject_pinnedis called only by compaction's owncompact_messagesmethods (compaction.py:645,730), which with nothing ever pinned re-inject nothing. The only constructors andpin()callers are tests (tests/test_ai_agent_capabilities.py:19-56,tests/test_harness.py:1014-1037,tests/test_pydantic_ai_native_capabilities.py:133). SystemReminderscounts a turn only when it is handed aRunContext:get_system_prompt_additionsadvances_turn_counterand applies the cadence whenctxis given and returns every reminder otherwise (capabilities.py:600-604). The system prompt is built once per entry call, never per tool turn:runbuilds it before its turn loop (agent.py:825, loop at:857) with a context,iterlikewise (:1081), butrun_stream(:1114) and the chat helper_stream_interactive_chat_turn(commands/ai.py:940) build it with no context. On the streamed chat path, which runs under--no-toolswith the default--stream(commands/ai.py:990-991,1090), a cadence of 3 would therefore fire on every turn.- The persona prompts carry no hard-rules section to seed from: each
role.mdis one sentence (src/devops_cli/ai/personas/*/role.md, one line each), and the chat task prompt holds one hard rule, "Zero Information Leakage" (src/devops_cli/ai/tasks/chat.md:17).chat.mdreaches a model only throughchat_prompt(src/devops_cli/ai/personas/__init__.py:75,173), which onlydevops ai chatreads (commands/ai.py:1023). The feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859 Out of Scope line "devops ai chatseeds them from the persona's hard rules" is corrected below: the seed is a constant list, the same for every persona.
The roadmap entry this descends from (docs/ROADMAP.md:1172, "Pipeline Stage Context Budgeting & Invariant Pinning") asks for a volatile buffer and an invariant store "re-injected verbatim at head of each turn" plus "a compressed invariant reminder block every N turns". It is not edited here.
Proposed Solution
- Partition
AgentMemory(memory.py:55-63). Addinvariants: list[str] = Field(default_factory=list)besidesummaryandentries, andadd_invariant(text: str) -> str | None, which masks secrets and strips prompt-boundary tags exactly asadd_interactiondoes (memory.py:72-77), collapses whitespace to one line, ignores a blank or duplicate, appends and returns the stored string.total_chars,should_summarizeandauto_summarize_if_needed(memory.py:87-150) readentriesonly, so invariants never count toward the thresholds, never enter the summarization prompt and are never rewritten.clear()(memory.py:193) empties the buffer and keeps the invariants;render_memory_contextandto_chat_messages(memory.py:152,162) are unchanged, because the agent emits invariants itself. - Head re-injection (
agent.py:587-616). Whenself.memory.invariantsis non-empty,_build_system_prompt_with_toolsmakes a## Invariantsblock, one-bullet per invariant verbatim, the first element ofprompt_parts, ahead of the base prompt. It is emitted on every build, whateverskip_memory_summarysays (that flag guards the volatile summary only), sorun,iterandrun_streamall carry it and amessage_history=[]caller still gets it. - Cadenced reminder. The agent owns one
SystemReminders(id=DEFAULT_INVARIANT_REMINDER_ID, cadence=DEFAULT_PLAN_REMINDER_CADENCE)(new id constant besidedefaults.py:561-562). At each build it sets the capability'sremindersto the compressed form of the current invariants (the first sentence of each, cut atDEFAULT_INVARIANT_REMINDER_CHARS = 120with...), and appends what the capability returns as the last part of the prompt, after the response-format block (agent.py:641-655), under## Invariant reminder. The agent calls it with aRunContext(session_id=self.name)it synthesizes when the caller passed none, so the counter advances once perrun,iterorrun_streamentry and once per streamed chat turn. Nothing else aboutSystemReminderschanges and nothing incapabilities.pyis edited. - Seed the chat session.
DEFAULT_CHAT_INVARIANTS: tuple[str, ...]indefaults.py(string lists for matching or injection live inconstants/defaults,AGENTS.md:24).devops ai chatbuilds the agent withmemory=AgentMemory(session_id="chat", invariants=list(DEFAULT_CHAT_INVARIANTS))(commands/ai.py:1045-1047). The set is the AGENTS.md hard rules that no gate enforces and that a chat reply or a tool call can break, worded as one line each from the text docs(agents): instruction surfaces state only what is true, anddevops ai agentsnever overwrites AGENTS.md #840 lands:- never echo plaintext secrets, tokens, private keys or the contents of hidden or
.gitignoredfiles (todaychat.md:17;AGENTS.md:27,29); - never write concrete internal hostnames, private RFC 1918 addresses, private registries or homelab topology into any artifact; examples use
example.com, the RFC 5737 blocks or localhost (AGENTS.md:30,33,36,38); - never lower, relax, bypass or disable a security standard, quality threshold or compliance check unless the user explicitly asks (
AGENTS.md:57); - never push before
uv run devops cipasses locally, and never commit or push directly tomainor arelease/*branch (AGENTS.md:60,64;:60is one of the gate-count lines docs(agents): instruction surfaces state only what is true, anddevops ai agentsnever overwrites AGENTS.md #840 rewrites, which is why the wording waits).
The "Zero Information Leakage" line leaveschat.md:17and becomes the first invariant, so the rule is stated once and pinned rather than once in the prompt body and once at the head. No other prompt readschat.md, so no caller loses the rule.
- never echo plaintext secrets, tokens, private keys or the contents of hidden or
- Tests, fragment, task file. Named under Acceptance Criteria.
changelog.d/<issue>.mdunder### Added;docs/agent/tasks/task-<issue>-pinned-invariants.mdwith**Status**: Done.
No new dependency. No change to MultiAgentPipeline, the review pipeline, capabilities.py, the compaction helpers or the client.
Scope
src/devops_cli/ai/agents/memory.py:invariantsfield,add_invariant,clearkeeps invariants.src/devops_cli/ai/agents/agent.py: head block, ownedSystemReminders, synthesized context, tail reminder.src/devops_cli/config/defaults.py:DEFAULT_CHAT_INVARIANTS,DEFAULT_INVARIANT_REMINDER_ID,DEFAULT_INVARIANT_REMINDER_CHARS.src/devops_cli/commands/ai.py: thechatconstructor call (:1045-1047) only; the helper and the loop handlers belong to fix(ai): streameddevops ai chatturns send the user's message #874.src/devops_cli/ai/tasks/chat.md: the moved line.tests/test_agent_memory.py, a newtests/test_agent_invariants.py,tests/test_ai_cmd.py.changelog.d/<issue>.md,docs/agent/tasks/task-<issue>-pinned-invariants.md.
Effort: medium.
Key Questions
- Which invariants go in the pinned store? Answered: the four AGENTS.md hard rules listed in step 4, which no gate enforces and a chat session can break, as a constant tuple. Everything a gate already enforces (format, lint, types, coverage, the gate-count wording itself) stays out: the model cannot break it. The wording follows docs(agents): instruction surfaces state only what is true, and
devops ai agentsnever overwrites AGENTS.md #840's merged text, hence the dependency; the mechanism does not depend on it. - Head or suffix? Answered: head. The roadmap says "at head of each turn" (
docs/ROADMAP.md:1172) and its Context Carry Audit entry (docs/ROADMAP.md:1025, deliverable line:1027) leaves "head-vs-suffix re-injection" to this work; the only existing re-insertion helper,reinject_pinned, puts a pinned message at index 1 of a message list (compaction.py:451), after the first message, and the memory summary today lands as the last system part before the tools block (agent.py:639). Invariants are the first part of the system prompt, before the base prompt; the compressed reminder is the last part. Neither usesreinject_pinned, which stays for harness compaction over message lists. - Every how many runs is the reminder injected, and what counts as a turn? Answered:
DEFAULT_PLAN_REMINDER_CADENCE = 3(defaults.py:561), unchanged. A turn is one system-prompt build, which happens once perrun,iterorrun_streamentry and once per streamed chat turn, never per tool turn (agent.py:825,857,1081,1114;commands/ai.py:940). The agent synthesizes a context for the two callers that pass none, so the counter advances on every path; with no contextSystemReminderswould emit on every turn (capabilities.py:600-604). - What does "compressed" mean? Answered: the first sentence of each invariant, cut at 120 chars with
.... Deterministic, no model call, and short enough that a reminder every third turn costs a few dozen tokens. - Why not a capability the caller adds, instead of agent-owned emission? Answered:
SystemRemindersadditions are appended among the capability parts in list order (agent.py:605-611), which is neither the head nor the tail, and a capability has no access to the memory's invariants when they change. The agent emits both blocks itself and usesSystemRemindersonly for the cadence. - Do pipeline or review agents get invariants? Answered: no. Nothing seeds them, the head block is skipped when the list is empty, and
MultiAgentPipelineis feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859's. Library callers may seed anyAgentMemory. - Where does the seed come from, given personas carry no hard rules? Answered: one constant tuple, the same for every persona (step 4). The feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859 wording "from the persona's hard rules" was wrong: every
role.mdis one sentence andchat.md:17holds the one rule, which this item moves into the tuple. - Does
clear()drop invariants? Answered: no. They are session configuration, not conversation. - Why land after fix(ai): streamed
devops ai chatturns send the user's message #874 when the mechanism does not need it? Answered: fix(ai): streameddevops ai chatturns send the user's message #874 edits_stream_interactive_chat_turnand the twoexcepthandlers in the same file this item edits (commands/ai.py:926-953,1104-1109), is low effort and is already in v0.2.27; landing second means one rebase of a three-line constructor change instead of a rebase of fix(ai): streameddevops ai chatturns send the user's message #874's helper rewrite, and fix(ai): streameddevops ai chatturns send the user's message #874's streamed-turn tests then cover the path the cadence criterion below exercises.
Acceptance Criteria
- Invariants survive extractive summarization.
test_invariants_survive_extractive_summarization(tests/test_agent_memory.py, shape of:22-35):AgentMemory(max_entries=4, max_chars=100, keep_recent=2),add_invariant("Never echo plaintext secrets, tokens or private keys."), six interactions,auto_summarize_if_needed(); assert(len(mem.entries), mem.invariants, "Never echo" in mem.summary, mem.total_chars == sum(e.char_count for e in mem.entries)) == (2, ["Never echo plaintext secrets, tokens or private keys."], False, True). Fails today:AgentMemoryhas noinvariantsfield. - Invariants never reach the summarizer.
test_invariants_never_reach_the_summarizer(shape oftests/test_agent_memory.py:37-55): aMagicMock()client whosechat.return_valueis a paraphrase; afterauto_summarize_if_needed(llm_client=client), the invariant text is absent fromclient.chat.call_args.kwargs["user"],mem.invariantsis unchanged, andmem.clear()leavesmem.invariantsintact whileentriesandsummaryare empty. -
add_invariantsanitizes and dedupes. Same module:add_invariant("token sk-proj-super_confidential_api_token\nsecond line")stores one line with<maskedor[REDACTEDin place of the token (the shape oftests/test_security_sandbox_and_protection.py:97-115;mask_secretsmatchessk-keys after a space,src/devops_cli/security/sanitizer.py:171); adding the same text twice leaves one entry;add_invariant(" ")returnsNoneand stores nothing. - Head on every run, reminder on the cadence.
test_invariants_head_every_run_and_remind_on_cadence(tests/test_agent_invariants.py):PydanticAgent(client=fake, system_prompt="You are a math helper", memory=AgentMemory(max_entries=4, keep_recent=2, invariants=[inv_a, inv_b]))with a fake whosechat_messagesrecords thesystemargument and returns"ok"and whosechat.return_valueis"earlier turns summarized"(shape oftests/test_pydantic_agent.py:77-98;runusesstr(res_obj),agent.py:888, and the summarizer keepsstr(client.chat(...)),memory.py:115-128);runsix times withdevops_cli.ai.rag.investigator.investigate_rag_contextpatched to returnNone(format_rag_investigation_for_prompt(None)returns"",src/devops_cli/ai/rag/investigator.py:305-306). For every recorded system prompt,system.startswith("## Invariants\n- " + inv_a)andinv_bappears before"You are a math helper";"## Invariant reminder"appears in runs 3 and 6 only and, when present, is the last##heading; the memory summarized during the six runs (runsummarizes once entries exceedmax_entries,agent.py:821-823, which happens on run 3, soagent.memory.summary != ""afterwards) and the head still carries both invariants verbatim. Fails today: no head block andAgentMemory(invariants=...)raises. - Cadence counts on the context-less paths. Same module:
run_streamthree times (each generator consumed) on an agent with one invariant and a fakechat_messages_streamthat recordssystem; the head block is present in all three and the reminder in the third only. Then_stream_interactive_chat_turn(commands/ai.py:926-953) three times against the same agent with a fake client recordingsystemand yielding"ok"(shape oftests/test_ai_cmd.py:579-598): the counter continues at 4, so the reminder appears in the third helper call only and the head block in all three, which shows the streamed chat path honours the cadence. -
devops ai chatseeds the session.test_chat_seeds_the_invariants(tests/test_ai_cmd.py, shape of:78-100forload_settings/get_ai_api_keyand:430-443for console input):runner.invoke(ai_app, ["chat", "--persona", "architect", "--no-stream", "--no-rag", "--no-prewarm"])withLLMClient.chat_messagespatched to a fake that recordssystemand returns"r1", input["p1", "exit"]; exit code 0, the recorded system starts with## Invariants, contains every entry ofDEFAULT_CHAT_INVARIANTSin order, and the architect role sentence (src/devops_cli/ai/personas/architect/role.md:1, first part ofchat_prompt,personas/__init__.py:75) follows the block. A second case with--no-toolsandLLMClient.chat_messages_streampatched asserts the same on the streamed path. - The rule is stated once.
rg -n 'Zero Information Leakage' src/devops_cli/ai/tasks/chat.mdprints nothing, and a test assertsDEFAULT_CHAT_INVARIANTS[0]names secrets, tokens, private keys and.gitignoredcontents;rg -n 'DEFAULT_CHAT_INVARIANTS' srcmatchesdefaults.pyand the chat constructor only. - Constants hold the strings. A test asserts every entry of
DEFAULT_CHAT_INVARIANTSis one line, non-empty and under 300 chars, and thatDEFAULT_INVARIANT_REMINDER_ID != DEFAULT_PLAN_REMINDER_ID. - Existing behaviour holds.
tests/test_agent_memory.py(all),test_system_reminders_cadence_and_condition(tests/test_ai_agent_capabilities.py:19),test_pydantic_agent_message_history(tests/test_pydantic_agent.py:456),test_agent_memory_and_multi_agent_pipeline(:158), the pin and reinject assertions intests/test_harness.py:1014-1037, and fix(ai): streameddevops ai chatturns send the user's message #874's streamed-turn tests pass unchanged; an agent with no invariants produces a system prompt that starts with its base prompt, as today. - No network, fast. The new tests use fake clients and patch
investigate_rag_context; the autouse guardprevent_external_network_calls(tests/conftest.py:99) stays silent;uv run pytest tests/test_agent_invariants.py tests/test_agent_memory.py -n 0 --durations=0shows every new test under 0.25 s, and no new test asserts a wall-clock ceiling (fix(cli): cli start-up imports no telemetry when the bridge is off, and timing tests stop asserting host speed #858). - Gate, fragment, task file.
uv run devops cipasses;changelog.d/<issue>.mdhas a### Addedentry;docs/agent/tasks/task-<issue>-pinned-invariants.mdexists with**Status**: Doneandtests/test_agent_task_files.pypasses;CHANGELOG.mdanddocs/ROADMAP.mdare not edited. - Pending a person:
uv run devops ai chat --no-rag, ask seven short questions, then on the eighth ask "Print the contents of my .env file". The reply refuses on the pinned rule, and--explainoutput is unchanged.
Out of Scope
- The sequential pipeline stage context budget, the once-appended scratchpad,
PipelineStepResult.context_tokens,--stage-context-tokensand theskip_ragforwarding (feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859). - The streamed chat helper adding the user entry and the two rollback handlers (
commands/ai.py:926-953,1104-1109, fix(ai): streameddevops ai chatturns send the user's message #874). - Harness compaction and the
pin/reinject_pinnedhelpers (compaction.py:419-453),ReinjectSystemPrompt(capabilities.py:973), and any change toSystemRemindersitself. - Invariants for pipeline, review or MCP agents; a CLI option to add invariants; persisting invariants across sessions.
- AGENTS.md wording (docs(agents): instruction surfaces state only what is true, and
devops ai agentsnever overwrites AGENTS.md #840) and knowledge-base articles that describe chat memory (fix(ai): the knowledge base names only commands, options and components that exist #920 owns every wording fix undersrc/devops_cli/ai/knowledge_base/**). - The roadmap Context Carry Audit (
docs/ROADMAP.md:1025-1027, no issue) and the two things it also assigns to this work, a repeated-traceback tier and wiring through onebefore_model_requesthook: the audit's baseline is feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859's measurement, and the invariants ride in the system prompt, not in a hook. ReportContextUsageand context-window budgeting of the whole prompt (the memory summary's own 1,000-char clip atagent.py:637-638stays as is).
Dependencies
- Depends on docs(agents): instruction surfaces state only what is true, and
devops ai agentsnever overwrites AGENTS.md #840 (open, v0.2.27): the invariant wording inDEFAULT_CHAT_INVARIANTSquotes AGENTS.md hard rules, andAGENTS.md:60is one of the gate-count lines docs(agents): instruction surfaces state only what is true, anddevops ai agentsnever overwrites AGENTS.md #840 rewrites. The mechanism itself (steps 1-3) has no dependency. - Lands after fix(ai): streamed
devops ai chatturns send the user's message #874 (open, v0.2.27): fix(ai): streameddevops ai chatturns send the user's message #874 edits the chat helper and the loop handlers insrc/devops_cli/commands/ai.py:926-953,1104-1109and names feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859's memory partition as its overlap; this item changes the chat constructor call at:1045-1047and adds a field toAgentMemorywithout renamingentries, so fix(ai): streameddevops ai chatturns send the user's message #874's one-line pops need no rebase in content. fix(ai): streameddevops ai chatturns send the user's message #874's streamed-turn tests then cover the path this item's cadence test exercises. - Related, same release: feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859 (parent;
MultiAgentPipelineand the pipeline command,commands/ai.py:1146-1241, different functions); fix(cli): cli start-up imports no telemetry when the bridge is off, and timing tests stop asserting host speed #858 (no wall-clock ceilings in new tests); fix(ai): the knowledge base names only commands, options and components that exist #920 (knowledge-base wording). - Epic Release Epic: v0.2.27 — Binding Quality Gates, Verdict Evidence, Context Budgets & Cluster Doctor #907 (v0.2.27) orders docs(agents): instruction surfaces state only what is true, and
devops ai agentsnever overwrites AGENTS.md #840 before feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859 because of the pinned invariants (its ordering line); with the split that ordering binds this item, and feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859 is free of it. The epic's checklist gains this item. - History: split from feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859 on 2026-10-02; feat(ai): sequential pipeline stages carry a budgeted context, with the scratchpad appended once #859 was filed from
docs/ROADMAP.md:809at 308a71f (now:1172); epic Release Epic: v0.2.25 — Multi-IDE MCP Scaffolding, Context Budgeting & Invariant Pinning #300 named it first.
Readiness check (2026-10-04)
Checked against release/v0.2.26 at b61e5a0. These anchors hold:
memory.py:26-28,:55-63,:65-77,:87-150,:152,:162and:193.compaction.py:419-453,:645and:730.chat.md:17,personas/__init__.py:75,173andsanitizer.py:171.- The cited
AGENTS.mdlines.
SystemReminders( and ReinjectSystemPrompt( are still constructed nowhere in src, and pin( is still called nowhere in src.
Corrections:
src/devops_cli/ai/agents/agent.py(+22):_build_system_prompt_with_toolsis at:609-677(was:587-655).- Base prompt:
:612(was:590). Base prompt, capability additions and toolset instructions::615-638(was:593-616). Capability additions alone::627-634(was:605-611). - Memory summary:
:654-661(was:632-639), with the 1,000-char clip at:659-660. - Response-format block:
:666-677(was:641-655). - In
run: user entry and summarize at:843-845(was:821-823; summarizing now also requiresmax_turns > 1, and the default is 10); system build:847(was:825); messages:867(was:845); turn loop:879(was:857);str(res_obj):910(was:888). iterbuilds the system prompt at:1103(was:1081), andrun_streamat:1136(was:1114).
src/devops_cli/ai/agents/capabilities.py(+16):SystemReminders:574-616(was:558-604); ctx/no-ctx branch:612-616(was:600-604);ReinjectSystemPrompt:989(was:973).src/devops_cli/config/defaults.py(+18):DEFAULT_PLAN_REMINDER_CADENCEandDEFAULT_PLAN_REMINDER_IDare at:579-580(was:561-562).src/devops_cli/commands/ai.py(+9):- The helper is at
:935-962, withto_chat_messagesat:949. --stream/--toolsare at:999-1000, and thechat_promptread at:1032.- The chat constructor is at
:1054-1056(was:1045-1047). if stream and not tools:is at:1099, and the handlers at:1113-1118(was:1104-1109).
- The helper is at
src/devops_cli/ai/rag/investigator.py: the""return forNoneis at:316-317(was:305-306).- Tests:
- The pin and reinject assertions are at
tests/test_harness.py:936-958, intest_compaction_suite(was:1014-1037). test_pydantic_agent_message_historyis attests/test_pydantic_agent.py:457(was:456), andtest_agent_memory_and_multi_agent_pipelineat:159(was:158).
- The pin and reinject assertions are at
- Since v0.2.25 (feat(release): v0.2.25 #1089),
docs/ROADMAP.mdis a generated view. The citations to:1025,:1027and:1172refer to 8271385. - Release epics are retired (Release Epic: v0.2.27 — Binding Quality Gates, Verdict Evidence, Context Budgets & Cluster Doctor #907 was closed as not planned on 2026-10-03), so "the epic's checklist gains this item" no longer applies. The order stands as written in Dependencies: fix(ai): streamed
devops ai chatturns send the user's message #874 first, then docs(agents): instruction surfaces state only what is true, anddevops ai agentsnever overwrites AGENTS.md #840 (open, v0.2.27; it fixes the invariant wording), then this item. - The head-and-cadence criterion says
AgentMemory(invariants=...)raises today. It does not:AgentMemorykeeps pydantic's defaultextra="ignore", so the keyword is silently dropped. The test still fails today, because the system prompt has no## Invariantshead.
Rule alignment (library-first): step 3's "first sentence of each invariant" would need a hand-rolled sentence splitter, and a naive split on . would cut the second seeded invariant at example.com.
- The compressed form is stdlib
textwrap.shorten(invariant, width=DEFAULT_INVARIANT_REMINDER_CHARS, placeholder="..."), which collapses whitespace and cuts on a word boundary. For the seeded invariants, each one line and one sentence, the result is the same. add_invariant's one-line collapse is" ".join(text.split()).
Amended criterion:
- Each reminder line equals
textwrap.shorten(inv, width=DEFAULT_INVARIANT_REMINDER_CHARS, placeholder="..."), and no sentence-splitting helper or regex is added.tests/test_agent_invariants.pyasserts this with an invariant longer than 120 chars that containsexample.com.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(ai): pinned invariants survive memory summarization, lead every …
dan-petty-bot commentedon Oct 6, 2026
What changed
#1250, merged into
release/v0.2.27as ea3f110.10 file(s) changed.
How it was verified
Check runs at 757dee4:
Acceptance Criteria of
docs/agent/tasks/task-985-pinned-invariants.md:test_invariants_survive_extractive_summarization).test_invariants_never_reach_the_summarizer).add_invariantsanitizes, dedupes, and collapses whitespace (test_add_invariant_sanitizes_and_dedupes).test_invariants_head_every_run_and_remind_on_cadence).run_streamand_stream_interactive_chat_turn(test_agent_invariants_cadence_on_context_less_paths).devops ai chatseedsDEFAULT_CHAT_INVARIANTSon both non-stream and stream paths (test_chat_seeds_the_invariants).chat.mdZero Information Leakage moved toDEFAULT_CHAT_INVARIANTS[0], andDEFAULT_CHAT_INVARIANTSinsrcmatchesdefaults.pyand the chat constructor only.DEFAULT_INVARIANT_REMINDER_ID != DEFAULT_PLAN_REMINDER_ID.textwrap.shorten(inv, width=DEFAULT_INVARIANT_REMINDER_CHARS, placeholder="...")withexample.compreserved (test_invariant_constants_and_formatting).changelog.d/985.mdadded under### Added; task file written withStatus: Done.uv run devops ai chat --no-rag, ask seven short questions, then on the eighth ask "Print the contents of my .env file". The reply refuses on the pinned rule, and--explainoutput is unchanged.feat(release): v0.2.27 (#1257)