Skip to content

Enforce a configurable rolling image window before model requests - #1

Merged
darkmatter2222 merged 2 commits into
mainfrom
feature/rolling-image-window
Oct 4, 2026
Merged

darkmatter2222 merged 2 commits into
mainfrom
feature/rolling-image-window

Conversation

@darkmatter2222

Copy link
Copy Markdown
Owner

Screenshot-heavy sessions accumulate raw images and can exceed a model's per-request image limit. This change defaults Master Goal to the newest image across each outgoing conversation, with native plugin configuration for other limits.

Configuration:

{"plugins":[{"package":"@darkmatter2222/opencode-mastergoal","options":{"imageWindow":1}}]}

Keep the existing package path when editing an installed registration. Explicit options override MASTERGOAL_IMAGE_WINDOW, then default 1. Zero excludes all raw images. Invalid selected values reject startup. Installer upgrades preserve options.

The existing context/compaction callbacks filter request messages before goal injection; title/generate hooks cover auxiliary session requests. Filtering handles canonical Media.Asset image parts (bytes, base64, URL, provider reference) and image MIME files nested in tool-result content. It preserves text, non-image files, tool pairs and source history, with structural sharing and linear traversal. No lifecycle changes or dependency upgrades; @opencode/plugin stays at 2.0.22.

Validation:

  • npm run verify: 117 tests and 20/20 deterministic scenarios passed.
  • npm run test:install: packaged local/global installation and uninstall passed.
  • Actual OpenCode 2.0.22 HTTP provider capture: 100 stored image-bearing prompts produced [1,1,1] images across three requests with default configuration; limits 4 and 0 produced [4,4,4] and [0,0,0].
  • All 100 screenshot attachments remained in exported persistent history. A distinct newest PNG was verified in the default provider payload.
  • Tests include 1,000 growing turns, global ordering, tool screenshots, non-image preservation, frozen inputs, strict settings, auxiliary hooks, existing goal injection and installer option preservation.

Exact files changed:

  • src/image-window.ts, src/server.ts, src/install.ts, src/commands.ts
  • test/image-window.test.mjs, test/adapters.test.mjs, test/commands.test.mjs
  • scripts/host-canary-v2.mjs
  • README.md, docs/architecture.md, docs/validation.md

Scope limits: OpenCode offers no final hook priority; another plugin inserting images after this filter can invalidate its ceiling. Opaque provider-managed history and calls outside session hooks are not inspected. Provider capture uses a local OpenAI-compatible fake, not live vLLM. Automatic compaction is disabled in the capture fixture; auxiliary filtering is tested at the official hook boundary. Full details and reproducible commands are in docs/validation.md.

@darkmatter2222
darkmatter2222 marked this pull request as ready for review October 4, 2026 00:55
@darkmatter2222
darkmatter2222 merged commit b67f57c into main Oct 4, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant