Repository navigation
fix(nu-mcp): keep $history indices stable, run evaluations one at a time, and correct stale guidance in the MCP instructions and AGENTS.md - #19318
Merged
Conversation
… time, and correct stale guidance in the MCP instructions and AGENTS.md
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.
Description
Once
$historywas full, each new evaluation shifted every older entry down by one.History::pushreturned the buffer length after evicting, so an index from an earlier response could point at a later result, while the instructions promised "indices do not shift, older ones simply become unavailable". This PR makes that promise true: indices only increase, and an evicted index reads asnull.pushalso evicts until the buffer fits the limit instead of dropping one entry per push, so loweringNU_MCP_HISTORY_LIMITtrims$historyto the new limit.Two
evaluatecalls sent at once (agents send parallel tool calls) each forked the same state, and the one that finished last overwrote the other. Both responses reported the samehistory_index, and the other call's$historyentry and$envchanges were lost. Evaluations now run one at a time, like lines typed into a REPL: a lock is held from fork to commit and released early when an evaluation is promoted to a background job.list_commandsandcommand_helpdon't wait for it.The rest of the text
nu --mcpsends to agents (instructions.md,evaluate_tool.md, and thelist_commands/command_helpdescriptions) also gave advice that nushell contradicts. It saidls **/*walks hidden directories andglobavoids them, when the reverse is true. It used ajob spawn --tagflag that was renamed in #17496, and saidcommand_helpshows input/output types, which it doesn't. Theevaluatetool description still told agents to avoid large output, which contradicts the server instructions sent in the same session. This PR rewrites those passages to match nushell, tones down the all-caps "THE RULE" section while keeping the rule and its reason, and fills in the two short tool descriptions with their real output format and limits.In
AGENTS.md, it fixes the claim thatcargo nuclippy-testsruns all tests (it runs clippy), says how integration-test targets are named in crates without ateststarget, states three wordy or hedged rules more plainly, and fixes a typo.User-facing changes (Release notes)
MCP: stable $history indices, one evaluation at a time
nu --mcp,$historyindices no longer shift when old entries are evicted. An evicted index reads asnull, and$history | lengthcounts every result stored in the session. LoweringNU_MCP_HISTORY_LIMITnow trims$historyto the new limit.nu --mcpnow runsevaluatecalls one at a time. Before, two calls sent together could get the samehistory_index, and one call's$historyentry and$envchanges were lost.lsvsglobon hidden directories,job spawn --description,command_helpoutput, and\u{...}escapes.evaluatetool description no longer tells agents to avoid large output. Output over the limit already comes back as anotepointing at$history.Additional notes