Skip to content

nullgate/conjure-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opencode-conjure

Patch set for opencode that improves compaction (context window management) for long-running agentic sessions.

Base: opencode v1.1.65

Developed from xxfork, an earlier experimental fork where the core compaction algorithms were prototyped. This patch set is a clean rebase of those changes onto upstream opencode.

What it does

  • Anchor-based compaction — three-segment split (prelude/interlude/temporal) instead of summarizing everything
  • Watermark calibration — uses real API token counts to correct estimation drift
  • Improved filterCompacted — marker-based matching prevents splice errors on repeated compaction
  • Tool message sanitization + consecutive role merging for Anthropic API compatibility
  • LLM debug dump, usage tracking, snapshot capture (instrumentation)

Requirements

  • Linux x86-64
  • bun >= 1.3.8
  • git

Build

./build.sh

From a local clone (faster, no GitHub access needed):

./build.sh --local /path/to/opencode

Clean rebuild:

./build.sh --clean

Binary output: build/opencode/packages/opencode/dist/opencode-linux-x64/bin/opencode

Patches

# Description
0001 B-class: flag env vars, watermark calibration, budget constraint, systemEstimate
0002 C-class: LLM debug dump, snapshot capture, maxOutputTokensOverride
0003 A-class: limit.input merge, OUTPUT_TOKEN_MAX 64K, anchor-based compaction, filterCompacted rewrite
0004 Fix: restore LLM dump enhancement after rebase
0005 Refactor: move watermark.json to .opencode/ephemeral/
0006 Fix: calldump-role-violation only writes when COMPACTION_DEBUG_DIR is set

Environment variables

Variable Description
OPENCODE_COMPACTION_DEBUG_DIR Compaction debug output directory
OPENCODE_LLM_DEBUG_DIR LLM request/response dump directory
OPENCODE_USAGE_LOG Usage JSONL log path (default: .opencode/ephemeral/usage.jsonl)
OPENCODE_SNAPSHOT_DIR Message snapshot output directory
OPENCODE_SESSION_TOKEN_BUDGET Effective token budget per session
OPENCODE_COMPACTION_RECALL_PROMPT Custom compaction recall prompt
OPENCODE_COMPACTION_CONTINUE_PROMPT Custom compaction continue prompt

Demo

conjure-demo/ is a self-contained project that uses the patched binary to analyze its own patches. It includes:

  • AGENT.md — instructions for the analysis task
  • conjure.sh — launcher script
  • .opencode/plugins/conjure.ts — lightweight plugin (situational motif + compaction stats)
  • /bootstrap command to start the analysis
./build.sh
cd conjure-demo
./conjure.sh
# then type: /bootstrap

The conjure.ts plugin injects a <context> tag into each LLM call with current time, session stats, and context usage percentage. After compaction, it logs the context reduction details.

Tested with opencode zen mode + Kimi (free tier). See conjure-demo/test/ for sample output.

License

Same as upstream opencode (MIT).

About

a simple proof of concept for opencode workflow

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors