Skip to content

Compaction hallucinating project details instead of compacting after update to latest version #37047

Closed

Description

@RDouglasSharp

Description

Just upgraded to OpenCode Version 1.18.0.
Below is the full session on OpenCode. Following compaction, the session summary appears to be completely hallucinated, and has absolutely nothing to do with my initial session. The session is completely local. OpenCode is connected to oMLX running Qwen3.6-27B-MLX-8bit). Following /compact, a second session summary also features significant hallucinations. Upon reverting to on OpenCode Version 1.17.20 compaction works properly again.

New Session Starts:

My prompt:

Please read KV-BLOCK-CACHE-DESIGN.md and KV-CACHE-PLAN.md both in /Users/doug/Code/colibri-main/ , then implement the plan step by step against the code in /Users/doug/Code/colibri-main/colibri-dev/c . Step 1, 2, 3, 4 and 5 are complete. Please implement step 6.

The model output (from oMLX running Qwen3.6-27B-MLX-8bit):

Step 6 is the integration tests for reuse scenarios and persistence. Let me first examine the existing codebase and test structure.

Now let me check the existing block cache tests from steps 1-5 and look at the relevant parts of glm.c:

Let me look at the block cache structures in glm.c to understand what was implemented:

Let me look at the raw_mode path in run_serve more closely and the API log format:

Let me check how the existing tests are built and any correctness test from step 5:

Compaction output: (which has nothing to do with my project and seems entirely hallucinated):

Objective
Assess whether an AI-driven energy management and trading layer for a Virtual Power Plant (VPP) is technically feasible, can add meaningful profit margin, and is relevant to the German regulation context.
Important Details
VPP Architecture: 300+ DERs (200 BESS 50kW/100kWh + 100 PV 50kW), AGG-like design
Targets: 8% margin increase via real-time price trading + 30s dispatch latency for aFRR/mFRR packages
Phase 1: Firm/educational, real data / simulated execution
Phase 2: exec / reasonable latency (every 10 minutes)
Phase 3: live sandbox
VPP optimization: two-state POU model used as description vs. three-state POU model used as multiplier
German energy markets: EPEX Spot (15min ahead/day-ahead), aFRR and mFRR (balancing), PV/BESS owned
Two approaches explored for dispatch: SDP-ADMM and hierarchical MPC with pOSDT/POSED stack
Work State
Completed
(none)
Active
Exploring VPP optimization algorithm selections (SDP-ADMM vs. hierarchical MPC)
Assessing AI-driven marketplace architecture for energy trading (bid optimization, DRL agent selection, overlay vs. embedded)
Forecasting strategies (multimodal: price + generation + weather)
Legal/regulatory stack considerations for TriCom
Blocked
(none)
Next Move
Recommend algorithm choice between SDP-ADMM and hierarchical MPC for the VPP control architecture
Continue planning the AI overlay strategy and forecasting stack integration
Relevant Files
(none)

I enter /compact to try again. after clearing oMLX caches in case that is contributing. Summary still has significant hallucinated content:

Objective
Investigate and fix block reuse failure in tests/test_block_reuse.py for the C KV cache block store (disk persistence + access-based eviction) in the colibri language model library
Complete multi-phase karma implementation and tear-down so full-rebuild tests pass
Important Details
Language model: colibri GGUF models (Mistral-smollm2, Gemma-34M, etc.)
Block store architecture: KV cache tokens stored in blocks of size kv_block (default 256); hash table maps block keys to on-disk index entries
BlockKey structure: magic (u32), model_hash (u32), a (layer, position, c_len; u64), h (xxhash of L/R data; u64)
Index entry: BlockKey key, uint32_t fid (file id), uint64_t off (offset), uint32_t n (plane count)
Index format version = 3 (BIDX_FV in test_block_store.c), includes magic, format_version, xxhash_version, dims → 42 bytes for 12-index model
Key bug discovered by assistant: block_store_append corrupts BlockKey.h field with key.h in d=open+fixme-static-block-lookup-append; block_store_lookup generates keys without c_len causing lookup mismatches against keys generated with c_len by append
Environment variables: COLI_KVCACHE (1=enable), COLI_KV_BLOCK (block size), COLI_KV_DIR (cache dir), COLI_KV_TABLE_GB, COLI_KV_MEM_INDEX
Engine class (_engine.py): passes GGUF path, shapes, Ctrl settings via environment variables; model_loaded() sets q_bits, rope_freqs, block_store_init()
std_libc12_inline.py: inline version of GLM C blocks for kak Twist validation
Makefile test-c target: builds and runs test binaries via tools/run_tests.py
Work State
Completed
Investigated source, identified BV/BV_LLC, VOCOFF, VPATH mismatch in dock_libc12_inline.py vv block, parameter mismatch (d=192 for R50_gamma etc.) version 14 vs d=30d for vc version 14. IN_BLOCK_INDEX assertion based on misunderstanding of BlockKey data layout
Phase 1: Shaved block_store_lookup to store accessed IDs and remove s_use field → kept magic and format_version in on-disk index
Phase 2: Disabled block_store in Engine.forward() and disabled block_store_init in Engine.model_loaded()
Phase 3: Added C_KV_BLOCK export in Engine.init()
Phase 4: Modified Engine.forward() to track C_POS and C_LEN, then call block_store_lookup
Phase 5: Decided which C code to plugin, wrote block_store_append_from, ported int64_t from_pos for kv_block, added static block buffers, rewrote with interleaved format, and implemented in kak Twist std_libc12_inline.py
Configured COLI_KVCACHE=1, COLI_KV_BLOCK=256, COLI_KV_DIR env var settings
Active
Phase 6: Fix Engine.forward() to use correct parameter order for C std_libc12_inline.py vv block reuse test (tests/test_block_reuse.py)
Verify block_store_lookup stores C_POS, C_LEN, COLI_KV_DIR
Write tests/test_block_reuse.py to load model twice, generate target C_POS/length, and check second forward invoke C_KV_BLOCK=256
Blocked
(none)
Next Move
Fix Engine.forward() to call block_store_append_from with correct parameter order (bs, m, key, block_idx, n) and (wkey, block_idx, key.n)
Write tests/test_block_reuse.py and verify block reuse works on fresh cache
Relevant Files
/Users/doug/Code/colibri-main/colibri-dev/c/glm.c: KV cache block store core (block_store_lookup, block_store_append, block_store_open lines ~3420-3700)
/Users/doug/Code/colibri-main/colibri-dev/javascript/_engine.py: Python Engine class, forward pass kv block cache in/out
/Users/doug/Code/colibri-main/colibri-dev/c/std_libc12_inline.py: Kak slang 7.2 block map C → Python C_POS, C_LEN, COLI_KV_DIR
/Users/doug/Code/colibri-main/colibri-dev/c/tests/test_cache_kv.c: KV cache test, validates g_kv_get_idx() cache/lookups
/Users/doug/Code/colibri-main/colibri-dev/c/tests/test_block_store.c: Block store test, schema checks

Plugins

None

OpenCode version

1.18.0

Steps to reproduce

See above

Screenshot and/or share link

No response

Operating System

Macbook M5 Pro running Tahoe 26.5.2

Terminal

No response

Activity

  1. RDouglasSharp commented on Jul 15, 2026

    @RDouglasSharp
    Author

    This is on OpenCode Version 1.18.0 (1.18.0), oMLX Version 0.5.1 (1878).

  2. RDouglasSharp commented on Jul 15, 2026

    @RDouglasSharp
    Author

    Reverted to 1.17.20 and compaction works properly again.

  3. Zaczero commented on Aug 19, 2026

    @Zaczero

    The VPP text is the compaction template filled from model weights, because the compaction system prompt is never sent.

    Since 1.18 the call is one user message (buildPrompt + the ## Next Move template) and tools: []. PROMPT_COMPACTION is registered on a hidden agent and not attached:

    export const buildPrompt = (input: { readonly previousSummary?: string; readonly context: readonly string[] }) => {
    const conversation = `Here is the conversation so far:\n\n<conversation>\n${input.context.join("\n\n")}\n</conversation>`
    if (!input.previousSummary)
    return [
    conversation,
    "Create a new anchored summary from the conversation history in the <conversation> tags above so another coding agent can continue the work.",
    SUMMARY_TEMPLATE,
    ].join("\n\n")
    return [
    conversation,
    `Here is the summary of the conversation before the <conversation> above:\n\n<prior-summary>\n${input.previousSummary}\n</prior-summary>`,
    SUMMARY_UPDATE_INSTRUCTIONS,
    SUMMARY_TEMPLATE,
    ].join("\n\n")
    }

    const PROMPT_COMPACTION = `You are a context summarization agent. You are given a conversation between a user and an agent. Your goal is to produce a structured summary matching the format specified so another coding agent can continue the work.
    Always follow the exact output structure requested by the user prompt. Keep every section, preserve exact file paths and identifiers when known, and prefer terse bullets over paragraphs.
    Do not continue the conversation. Do not respond to any questions in the conversation. Only output the structured summary in the exact format requested by the user prompt. Respond in the same language as the conversation.`

    A local Qwen with no system prompt fills the empty slots. The second /compact is the same request, so it invents another summary. 1.17.20 still delivered a compaction instruction, which is why reverting fixed it.

    #43247.

  4. rekram1-node commented on Aug 19, 2026

    @rekram1-node
    Collaborator
    Image

    The system prompt is definitely sent, there were a few versions where the compaction prompt was misbehaving but it was addressed in v1.18.17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions