Frozen state: store edits to earlier array elements as changes, not whole arrays

Open
#5,320 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Start by reading the diffState implementation and the state operation readers and writers; the issue names no file or test paths. Compare how array prefix appends and whole-array set operations are encoded, then check existing tests for frozen state diffs. Done means earlier element edits can be stored with tail appends or truncations, with a compatible rollout that ships readers before writers.

Written by the indexing model from the issue text.

Description

Follow-up from review of #5214 / #5215.

Frozen state is stored as a change from the version it was made from (diffState). Arrays are diffed as append only when the old array is a prefix of the new one. Any other change, such as editing an earlier element and then appending, pop(), or splice(), writes the whole array as one set.

Agent loops hit this often: they fill in a tool result on the last assistant message, then append the next one. Measured on a 200-message history, editing the last message and appending one produced 6,566 B of ops, against 6,536 B for the whole value, so no saving at all.

Possible approaches:

  • per-index set ops for changed elements (by identity, which is cheap for frozen values), plus append for the tail;
  • a truncate op for pop() / splice() at the end;
  • falling back to set only when the index ops outgrow the array.

The stored format would need a new op kind, so readers must ship before writers use it.

🤖 Generated with Claude Code

Dominant language
TypeScript
Stars
2.5k
Forks
401
Avg merge
1d 21h
Merged PRs (30d)
201

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vercel/workflow

All issues in vercel/workflow

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.