Skip to content

Preserve insight CLI and reflect fixes with iii 0.22.1 - #1

Draft
mbakman wants to merge 30 commits into
mainfrom
codex/upstream-0221
Draft

mbakman wants to merge 30 commits into
mainfrom
codex/upstream-0221

Conversation

@mbakman

@mbakman mbakman commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

The fork provides native insight search through both agentmemory insights and agentmemory-insights. It preserves the reflect fixes in source and aligns iii-engine, SDK, and helpers at 0.22.1. Application version remains 0.9.29.

The CLI previously exited after 15 seconds while its in-process worker was still loading search indexes. All five startup paths now use a validated 120-second default. AGENTMEMORY_WORKER_READY_TIMEOUT_MS accepts integer values from 1000 through 600000 milliseconds. Engine startup deadlines remain unchanged. Full readiness still requires viewer startup or an explicit viewer skip. Ordinary installed startup reached Ready after 36.651 seconds, with the existing engine kept running. A second start refused to create another worker.

The package includes the tested dependency lock as npm-shrinkwrap.json. README documents installing a local tarball and then running local npm ci --omit=dev inside its installed package directory. This avoids npm 11.20.0 selecting newer compatible versions on the local tarball global-install path. All 186 installed production dependencies match the tested lock. All 286 packaged application files match the final private artifact.

Validation in the startup repair session:

  • npm run build passed.
  • npm test passed 2,958 tests in 244 files; two tests were skipped.
  • npm run skills:check passed all 17 skills.
  • Behavioral tests cover readiness at 39 seconds, stalled and hung probes, configuration validation, and unaffected client commands.
  • The installed pinned MCP bridge returned all 54 tools and the exact prior ten force_set result IDs.
  • Both installed insight entrypoints obeyed the two-result limit and omitted source-memory ID lists. Empty results returned zero; authentication and refused-connection failures returned exit 1 with distinct diagnostics.
  • Authenticated status and viewer access returned HTTP 200. Keyword indexing was complete and live capture continued.
  • Fable reviewed the plan and implementation at effort max, with native 1M context, and returned READY.

The recorded cold backup, independent restore, migration comparison, and rollback limits are in the cutover record. Current startup repair evidence is summarized in the progress record. Private backups and memory evidence remain local.

The 502 prior dead letters remain a separate capture maintenance item. The existing vector coverage gap also remains separate. Sol observation compression is enabled; scheduled generation and retention remain disabled during the model trial. This PR remains a draft. No main merge is part of this work.

rohitg00 and others added 30 commits October 4, 2026 13:13
…r engine config (rohitg00#1472)

* fix(embedding): let OPENAI_EMBEDDING_API_KEY win over OPENAI_API_KEY

The embedding factory passed OPENAI_API_KEY into the OpenAI embedding
provider, so the provider's own resolution (embedding key first, then the
shared key) never ran. Installs that point embeddings at a separate
endpoint with OPENAI_EMBEDDING_BASE_URL sent the chat key there and every
embed call failed with 401.

- the factory now lets the provider resolve the key from the merged env
  (process env plus ~/.agentmemory/.env)
- blank values are treated as unset
- auto-detection also selects the openai provider when only
  OPENAI_EMBEDDING_API_KEY is set
- README env template lists OPENAI_EMBEDDING_BASE_URL and
  OPENAI_EMBEDDING_API_KEY

* fix(hooks): emit structured SessionStart context for hook_event_name payloads

With AGENTMEMORY_INJECT_CONTEXT=true the SessionStart hook printed the
memory context as plain text. Hosts that add plain SessionStart stdout to
the conversation picked it up, but strict hook runners that only read the
structured hookSpecificOutput.additionalContext field dropped it.

When the payload carries hook_event_name "SessionStart", the hook now
prints {"hookSpecificOutput":{"hookEventName":"SessionStart",
"additionalContext":...}}, which the documented hook contract accepts for
SessionStart (https://code.claude.com/docs/en/hooks), and so does the
Codex SessionStart parser.

Unchanged:
- injection off still prints nothing
- the camelCase sessionStart payload keeps the additional_context shape
- the Devin path keeps the envelope it already used
- payloads without hook_event_name (Copilot CLI) keep plain text
- Droid (FACTORY_PROJECT_DIR / DROID_PLUGIN_ROOT set) keeps plain text,
  which its hook runner documents as SessionStart context

pre-tool-use and pre-compact are left as they are: PreCompact has no
additionalContext field in the hook contract, and some runners that share
these scripts reject additionalContext on PreToolUse.

plugin/scripts/session-start.mjs is rebuilt.

* docs(engine): document AGENTMEMORY_III_CONFIG and the engine bind address

A CLI started inside a container binds the engine to the container's
loopback, so published ports reach nothing, and the variable that changes
this was only listed by name.

The loopback default stays: it is deliberate and covers containers too.
This documents how the CLI picks its engine config (AGENTMEMORY_III_CONFIG,
./iii-config.yaml, ~/.agentmemory/iii-config.yaml, bundled), that the
chosen file is re-rendered on every start with its host values kept, and
that a containerized CLI can opt into 0.0.0.0 by pointing
AGENTMEMORY_III_CONFIG at the packaged iii-config.docker.yaml. It also
states that docker-compose.yml mounts iii-config.docker.yaml straight
into the engine container and never goes through the CLI lookup.

- README: new "Engine config and bind address" section
- agentmemory-config skill REFERENCE: "Engine config" section
- CLI --help: AGENTMEMORY_III_CONFIG under Environment
- tests: rendering keeps the bundled config on 127.0.0.1 and keeps the
  0.0.0.0 binds of iii-config.docker.yaml

* docs(env): document embedding-only OpenAI keys and the engine config path

Adds OPENAI_EMBEDDING_BASE_URL and OPENAI_EMBEDDING_API_KEY next to the
embedding provider settings, and AGENTMEMORY_III_CONFIG next to the data
directory, so .env.example matches the README and the CLI help.
Add `agentmemory insights <query> [--limit N] [--json]` and the compatibility bin `agentmemory-insights <query> [max] [pool]`, thin clients for the server's existing POST /agentmemory/insights/search. Output omits source-memory ID lists, failures exit 1 with a diagnostic on stderr, usage errors exit 2, and successful empty searches exit 0.

Regenerate the agentmemory-config skill reference for AGENTMEMORY_INSIGHTS_TIMEOUT_MS.
Resolve dist entries and sources relative to the test file via a repoFile helper instead of cwd.
Fail fast with a clear message when dist/cli.mjs or dist/insights-cli.mjs is missing or older than its sources.
Add spawnCli with a 30s timeout and optional early stdout/stderr close for stream tests.
Add runCli to invoke the native binary without the insights prefix.
No behavioral tests added; the 31 existing entrypoint tests pass on a fresh build.
Guard stdout/stderr so an early-closed reader exits 0 and other write errors exit 1.
Validate the base URL and III_REST_PORT before building the search endpoint.
Distinguish truncated response bodies from malformed JSON and cancel unread bodies on non-OK status.
Cap --limit and max at 100, bound the timeout, and reject queries with only one-character terms.
Name the offending record on validation errors and slice results to the limit first.
Add unit and entrypoint tests covering each fix.
Show help for --help or -h anywhere before --, and prefix messages by invoked name.
Connection and timeout errors name the origin and error code with a remediation hint.
Reject an unsendable AGENTMEMORY_SECRET with a configuration error that never echoes it.
Add a quoting hint for non-numeric compat max or pool arguments.
Strip control characters from text output; JSON output is unchanged.
Add unit and entrypoint tests for both compat and native modes.
searchInsights requests one record past the limit and returns { insights, truncated }.
JSON output adds truncated after limit; text output marks the header and prints a stdout footer suggesting a higher limit or a more distinctive term.
Each insight carries createdAt and lastReinforcedAt, nulled leniently when not strings.
Text brackets show UTC created and reinforced dates, omitting unparseable values.
Unit and entrypoint tests cover truncation, the limit-100 cap, and date rendering in both modes.
Rewrite insights --help to the design text and add a short usage block for usage errors.
Update top-level help: insights entry, Honored-by line, AGENTMEMORY_INSIGHTS_TIMEOUT_MS, and insights in the unknown-command Supported list.
Expand the README insights section on query semantics, the 1-100 limit, configuration and exit codes.
Add an insights line to INSTALL_FOR_AGENTS.md lifecycle commands.
Add help, usage-error and unknown-command tests for both entrypoints.
Reject secrets with control characters or characters above U+00FF before fetch.
Show the quoting hint only for non-plain-decimal limit values.
Require plain dates or zoned date-times before rendering created dates.
Shorten the --limit help entry and pin help text in tests.
Guard the test harness against empty or flag-first argv.
The insights CLI now sends its single POST with redirect: manual, so a 3xx
response never re-sends the request or the bearer token to the Location target.
Any 3xx exits 1 with a backend failure message telling the user to point
AGENTMEMORY_URL at the server's own address. Unit and entrypoint tests cover it.
Use graph snapshots, bounded retrieval and prompts, and persistent cluster cooldowns. Gate session-stop graph extraction and align worker and HTTP timeouts.

Add regression coverage and record clean npm installation and live deployment evidence.
…0#1477)

The bucketed index rewrite (rohitg00#1416) replaced test/index-persistence.test.ts and
dropped the gating suite that rohitg00#1182 added. Bring it back against the current
storage: index_persist rows now come from the legacy migration and its cleanup
deletes, and audit rows land in the month scope.

The suite clears AGENTMEMORY_AUDIT_INDEX_PERSIST going in and restores it on
the way out, then checks that auditing is off by default, that trimmed and
case-insensitive "1" and "true" turn it on (with migrate and delete rows),
that "0", "false", "yes" and blank values keep it off, and that the index
still migrates and reloads from buckets when auditing is off.

Co-authored-by: Dmitrii Zhukov <dmitry0983@gmail.com>
…ohitg00#1476)

* feat(opencode): support OpenCode 2.x plugin API alongside V1

OpenCode 2 replaced the V1 `Hooks`-object plugin shape. The default export
must now carry an `id` plus a `setup(ctx)`, and hooks are registered on the
domain that owns the operation. On OpenCode 2.0.20 the existing plugin fails
to load entirely:

  Plugin must export a default definition with an id and an effect or
  setup function.

The plugin now default-exports both implementations from one file:

  export default { id, setup: v2Setup, server: v1Hooks }

V1 calls `server()` and uses the returned hooks; V2 reads `id` and `setup()`
and ignores `server()`. The V1 body is unchanged and remains the full
22-hook implementation. The two paths are kept separate on purpose, since
sharing an export does not translate V1 hooks into V2 hooks and the payloads
differ enough that a shared core would overstate V2 coverage.

Ported to V2: event -> ctx.event.subscribe(), tool.execute.before ->
ctx.tool.hook, chat.message -> ctx.session.hook("prompt"), and
experimental.chat.system.transform -> ctx.session.hook("context"). All 15
consumed event types still exist on the V2 event stream; permission.updated
is now permission.asked with a reshaped payload.

Three V1 hooks have no faithful V2 equivalent and are dropped on that path
rather than approximated, since a wrong-shaped payload reaching agentmemory
is worse than a missing one:

- config: no mutable global config object and no observing hook. The V2 path
  takes a one-shot snapshot at setup instead.
- chat.params: V2 `context` starts with empty options rather than resolved
  model settings, so recorded values would be wrong.
- experimental.session.compacting: V2's compaction hook can only set
  `result`, which skips the model call, so context cannot be injected.

`@opencode/plugin` is not imported at runtime, so no V2 SDK install is needed.

Tested on OpenCode v2.0.20: loads with no errors, and server() still returns
all 7 V1 hooks.

* fix(opencode): keep the V2 event subscription alive and stop dropping observations

Three defects found in the V2 path, all confirmed by reading the code and by
running the module under bun.

The subscription now wraps its switch body in handleEvent() and invokes it per
event. Inline in the for-await loop, the guard `return`s exited the async IIFE
and permanently ended the subscription, so the first message.updated for a user
role killed the stream and no later session.deleted, /summarize, tool or
permission event was ever processed. A throw from a single handler is also
isolated now. Verified by driving the real stream: before the fix an event
following a guard-return produced 0 observations, after it produces 2.

The setup-time config snapshot is parked in pendingConfig when no session is
active, which is the normal case, and flushed from the session.created handler
after /session/start. It was previously discarded, so config_loaded was almost
never sent despite what the README says. The V1 config hook already used this
pattern.

Tool call dedup now records callID only in the completed and error branches,
matching V1. Recording it on the first pending/running update made the
terminal update look like a duplicate, so completed tool calls were never
observed.

* fix(opencode): cast postJson results before reading context

postJson returns Promise<unknown | null>, so the three V2 reads of .context
produced TS18046. The V1 path already casts at its four read sites; these three
were missed during the port.

* fix(opencode): port the V2 capture path against the real event stream

The V2 path registered and returned a cleanup function, but captured almost
nothing. The payload lives in `event.data`, not `event.properties`, so `sid0`
was always undefined and every handler returned at its guard. Every event type
the handler switched on had been renamed. Rewritten against what v2.0.22 emits.

Where the previous port guessed, this one follows the observed runtime:

- Events are read from `event.data`; the envelope is
  `created, data, id, location, type`. Session identity comes from
  `data.sessionID`, since `location` is process-level.
- The V1 event names no longer exist. Mapped to what V2 emits: message text to
  `session.text.*` and `session.reasoning.*`, `message.part.updated` to
  `ctx.tool.hook("execute.after")`, `command.executed` to `shell.created`,
  `session.error` to `session.execution.failed`, `file.edited` to
  `file.watcher.updated`, `session.status` to `session.step.*`.
- `ctx.agent.list()`, `ctx.provider.list()` and `ctx.mcp.list()` resolve to
  `{ data, location }`. Reading them with `Object.keys()` recorded the literal
  strings `["location", "data"]` as agent and provider names.
- `ctx.model.default()` is a promise. Without `await` it stringifies to `{}`.
- There is no `session.created`. A session is registered by the first event
  carrying its ID, and `session_started` is emitted there, because
  `session.execution.started` was not observed on the live stream.

Tool results come from `execute.after`, which carries `status` and
`result.output`, replacing the V1 `message.part.updated` tool branch. The tool
name lives on `session.tool.input.started` as `name`, so it is tracked per call
ID to label failures. `session.tool.failed` and `shell.exited` are handled as
fallbacks, suppressed when the hook already reported the same call.

Memory is now injected on every model call instead of once per session: the
`context` hook fires per call and exposes `system`, so the previous guard meant
only the first prompt carried recalled memory.

Validated against payloads captured from a running v2.0.22 rather than
hand-built objects, which is how the original shape error survived review. A
36-assertion suite covers every handler, the deduplication paths and the
regression where an early `return` ended the subscription permanently. It passes
with zero failures, and a live run produced real observations for
`post_tool_use`, `config_loaded`, `step_start`, `step_finish`,
`assistant_message`, `command_executed`, `reasoning`, `text_started`,
`text_ended` and `notification`.

The V1 path is untouched: the diff starts at the V2 block.

* docs(opencode): document the V2 runtime as observed, not as generated

The README claimed all fifteen event types still existed on the V2 stream and
that memory could not be attached to the compaction prompt. Both statements
were wrong. The V1 event names are gone, the compaction hook does expose
system, and the stale SDK types are what made the original port look correct.

Each claim is now marked observed or inferred, and the verification section
states that the suite runs against payloads captured from v2.0.22.

* docs(opencode): explain the ctx:any signature and the double-load risk

Both are open questions from review, and both were answered only in PR
comments, which is not where someone installing the plugin will look.

The `any` is deliberate: typing it from @opencode/plugin would import
generated types that are stale for V2, so the compiler would reject correct
code while accepting the shape that broke the previous port. The README now
states the three risks that follow from that trade, and the comment above
v2Setup repeats them for anyone reading the source.

The install section previously told people to copy the file into the plugins
directory AND list it under "plugins", which can register the plugin twice and
capture every event twice. It now presents the two routes as alternatives with
an explicit warning against combining them.

* docs(opencode): correct the assertion count to 35

The suite has 35 assertions, not 36. Off by one from counting the summary
line as an assertion.

* fix(opencode): bound per-call state and register every session

Three of the five review findings are real leaks or correctness gaps; the other
two are documentation that contradicted the code.

Registration was gated on `activeSessionId` being unset, so the first session
claimed it and every later one skipped registration entirely. A subagent child
session running alongside its parent never reached `/session/start` and never
got `session_started`, while the handlers below still emitted observations for
that ID, so the server received activity for a session it had never seen.
Registration is now tracked per session ID, with the global kept only as a
fallback for events that carry no ID, and the set is pruned on
`session.deleted`. V1 does not have this problem because it registers on its
own `session.created` event.

`toolNames`, `toolCallInputs` and `reportedToolCalls` were never released on
the success path. `toolCallInputs` holds the full `input` of every call, which
for `write` and `edit` is the entire file body, so a long-running process
accumulated every file it had ever written. Entries are now dropped when
`session.tool.success` reports the result, and a session's dedupe keys are
cleared on `session.deleted`.

The file watcher and filesystem handlers wrote to the stash without applying
`MAX_STASHED_FILES`, unlike every other write. Those fire for any workspace
change, so the stash could grow without bound and newer files could sit queued
behind older entries that never got enriched. All writes now go through one
`stashAdd` helper that enforces the cap.

The duplicated `reportedToolCalls.add` lines and the duplicated comment in the
`execute.after` error branch were leftovers from editing the same block twice.
Removed.

The install section told people to copy the file into the auto-loaded
directory and then, under a "Route A" heading, to list that same copy under
`"plugins"` — which is exactly the double registration the section warned
about. The copy is now the whole install, the config key is presented only for
installing elsewhere, and the warning says which entry to remove.

The compaction row in the model table said "not injectable" while the text
described it as wired. It is wired but was never observed firing, so it now
reads "inferred, unobserved" in both places, and the prose says the same.

Suite is now 40 assertions, up from 35, with new cases for multi-session
registration, release of per-call state, and the stash cap under a burst of
watcher events. Zero failures. The V1 body is untouched: the code diff starts
inside `v2Setup`.

* fix(opencode): only register a session once /session/start returns

The session was added to `registeredSessions` before the request, so a start
that failed while agentmemory was restarting left the ID marked as registered
and every later event skipped registration for the rest of the process. The
session could never be recovered without restarting OpenCode.

`postJson` resolves to null on any failure, so the ID is now added only after a
non-null response, and a failed attempt drops the per-session state it created
so the retry starts clean. Registration is then retried on the next event.

Two assertions added, bringing the suite to 42. Both fail against the previous
code and pass against this one: a start that fails twice and then succeeds is
retried rather than abandoned, and the subscription stays live through the
failure.

* chore(scripts): detect drift between repo and installed OpenCode plugin

The file in ~/.config/opencode/plugins/ is an install artifact and must not be
edited directly. On 2026-10-02 it was still the pre-fix build, reading
event.properties and capturing nothing, while the PR had moved on eight fixes.

The script compares SHA-256, reports drift, and names the V2 blocker
explicitly when it finds the installed copy still reading event.properties.
It only writes when given -Apply, because silent sync would hide a regression
arriving from the PR. Verified in all three states: in sync, drifted, and
drifted-then-applied.

* fix(opencode): capture compaction from events, drop the dead hook

A re-probe against v2.0.22 that creates a session and forces a compaction
shows three things the earlier pass got wrong.

`session.created` exists and carries sessionID, projectID, location, title,
version, subpath and slug. This file claimed it did not. That came from
observing an already-open session and never creating one: absence in a sample
rather than absence in the API. Registration already ran off the first event
carrying an ID, so `session.created` needs no code change, only the correction
and a comment on why the fallback still exists.

`ctx.session.hook("compaction")` registers a handler that is never invoked,
even when `ctx.session.compact()` is called directly and returns a compaction
message. The loader validates hook names at registration and not against
invocation, so the dead handler is removed. Compaction is captured from
`session.compaction.started` and `session.compaction.failed` instead, which
means compaction is now observed for real. Memory still cannot be attached to
the compaction prompt, because no compaction event carries a system array.

`parentID` is accepted by `session.create` and appears in no event payload, so
what `/session/start` sends stays null. The field is kept for a future version
and documented as unused.

`session.execution.succeeded` carries only `{ sessionID }`, already present on
every other observation, and `session.step.ended` covers the signal, so it is
observed but deliberately not recorded.

The V1 body is untouched.

* test(opencode): cover the V2 capture path against captured payloads

The V2 port shipped dead because its tests agreed with its assumptions: it read
`event.properties`, always `{}` on the runtime, and every handler returned at
its guard while the suite stayed green. These tests drive the handlers with
payloads captured from v2.0.22 and run under the repo's existing vitest, so
`npm test` covers the plugin with no new tooling.

33 cases across session lifecycle, tool hooks, memory injection, compaction,
the event switch and resilience. Two behaviours they lock in:

- the compaction hook is asserted absent, not merely untested, because it
  registers without error and never fires
- the subscription survives events it does not recognise, the regression where
  a guard `return` inside the for-await ended it permanently

Each new assertion was checked against the previous commit: the three
compaction cases fail on 7a06239 and pass here.

One harness rule is worth stating because it cost an hour: every assertion
waits for its own target. An earlier draft waited for `/session/start` and
asserted on `session_started`, which is emitted after that await resolves, so it
read an empty array and 19 cases failed for a reason that had nothing to do with
the plugin.

* docs(opencode): correct the session.created and compaction claims

Removes the "there is no session.created" claim, corrects the compaction row
from "ported, inferred" to the observed reality (the hook never fires,
compaction is captured from events and is not injectable), and points
Verification at the vitest file that now runs under the repo own test command.

Also drops the 42-assertion count, which referred to the bun harness that no
longer exists. The suite is 33 vitest cases.

* fix(scripts): scope the V2 blocker check so it stops crying wolf

The drift detector reported "reads event.properties, capture dead" on a
correctly synced file. It grepped the whole file, and the V1 path legitimately
reads event.properties because in V1 the payload does live there. A healthy
install looked broken.

The check now scopes to the v2Setup block, falls back to the whole file for the
older V2-only format that predates the dual export, and ignores comments. An
earlier attempt still missed the real case because its pattern expected
event.properties while the code reads (event as any).properties; matching the
word properties in non-comment code within the V2 scope is both simpler and
correct.

Verified both ways: the 30/09 pre-fix file is flagged, and the synced file is
not.

* fix(opencode): read the tool error from event.error

The failure branch read `result.metadata.error`, but `metadata` carries only
exit/status/truncated. The message came out empty, and since the call was then
marked as reported the `session.tool.failed` fallback was skipped too, so the
error was lost twice over.

`event.error` is now in the chain ahead of the metadata fallback. The test
covers the documented shape and was checked against the previous code, where it
reads an empty string.

* fix(opencode): fetch recalled context once per prompt

The context hook fires on every model call, tool continuations included, so
requesting /context per call multiplied the requests without adding anything:
within a prompt the recalled set does not change.

The result is now cached for the turn and cleared by the prompt hook, so each
new prompt refreshes it. Memory still reaches the system prompt of every call.

* fix(opencode): restore the compaction hook and drop redundant observations

The compaction hook was removed on the claim that it never fires. That claim
was not established: `ctx.session.compact()` only queues a compaction request,
and the run that produced the evidence failed immediately with "Nothing to
compact yet" because the session was empty. The hook never got a real
compaction to run, so it is restored and shares the turn's cached context.

`session.text.started`, `session.text.ended` and `session.usage.updated` are no
longer recorded. The first two carry no content and the third duplicates the
token and cost figures already in `step_finish`, while every observation goes
through the capture pipeline.

* style(opencode): drop code comments

Repo convention keeps the plugin sources comment-free; the runtime notes that
explain the V2 shape live in README.md instead of beside the code, so the
behaviour is documented once, in the place a reviewer reads first.

The V1 body is untouched: the diff starts inside v2Setup.

* chore(opencode): remove the local plugin sync script

The script compared the repo plugin against one machine's install path to catch
drift. That is local setup, not something the repository should carry, and the
install path it hardcodes does not exist for anyone else.

* docs(opencode): correct the V1 and compaction claims

Three claims were wrong or unproven.

`session.created` was said not to exist. It does; the earlier reading came from
observing an already-open session and never creating one, which is absence in a
sample rather than in the API.

The compaction hook was said to never fire, and it was removed. That was not
established: `compact()` only queues the request and the run behind the claim
failed immediately on an empty session, so the hook never had a real compaction
to run.

The compatibility line named "OpenCode 1.x" with "1.18.29+". OpenCode has no
1.x CLI: `@opencode/cli` goes from 0.0.0 beta straight to 2.0.x, and the V1
plugin API ships in `opencode-ai`, tested here at 1.18.34. A plugin declaring
both a `server()` on its default export and a named export is loaded once by
that version: the default is used and the named export is ignored.

Also records that `session.text.*` and `session.usage.updated` are read but not
recorded, and that /context is fetched once per prompt.

* fix(opencode): close the V2 capture gaps found in live sessions

Checked against OpenCode 2.0.24, 1.18.34 and 1.17.10 in real sessions.

- V1 releases call setup() as well as server(), with a context that has
  no tool, session or event. setup() now returns when those are missing,
  so V1 no longer runs a second config snapshot and a silently failing
  V2 registration.
- session.execution.succeeded requests /summarize, the V2 equivalent of
  the V1 idle summary. V2 sessions were never summarized.
- session.text.ended is recorded as assistant_message, so the agent's
  answer reaches memory.
- session.instructions.updated records the changed instruction sources.
  The payload field is delta, a map of source to hash, not text.
- Drop observations with no content: reasoning.started, inbox.delivered,
  and the shell.created entry that duplicated the tool observation.
- Skip a config snapshot equal to the previous one.
- Remove the comment blocks added with the V2 path.

* docs(opencode): record verified V1 and V2 runtime behavior

The V1 load is now verified on 1.17.10 and 1.18.34, including the setup()
call. Correct the session.created fields, the summarize and instructions
behavior, the text and shell event rows, and the standalone delete gap.

---------

Co-authored-by: Tyxiel <128870773+Tyxiel@users.noreply.github.com>
Preserve insight command compatibility and source reflect fixes. Align SDK, helpers, and engine pins; use generated local API secrets for insight search and test monthly audit records. Record build, suite, skill, package, and installed command evidence.
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.

2 participants