Skip to content

Commit 9e44d92

Browse files
rodion-mclaude
andcommitted
Raise fetch_artifacts hard limit from 20 to 50, recommend ≤20 for context
Hard limit increased to 50 to support bulk fetches. Docstring recommends ≤20 to keep agent context size manageable — agents should prefer smaller batches unless they specifically need more. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ff9dc30 commit 9e44d92

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/tests/test_e2e_tools.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,16 +748,17 @@ async def test_empty_identifiers_returns_error(self):
748748
assert "required" in _text(result).lower() or "error" in _text(result).lower()
749749

750750
@pytest.mark.asyncio
751-
async def test_over_20_identifiers_rejected(self):
751+
async def test_over_50_identifiers_rejected(self):
752752
mcp = _server({})
753753
async with Client(mcp) as client:
754754
result = await client.call_tool(
755755
"fetch_artifacts",
756-
{"identifiers": [f"id-{i}" for i in range(21)]},
756+
{"identifiers": [f"id-{i}" for i in range(51)]},
757757
raise_on_error=False,
758758
)
759759

760-
assert "20" in _text(result) or "Maximum" in _text(result)
760+
assert result.is_error
761+
assert "50" in _text(result) or "Maximum" in _text(result)
761762

762763
@pytest.mark.asyncio
763764
async def test_artifact_with_relationships(self):

src/tests/test_fetch_artifacts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ async def test_fetch_artifacts_exceeds_max_identifiers():
435435
"""Test that more than 20 identifiers raises ToolError."""
436436
ctx = MagicMock(spec=Context)
437437

438-
identifiers = [f"owner/repo::file{i}.py::func{i}" for i in range(21)]
438+
identifiers = [f"owner/repo::file{i}.py::func{i}" for i in range(51)]
439439

440-
with pytest.raises(ToolError, match="Maximum 20"):
440+
with pytest.raises(ToolError, match="Maximum 50"):
441441
await fetch_artifacts(ctx=ctx, identifiers=identifiers)
442442

443443

src/tools/fetch_artifacts.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ async def fetch_artifacts(
6363
gives the total. Relationships are omitted for non-function artifacts.
6464
6565
Note:
66-
- Maximum 20 identifiers per request to avoid excessive payloads.
66+
- Hard limit: 50 identifiers per request. Recommended: ≤20 to keep
67+
context size manageable and avoid flooding the conversation with code.
6768
- Identifiers must come from `semantic_search`, `grep_search`, or legacy `codebase_search` results.
6869
- Relationships shown here are a **preview** (up to 3 call relationships per direction).
6970
To retrieve the complete list, or to explore other relationship types
@@ -76,8 +77,8 @@ async def fetch_artifacts(
7677
if not identifiers:
7778
raise ToolError(f"[{_TOOL_NAME}] At least one identifier is required.")
7879

79-
if len(identifiers) > 20:
80-
raise ToolError(f"[{_TOOL_NAME}] Maximum 20 identifiers per request. Please reduce the number of identifiers.")
80+
if len(identifiers) > 50:
81+
raise ToolError(f"[{_TOOL_NAME}] Maximum 50 identifiers per request. Please reduce the number of identifiers.")
8182

8283
context: CodeAliveContext = ctx.request_context.lifespan_context
8384

0 commit comments

Comments
 (0)