Repository navigation
Use Chatbook's reported line number for multi-input evaluations - #256
Merged
Merged
Conversation
Chatbook 2.7.28 (WolframResearch/Chatbook#1677) evaluates each top-level input of the evaluator code separately, so one tool call can use up several line numbers. Incrementing the session's line counter once per call no longer matches the Out[n] labels. - Request the new "Line" property and continue the session's line counter from it, falling back to one line per call when it isn't available (older Chatbook, failed evaluation, kernel quit). - Evaluate "Local" eval-kernel bookkeeping with "Line" -> None instead of rolling back $Line, so it uses no line number and no longer overwrites In/Out history entries. - Skip syncEvalKernelLine with 2.7.28+, which applies the "Line" option in the Local and Cloud evaluator kernels itself. - Label the UI notebook's input cell with the first input's line number. Gated on the Chatbook version, so behavior is unchanged with older Chatbook versions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015FJqQoZs86ntnnPqsvkCf6
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The core behavior depends on Chatbook 2.7.28 paths that currently skip in CI.
0 open findings
What changed in this PR
Updates evaluator sessions for Chatbook 2.7.28’s per-input line numbering and history behavior.
Changes:
- Continues session counters from Chatbook’s
"Line"property. - Preserves Local evaluator history during bookkeeping.
- Adds compatibility, integration, and UI-label tests.
| File | Description |
|---|---|
Kernel/Tools/WolframLanguageEvaluator.wl |
Implements version-gated line and Local-session handling. |
Tests/EvaluatorSessions.wlt |
Tests line counters, history, sessions, and compatibility. |
Tests/WolframLanguageEvaluator-UI.wlt |
Tests multi-input notebook labels. |
docs/tools.md |
Documents version-dependent line behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
rhennigan
added a commit
that referenced
this pull request
Oct 9, 2026
Bring in PR #256 (Chatbook's reported line numbers for multi-input evaluations) and the 2.2.18 version bump, and rebuild the agent skills so that they are stamped with version 2.2.18. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HqbPD3YXk9krL9wVG9AACD
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
WolframResearch/Chatbook#1677 (Chatbook 2.7.28) changed
WolframLanguageToolEvaluateto evaluate each top-level input of the code separately, the way an interactive kernel session does. Each input gets its own line number:One tool call can now use up several line numbers, so incrementing the session's line counter once per call puts the next call's
Out[n]on the wrong line. Chatbook now reports the line number for the next input as a new"Line"property, and this PR uses it.Changes (
Kernel/Tools/WolframLanguageEvaluator.wl)chatbookToolEvaluatealso requests the"Line"property, continues the session's$linefrom it, and drops it from the result before returning. Without a valid reported line (older Chatbook, a failed evaluation, or the eval kernel quit), the counter advances by one as before."Local"bookkeeping: session start/save/resume and the paclet load in the eval subkernel now go through a newlocalKernelEvaluate. On 2.7.28+ it evaluates with"Line" -> Noneinstead of rolling back$Line. This matters because Chatbook now recordsIn/Outhistory for held input, so the old rollback would overwrite history entries. As a side effect,%,Out[n]andInString[n]work in Local-method sessions now; they used to return internalByteArrays.syncEvalKernelLine: this is now a no-op on 2.7.28+, because Chatbook applies an explicit"Line"option in the Local and Cloud evaluator kernels itself.Out[n]=, so a three-input call starting at line 1 showedIn[3]:=.makeEvaluatorUIResulttakes that line number as a new third argument.All of this is gated on the installed Chatbook version, using the same pattern as the existing
$CloudSessionMXgate ($linePropertyChatbookVersion = "2.7.28",chatbookLinePropertyQ). With older Chatbook versions (the minimum is still 2.7.0) the behavior is unchanged. I also updateddocs/tools.mdand the comments that described the old line handling.Related: WolframResearch/Chatbook#1677, #249. #249 is fixed on the Chatbook side by the same PR, which parses each input in the evaluator kernel.
Test plan
Tests/EvaluatorSessions.wlt, independent of the installed Chatbook: version gate, continuing at the reported line (string and property-list requests), fallback without a reported line, old-Chatbook path,localKernelEvaluatecall shape for both versions, and thesyncEvalKernelLineno-op."Session"method and (when a sandbox kernel can start) the"Local"method, including%/Out/InStringhistory.Tests/WolframLanguageEvaluator-UI.wlt, with cloud deployment mocked.EvaluatorSessions.wlt+WolframLanguageEvaluator-UI.wlt, 88/88 pass; the 2.7.28-only tests skip.PacletDirectoryLoad):EvaluatorSessions.wlt71/71 (including the existing cloud-session integration test),WolframLanguageEvaluator-UI.wlt20/20,Tools.wlt110/110."Session","Local"and"Cloud"with Chatbook 2.7.28: numbering is correct across multi-input calls, session switches, and a resume from disk.In[1]:=/Out[2]=, and the next call continued atIn[3]:=/Out[3]=.Note: the newest Chatbook on the public paclet server is still 2.7.0, and CI doesn't install a newer one, so the 2.7.28-only integration tests will skip in CI for now.
🤖 Generated with Claude Code
https://claude.ai/code/session_015FJqQoZs86ntnnPqsvkCf6