Repository navigation
Recount harness: bind the loader's msgs the history restore now estimates from - #12747
Conversation
…estimates from #9475 made the history restore fall back to estimateContextUsage(msgs) when no saved usage is usable. The harness replays that block inside hydrateThreadUsage, which never declared msgs, so every history-hydration case threw 'msgs is not defined' on main. Bind msgs from props, pin the estimate-then-recount behaviour, and guard that every loader local the sliced block reads is declared by the harness.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 465d4b16b0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| start = provider.index(restore) | ||
| loader = provider.rindex("async load() {", 0, start) | ||
| above = provider[loader:start] | ||
| declared_above = set(re.findall(r"\b(?:const|let)\s+([A-Za-z_$][\w$]*)", above)) |
There was a problem hiding this comment.
Include destructured locals in the binding guard
This declaration regex only recognizes simple bindings such as const msgs, so the guard does not actually cover every loader local: the existing const { remoteId } = ... is already read by the sliced restore block but absent from declared_above. If a future restore change reads another destructured loader local, the new test will pass while hydrateThreadUsage still throws a ReferenceError; collect object/array destructuring bindings as well.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Right, the guard missed destructured locals, so remoteId was never actually checked. Fixed in 331fb07: it now collects object and array destructuring names (with a small test of its own) and requires seeing both msgs and remoteId. Renaming the harness's remoteId binding now fails the guard by name.
The binding guard only collected 'const name' declarations, so a destructured loader local such as remoteId was never checked. Collect object and array destructuring names as well, and require the guard to see remoteId.
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Repo tests (CPU, studio)is red on main and on every PR based on it (for example #12739 and #12744). Five cases intests/studio/test_new_chat_context_recount.pyfail with:Cause
#9475 (show estimated context usage before model load) changed the history loader's restore to
The product change is intended: a reopened thread with no usable saved usage now shows a text estimate right away instead of an empty bar until the recount answers. The test is what is behind. It slices that block out of
runtime-provider.tsxand replays it insidehydrateThreadUsage, which declares the loader's other locals (remoteId,savedUsage,store, ...) but nevermsgs. Imported helpers such asestimateContextUsageare followed in automatically byrun_harness; loader locals are not.Changes
hydrateThreadUsagebindsmsgsfromprops.messages(empty by default, so the existing cases keep their expectations).test_history_hydration_shows_an_estimate_until_the_recount_landspins what feat(studio): show estimated context usage before model load #9475 added. While the recount is held, the bar shows the estimate (100 tokens for 400 characters,estimated: true) when nothing saved is usable. The recount's exact count then replaces it. Saved usage for the loaded model is shown as is and is not recounted.test_the_harness_binds_every_loader_local_the_history_restore_reads: reads the locals declared inload()above the slice and fails if the block reads one thathydrateThreadUsagedoes not declare, so the next local the block starts reading fails with its name rather than as a ReferenceError inside a pricing assertion.Verification
0108742f1e): 5 failed, 54 passed. This branch: 63 passed.msgsbinding fails the new guard and the estimate cases, plus the five original cases.restoredUsage ?? estimateContextUsage(msgs)withrestoredUsagein the product fails the two estimate cases.