Repository navigation
feat(mcp): forward Router lang_guess through the single-request tools - #797
Merged
Merged
Conversation
The batch surface, laya-serve and the CLI all forward core's soft language hint (lang_guess), but the single-request MCP tools did not: a client scoring one state over MCP could nudge the checkpoint with a probable language only by sending a batch of one. lang_guess is routing-only, so it is treated exactly like task: forwarded to a router call, refused on a pinned model (nothing left to route), and stripped on the direct-agent path (Agent.predict does not accept it). laya_predict, laya_route, laya_shortlist and laya_preset now take it, with validate_lang_guess mirroring validate_lang at the JSON boundary.
Owner
|
Merged for 0.3.23. Verified on the integrated branch, not on the PR in isolation: every suite in the Thank you. |
This was referenced Oct 4, 2026
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.
What
laya_predict,laya_route,laya_shortlistandlaya_presetnow accept and forward core's soft language hint,lang_guess, and the MCP tool schemas / descriptions advertise it. Avalidate_lang_guessis added at the JSON boundary, mirroringvalidate_lang.Why
lang_guessis already reachable from every other surface that routes:laya.mcpbatch tools forward it per request (BATCH_ITEM_OVERRIDESadvertises the key,laya_predict_batch/laya_route_batchhand it toRouter.*_batch),laya.serveforwards it (lang_guessis inBODY_CONTROLS),Only the single-request MCP tools did not, so a client scoring one state over MCP could nudge the checkpoint with a probable-but-uncertain language only by sending a batch of one. This closes that forwarding gap.
lang_guessis routing-only, so it is treated exactly liketask:langand before built-in detection),taskrefusal,Agent.predictdoes not accept the keyword, soRouter.route/predicttake it andAgent.predictdoes not.validate_lang_guesspasses a code string through verbatim and refuses a non-string (including a callable, which core accepts but an MCP client cannot send as JSON).How it was verified
tests/test_mcp.py: 835 passed, 0 failed. A newtest_lang_guess_controlsuite pins: the validator (verbatim codes, non-string/callable refused asinvalid_lang_guess); predict forwards when set / omits when unset / forwards alongsidetask/ keepslangandlang_guessas distinct keywords; predict and route refuse a pinned model +lang_guessbefore touching core; the direct-agent path strips it while keepinglang; shortlist sends it to the route and drops it from the answering pass; preset threads it through; and a cross-surface drift guard assertinglang_guessis inserve.BODY_CONTROLSandBATCH_ITEM_OVERRIDESand accepted byRouter.route/predict.test_controls_signature_and_schemanow also checks the four single tools exposelang_guessas a nullable, defaulted, non-required schema field documented in the description.Checklist
mainNote on overlap
This edits
laya/mcp/tools.pyandlaya/mcp/server.py, which my open #766/#770 (batchhooks_timeout/min_confidence/sort_by_length) also touch, at different lines and for different controls — orthogonal, but a rebase may be needed depending on merge order. Related umbrella: #489.