Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge main into release/2.1: bootstrap transient-chunk retry (#617)
AkitaOnRailsb6bf12513a53
diff --cc CHANGELOG.mdindex 65f65ce1,e928436e..d850a37d--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -7,51 -7,17 +7,61 @@@ and this project adheres to [Semantic V## [Unreleased]+### Added+- `install-hooks --agent codex` now wires Codex's `SessionEnd` hook, so a+ finished Codex session gets the same automatic end-of-session summary+ and cross-agent handoff Claude Code already gets. Codex shipped a+ first-class `SessionEnd` event in Codex CLI 0.145.0 (openai/codex#33895);+ the `hooks/codex/session-end.{sh,ps1}` scripts already existed and only+ needed adding to the Codex hook profile. On older Codex the event key is+ inert; `ai-memory finalize-session --agent codex` remains the fallback.+ `merge_codex_payload` no longer strips a `SessionEnd` key on every apply+ — a third-party `SessionEnd` hook is preserved alongside ours. ([#604])+- `AI_MEMORY_LLM_HEADERS` (`llm_headers` in `config.toml`) attaches extra+ HTTP headers to every LLM chat request, for gateways that require a+ caller-identifying header. Entries are `Name=Value` or `Name: Value`,+ comma separated in the env var. Parsed and validated once at the+ configuration boundary, so a malformed entry fails at startup rather than+ on the first consolidation pass, and providers consume typed header+ material instead of operator strings. Headers ai-memory sets itself+ (`authorization`, `content-type`, `x-api-key`, `x-goog-api-key`,+ `anthropic-version`, `anthropic-beta`, `openai-beta`, `host`,+ `content-length`) are refused: `reqwest` appends rather than replaces, so a+ duplicate would break the request instead of overriding it. Values are+ marked sensitive on the wire and never logged — the `Debug` output carries+ header names only. ([#606])++### Changed+- Every LLM chat request now sends `User-Agent: ai-memory/<version>`.+ `reqwest` sends no user agent unless one is configured, so provider+ requests previously arrived anonymous, and gateways that require callers to+ identify themselves reported ai-memory as an unknown client. An+ `AI_MEMORY_LLM_HEADERS` entry for `user-agent` overrides it. The Copilot+ provider is unchanged: it keeps `GitHubCopilotChat/<version>`, the+ editor-plugin agent GitHub's Copilot API expects. ([#606])+- `x-opencode-session` and the `opencode` user agent, both shipped in 2.0.2,+ are now operator-overridable like any other header: an+ `AI_MEMORY_LLM_HEADERS` entry for either name takes precedence over the+ provider's default. The default remains 2.0.2's — one `LlmOperationId` per+ logical operation, stable across retries and the strict/tolerant fallback —+ so nothing changes unless an operator asks for it. Override the session+ header to tell several ai-memory instances apart in OpenCode's metrics.+ ([#606])+### Fixed+- The OpenCode provider now sends `gpt-5.6-luna` requests to OpenCode Go's+ Responses endpoint. Luna is not served through Chat Completions, where plain+ and structured ai-memory calls returned HTTP 500 (#618).+ - `bootstrap` now retries a chunk's LLM call on a transient error before+ giving up, instead of letting one blip discard the whole multi-chunk run+ (#617). A provider `5xx`/`429` or a transport timeout/connect failure on+ chunk *n* previously aborted the run and threw away chunks *1..n-1* — the+ reporter's own runs died repeatedly to provider `520`s and connection+ resets. Each chunk now gets up to 3 short, fixed-delay attempts;+ deterministic failures (auth, schema, a `4xx`, malformed JSON) are not+ retried. The retry is deliberately short and bounded, not tenacity-style+ escalating backoff (cognee #2840). A durable `--resume` for the rarer+ crash/hard-failure case remains tracked separately in #617.- `bootstrap` no longer aborts the whole multi-chunk run when one chunkreturns no `pages` key (#614). Later chunks are told which pathsearlier ones wrote, so a model that judges the material already