perf(copilot): reduce tool output truncation from 500K to 100K chars

500K chars (~125K tokens) per tool result was too generous — a few
large tool outputs could push context past 200K+ tokens. 100K chars
(~25K tokens) keeps individual results reasonable. The SDK writes
oversized results to tool-results/ files and returns a reference.
This commit is contained in:
majdyz
2026-04-13 12:24:35 +00:00
parent ac054c31f6
commit 7d16258a98

View File

@@ -63,8 +63,10 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
# Max MCP response size in chars — keeps tool output under the SDK's 10 MB JSON buffer.
_MCP_MAX_CHARS = 500_000
# Max MCP response size in chars. Lower = smaller context = cheaper.
# 100K chars ≈ 25K tokens. The SDK writes oversized results to
# tool-results/ files and returns a file reference instead.
_MCP_MAX_CHARS = 100_000
# MCP server naming - the SDK prefixes tool names as "mcp__{server_name}__{tool}"
MCP_SERVER_NAME = "copilot"