DEV-1372: MCP query tool accepts inline source_model#109
Conversation
…nsion | SlayerModel)
Previously typed `str`, which forced agents to JSON-encode dicts; SLayer
then validated the JSON blob as a name and rejected with `Invalid model
name '{...}'`. The signature now matches `SlayerQuery.source_model`'s
native polymorphism, so FastMCP exposes both shapes in the tool schema.
The run-by-name shortcut stays — it applies `model.query_variables` as
the lowest precedence layer, which the regular `SlayerQuery` path
doesn't (see DEV-1373). Gated on `isinstance(source_model, str)` so
inline values fall through to `SlayerQuery.model_validate`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR expands the MCP ChangesPolymorphic source_model Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
slayer/mcp/server.py (1)
1055-1056: ⚡ Quick winUse
query=keyword argument in theengine.execute()call.Line 1055–1056 passes
model_nameas a positional argument, violating the repository guideline for multi-parameter functions. Theexecute()method signature defines the first parameter asquery, and all other call sites in this file consistently usequery=explicitly.Change:
result = await engine.execute( model_name,To:
result = await engine.execute( query=model_name,🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@slayer/mcp/server.py` around lines 1055 - 1056, The call to engine.execute is passing model_name positionally; change it to use the query= keyword so it matches the execute(query, ...) signature and the project's convention. Locate the engine.execute(...) invocation around the result = await engine.execute( model_name, and replace the positional model_name argument with query=model_name, leaving other arguments unchanged to preserve call semantics.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@slayer/mcp/server.py`:
- Around line 1055-1056: The call to engine.execute is passing model_name
positionally; change it to use the query= keyword so it matches the
execute(query, ...) signature and the project's convention. Locate the
engine.execute(...) invocation around the result = await engine.execute(
model_name, and replace the positional model_name argument with
query=model_name, leaving other arguments unchanged to preserve call semantics.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b767181d-0102-48d1-82bd-749c1d0ad3ba
📒 Files selected for processing (4)
docs/interfaces/mcp.mddocs/reference/mcp.mdslayer/mcp/server.pytests/test_mcp_server.py
…xecute Use keyword argument on the run-by-name shortcut's engine.execute call to match every other call site in this file and the user's global rule for multi-parameter functions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|



Summary
querytool'ssource_modelparameter now typedstr | ModelExtension | SlayerModel, matchingSlayerQuery.source_model's native polymorphism. Previously typedstr, which forced agents to JSON-encode inline dicts — SLayer then validated the JSON blob as a name and rejected it withInvalid model name '{...}': must not contain '/'. Wire-level evidence (Haiku 4.5, households_1): 15 / 88 query-tool calls (17 %) on a single 15-task run failed this way.engine.execute(str)) preserved — it layersmodel.query_variables → stage → runtimeprecedence that the regularSlayerQuerypath doesn't reach. Gated onisinstance(source_model, str)so inline values fall through toSlayerQuery.model_validate. The variable-precedence asymmetry that forces this gate is filed separately as DEV-1373.docs/reference/mcp.mdanddocs/interfaces/mcp.md.Test plan
tests/test_mcp_server.py::TestQueryAcceptsInlineSourceModel— three new tests covering string regression, inlineModelExtensiondict, inlineSlayerModeldictpoetry run pytest -m "not integration"— 2173 passedpoetry run ruff check slayer/ tests/— cleanCloses DEV-1372.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
querytool now accepts inline model definitions and extensions for thesource_modelparameter, in addition to saved model names.Documentation
source_modeloptions.Tests
queryaccepts string, inline extension, and inline model payloads.