Repository navigation
fix: stop the assistant inventing filters, and bound MCP discovery - #367
Merged
Merged
Conversation
This was referenced Sep 16, 2026
3 tasks done
neuromechanist
added a commit
that referenced
this pull request
Sep 30, 2026
The file had sections for 0.8.10, 0.8.12, 0.8.14 and 0.8.15 only. The three missing releases are written from the pull requests between their tags (0.8.13: #438, #440, #441, #443; 0.8.11: #418; 0.8.9: #351 to #355 and #359 and #367), so the last seven releases are now all present. Tested: docs only; each entry checked against its pull request's body.
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.
Addresses the review findings on the release pull request #366. Three independent reviewers plus my own pass; this covers the correctness bugs, the blocked gate, and the availability risk. The remainder is filed as follow-ups.
The one that produces wrong science
The system prompt's own worked example told the model to call the primary tool with a parameter that does not exist.
search_datasetstakesmodality; the prompt saidmodality_filter. The server's input schema carries"additionalProperties": {}, so it accepts the unknown key and silently drops it.Verified against the live server:
A researcher asking for MEG datasets gets 92 mostly-EEG results presented as filtered, with nothing in the response or the logs marking it. The prompt also advertised a participant-count filter that does not exist (same silent-drop mechanism), and two of the four canned widget questions were written for the old toolset: one asks for "MEG datasets with at least 50 participants", the query this toolset is least able to answer, and one names
ds000248, an OpenNeuro accession the rewritten prompt itself says is not a valid identifier.Fixed by naming the six real filters explicitly, saying in the prompt that unknown arguments are silently ignored, and pointing participant questions at
subject_counton the results. New canned values checked live:modalityaccepts either case (85 results either way) andnm000219describes cleanly.The one that takes the whole API down
discover_mcp_toolsends inpool.submit(...).result()with no timeout, andcreate_community_assistantis uncached and called per request directly fromasync defhandlers, so that synchronous block runs on the event loop thread. Meanwhileasyncio.wait_forwrapped onlylist_tools(); the connect and protocol handshake sat outside it, bounded solely by the SDK's 300 second read default.So a NEMAR host that accepts the socket and then stalls froze every community's requests for up to five minutes, failed the health probe, and restarted the container. Two reviewers reproduced it independently; one held a socket open and watched discovery still hanging at 75 seconds.
Fixed by putting connect and handshake inside the timeout in both
_discoverand_call, giving.result()a bound, and caching discovered tools for five minutes so the round trip leaves the request hot path entirely.One trap worth naming:
with ThreadPoolExecutor(...)exits viashutdown(wait=True), so adding a timeout to.result()alone still blocks on the hung worker at thewithexit. The executor is now constructed without the context manager and shut down withwait=False, cancel_futures=True.The one that misleads a researcher
When discovery returns nothing, the prompt still described six tools that were not bound, and separately instructs the model to answer rather than decline. The likely output is confident dataset accessions with real-looking links and invented citations.
_load_mcp_toolsnow reports which servers yielded nothing, and the constructor appends an instruction not to answer from memory or invent an identifier, and to point the user athttps://nemar.org/discover._load_mcp_toolsreturns(tools, degraded)rather than mutating instance state, so it stays callable as an unbound function, which its tests rely on.Also
ToolNodehandler converts onlyToolInvocationErrorand re-raises the rest, and these tools carry a raw JSON Schema rather than a pydantic model, so that error never occurs for them. Failures now reach the model as readable text, the way a server refusal already did.mcpis capped below 3.0.0. The production image installs frompyproject.toml, notuv.lock, so an unreviewed major would otherwise reach production on the next build.test.yml's lint step ranruff format --check ., which reaches Python snippets inside seven Markdown docs and fails on all of them. That is whyAll Tests Passedis red on Release 0.8.9: NEMAR assistant on the MCP server #366 today. Scope narrowed tosrc tests, matchingtests.yml.Test
Two mutation checks, because a test that cannot fail is worse than no test.
mcp_client.pyit hung until killed at 75 seconds (timeoutexit 124). With the fix it passes in 2.29 seconds.test_a_refusal_comes_back_as_text_not_an_exceptionasserted only a substring that the fallback path also produces, so deleting theis_errorbranch left it green. It now asserts the distinguishing prefix, and deleting that branch fails it.test_every_prompt_named_tool_actually_existscontainedassert named <= availablewherenamedwas built by filteringavailable, so it could never fail. It now compares an explicit literal set in both directions: tools the prompt names that the server does not serve, and tools the server serves that the prompt never names.Full offline suite: 1872 passed, 32 skipped.
ruff checkandruff format --checkclean.Follow-ups, not in this pull request
The drift tests that would catch NEMAR renaming a tool are
@pytest.mark.network, deselected by both workflows on every pull request, and the post-merge job that runs them iscontinue-on-error: true, so they can never fail a build..context/nemar-api.mdstill documents the deleted endpoint as live.CLAUDE.mdclaims a 70 percent coverage minimum that nothing enforces. Two workflows are both namedTestsand both match every pull request.nemar_render_overviewreturns a PNG that_text_ofdrops and the widget does not render.