You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
agent-framework #139 — ACCEPT at exact head fec2fc430b3da4d7a40e181cff5012eca5c3efa4 (PR base 12f0ee6; origin/main is now 511b722, and git merge --no-commit of that into the head auto-merges with no conflicts). Reviewed as part of the kv-unified package with the lens "does anything change for an agent whose CM is not kv-unified".
Current flows are not disrupted. Gate is isKvUnifiedEnabled() = config.foldingStrategy === 'kv-unified' (CM autobiographical.ts:7445-7447), absent entirely on CM v0.7.0 → false.
Ungated change, evaluated: src/framework.ts:6015-6020 and :6959-6998 compute a per-call usage delta and feed it to reportRealInputTokens for every agent.
Membrane usage events are cumulative across the native/XML tool loop in both lineages checked (local 8cbbf88membrane.ts:2489-2500, :3032-3043; release v0.5.81 via turnUsage.addRound, src/utils/usage.ts:119-129), so the premise holds.
First call: cumulativeDelta(x, 0) = x, byte-identical to base. Retries are a fresh driveStream and a fresh membrane stream, so delta and counter reset together.
It is a no-op on the value CM consumes: reportRealInputTokens (CM autobiographical.ts:7380-7395) is armed once per compile (:7357) and drops later samples; only the first usage event per compile is consumed and that value is unchanged. agent.lastStream*Tokens and the inference:usage trace still carry cumulative event.usage.
Gated, verified: agent.ts:645-653 calls isKvUnifiedEnabled?.() per activation (trivial); the prefix hash and second buildSystemPrompt (:655-660) run only under kv-unified; cacheMarkers: 'cm-owned' is spread only under kv-unified (:709) so the default request object is identical (test asserts undefined); kvQueue/onCacheWireReceipt (:744-787) only under kv; takeKvSubmission?.() (framework.ts:7000) and the finally drain (:7077-7087) are dead for non-kv agents.
Nonblocking:
No framework-level test covers the driveStream delta path; the membrane "cumulative event" contract is asserted in a comment only. A driveStream test with two usage events would pin it.
Comment at framework.ts:6012-6014 says per-call usage feeds kv receipt acceptance; it does not (acceptance keys off takeKvSubmission() per event).
If a future membrane emitted per-call usage, cumulativeDelta would under-report on calls 2+ whenever current >= previous; unobservable today given the arm-once gate.
Gated: immutablePrefixHash hashes the input injections' system blocks (agent.ts:652-654) while the wire uses compile's returned systemInjections (:700); CM passes them through unchanged today, nothing pins that. beginKvUnifiedSubmission throws when no draft (CM :7436-7438) from inside membrane's onCacheWireReceipt callback.
Receipts: git diff --check clean; head builds against the deployed Mac membrane/CM (tsc exit 0); against archived release tags membrane v0.5.81 + CM v0.7.0 the head adds zero errors over base (both show the same 3 fixture-artifact TS2322s from two nominal Membrane classes); tests base 635/0/4 → head 639/0/4, failure-set diff empty; mutation (cumulativeDelta → identity) turns the 2 usage-accounting unit tests red; changelog fragment present; version unchanged (0.11.0).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Dependencies:
Validation
Rollout
No strategy is activated by this PR. Existing agents and marker ownership remain unchanged unless their Context Manager reports kv-unified enabled.