Skip to content

cli: keep ResponseStore item_reference entries while any owning response is live - #435

Open
Pybsama wants to merge 1 commit into
Nehanth:mainfrom
Pybsama:fix/response-store-shared-item-refs
Open

Pybsama wants to merge 1 commit into
Nehanth:mainfrom
Pybsama:fix/response-store-shared-item-refs

Conversation

@Pybsama

@Pybsama Pybsama commented Dec 3, 2026

Copy link
Copy Markdown

Summary

  • Track per-item owners as Map<rid, item> in ResponseStore.items (cli/lib/store.js) instead of overwriting a single { rid, item } entry.
  • Previously, when a later response referenced an earlier response's item via { type: "item_reference", id }, parseInput() preserved the item's id in the later response's inputItems and store.put() overwrote this.items.get(id) with the newer response ID. Deleting or expiring that later response then removed the item from ResponseStore.items even while the original response was still live (and evicting the original owner would drop it while a referencing response was still live).
  • ResponseStore.item(itemId) now checks live owners in most-recent-first order, cleaning up expired entries via this.get(rid) and falling back to any still-live owning response; delete(id) removes only that response's ownership and deletes the index key once no live response holds it.

Tests

  • Added unit tests in cli/test/responses_store_test.mjs covering:
    • deleting a later referencing response while the original owner remains live,
    • LRU-evicting the original owner while a referencing response remains live,
    • expiring a later referencing response while an earlier owner was refreshed via get().
  • Added end-to-end /v1/responses regression assertions in cli/test/responses_test.mjs verifying that deleting a response created with item_reference leaves the referenced item usable while its original response is still stored.
  • Confirmed both new tests failed before the fix and passed after:
    • node --check cli/lib/store.js cli/test/responses_store_test.mjs cli/test/responses_test.mjs
    • node --test cli/test/*_test.mjs (174 passed, 0 failed, 0 skipped)
    • node --test packages/room-node/test/*_test.mjs packages/openclaw/test/*_test.mjs (213 passed, 6 skipped, 0 failed)
    • npm run test:runtime (6/6 checks passed, 172 frames)

@Pybsama
Pybsama requested a review from Nehanth as a code owner December 3, 2026 18:25
@vercel

vercel Bot commented Dec 3, 2026

Copy link
Copy Markdown

@Pybsama is attempting to deploy a commit to the nehanth's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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