Skip to content

fix: Keep room for an active bean candidate beside the inactive sample and revise bean pages on the condition toggle (#634) - #693

Merged
imuromtsev merged 4 commits into
mainfrom
imuromtsev/bean-sample-budget
Oct 14, 2026
Merged

imuromtsev merged 4 commits into
mainfrom
imuromtsev/bean-sample-budget

Conversation

@imuromtsev

Copy link
Copy Markdown
Collaborator

Purpose

Two gaps in the bounded bean MCP tools (#634):

  • explyt_find_spring_bean wrote the inactiveCandidates sample before the page and gave it up to half of maxChars. A small budget then had no room left for even one active candidate and answered RESPONSE_TOO_LARGE, and the maxChars that answer named still included the sample, so a retry with it failed again.
  • The revision of a static bean answer did not include the bean condition evaluation setting, so a continuation taken across a toggle of the setting mixed pages computed with and without conditions.

Change

  • BoundedPageWriter.fitSample can reserve room for the first page item: the sample keeps only what still lets that item fit, down to none with the truncated flag. Without a first item (the nearestByPrefix sample of the endpoint tools, whose miss page has no items) the reserve is zero, so the endpoint tools answer as before.
  • BoundedBeanResponseWriter uses fitSample instead of its own loop; the sample stays capped at 3 entries and at half of maxChars. When no sample entry fits, inactiveCandidates is left out, inactiveCandidatesTruncated: true is set and inactiveCount is kept. The RESPONSE_TOO_LARGE hint names the maxChars that serves the first active candidate.
  • BeanSnapshotService.modelStampOf adds the condition evaluation setting to the stamp of static selections, so a continuation after a toggle answers RESULT_CHANGED. Selections from a recorded native context are unchanged.

Measurement (item 3)

On the test fixture at the default budget, a sample of 2 inactive candidates costs 910 chars and moves 3 of 5 active candidates to later pages (shortest candidate 180 chars, page 1647 chars). A guard test keeps the displacement within what the sample's own length explains.

Not in this PR

Item 1: beans inactive by @Profile are filtered before the snapshot and never appear as inactive candidates.

Verification

  • Red commit 000df74: 6 reds (3 unit tests of the bean writer, a fixture test with a small budget, the toggle revision in explyt_find_spring_bean and explyt_get_spring_beans), each failing on its assertion; one green guard for item 3.
  • Red commit eb0a1bb (review follow-up): the sample must stay within half of maxChars even when it fits beside the first candidate (811 chars of a 1372 budget failed).
  • After the fixes f45c970 and 504506c: BoundedBeanResponseWriterTest 14/14, SpringBeanMcpConditionVerdictTest 27/27, BeanListingConditionTest 17/17, endpoint page and lookup tests 13/13 and 16/16, BeanSnapshotServiceTest 12/12.
  • All modules on f45c970 (:spring-bootstrap:test --rerun-tasks, fresh JUnit XML): spring-core 2387, spring-web 905 (6 skipped), spring-ai 783, jpa 138, spring-data 140, base 35, aop 6, security 6, initializr 5; 0 failures, 0 errors.
  • :spring-ai:test on 504506c (the half-cap delta touches spring-ai only): 784 tests; one Exodus teardown failure ("Finish all transactions before closing database environment") in SpringBootApplicationMcpToolsetServiceCallsTest, which passed 25/25 when rerun alone (known flake).

Main only: BoundedPageWriter, BoundedBeanResponseWriter and BeanSnapshotService are not on the release branches.

Refs #634

@imuromtsev imuromtsev added the spring-mcp-tools Explyt MCP tools (explyt_*); need JetBrains MCP Server, IDEA 2025.2+ label Oct 13, 2026
@github-actions

Copy link
Copy Markdown
TestsPassed ✅Skipped ⚠️Failed
JUnit Test Report4406 ran4400 passed6 skipped0 failed

@imuromtsev
imuromtsev merged commit f5add43 into main Oct 14, 2026
2 checks passed
@imuromtsev
imuromtsev deleted the imuromtsev/bean-sample-budget branch October 14, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spring-mcp-tools Explyt MCP tools (explyt_*); need JetBrains MCP Server, IDEA 2025.2+

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant