Title: Non-interactive mode: late-connecting MCP server injects empty user message; model echoes system-prompt tool lists instead of answering · Issue #4038 · github/copilot-cli · GitHub
Open Graph Title: Non-interactive mode: late-connecting MCP server injects empty user message; model echoes system-prompt tool lists instead of answering · Issue #4038 · github/copilot-cli
X Title: Non-interactive mode: late-connecting MCP server injects empty user message; model echoes system-prompt tool lists instead of answering · Issue #4038 · github/copilot-cli
Description: Describe the bug Run copilot -p "..." with an MCP server that exposes 7 or more tools. The CLI appends an empty user message right after the real prompt. The model then answers the empty turn instead of the prompt. In several of my sessi...
Open Graph Description: Describe the bug Run copilot -p "..." with an MCP server that exposes 7 or more tools. The CLI appends an empty user message right after the real prompt. The model then answers the empty turn inste...
X Description: Describe the bug Run copilot -p "..." with an MCP server that exposes 7 or more tools. The CLI appends an empty user message right after the real prompt. The model then answers the empty ...
Opengraph URL: https://github.com/github/copilot-cli/issues/4038
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Non-interactive mode: late-connecting MCP server injects empty user message; model echoes system-prompt tool lists instead of answering","articleBody":"### Describe the bug\n\nRun `copilot -p \"...\"` with an MCP server that exposes **7 or more tools**. The CLI appends an empty user message right after the real prompt. The model then answers the empty turn instead of the prompt. In several of my sessions it echoed fragments of its own system prompt (the deferred-tools listings), starting mid-word.\n\nI bisected the trigger with a minimal stdio MCP server (script below): identical runs with the tool count as the only variable.\n\n| tools exposed | user.message events | result |\n|---|---|---|\n| 2 | 1 | correct answer |\n| 5 | 1 | correct answer |\n| 6 | 1 | correct answer |\n| 7 | 2 (second empty) | bug |\n| 8, 10, 17, 25 | 2 (second empty) | bug |\n\nThe 6→7 boundary suggests the tool-deferral mechanism (large tool sets moved to on-demand loading) injects the empty turn. Slow server startup is not required; a server that responds instantly triggers it too.\n\nEvidence from `~/.copilot/session-state/\u003cid\u003e/events.jsonl`, two `user.message` events 130 ms apart, the second one empty:\n\n```\n16:41:22.133 user.message len=24 :: 'Reply with exactly: PONG'\n16:41:22.263 user.message len=0 :: ''\n16:41:34.591 assistant.message len=1624 :: '-quality-feedback MCP server. Tools prefixed with `model-quality-`:\\n- report_model_quality_issue...'\n```\n\nThe assistant reply starts mid-word (`-quality-feedback MCP server...`): it echoes the deferred-tools listing from the system prompt rather than answering. The garbage echo does not happen on every run; with a small 25-tool dummy the model sometimes still answered `PONG` despite the empty turn. The empty extra turn appears on 100% of runs at ≥7 tools. Any script or subagent built on `copilot -p` risks corrupted output.\n\n### Affected version\n\n1.0.68 (macOS, Darwin arm64)\n\n### Steps to reproduce the behavior\n\n1. Save this minimal MCP server as `/tmp/slowmcp.py`:\n\n```python\n#!/usr/bin/env python3\nimport json, sys\n\nTOOLS = [{\"name\": f\"dummy_tool_{i}\", \"description\": f\"dummy tool number {i}\",\n \"inputSchema\": {\"type\": \"object\", \"properties\": {\"text\": {\"type\": \"string\"}}}}\n for i in range(7)] # 7 = minimum that triggers; 6 does not\n\nfor line in sys.stdin:\n try:\n req = json.loads(line)\n except json.JSONDecodeError:\n continue\n rid, method = req.get(\"id\"), req.get(\"method\", \"\")\n if method == \"initialize\":\n resp = {\"jsonrpc\": \"2.0\", \"id\": rid, \"result\": {\n \"protocolVersion\": \"2025-11-25\",\n \"capabilities\": {\"tools\": {}},\n \"serverInfo\": {\"name\": \"slowdummy-mcp\", \"version\": \"2.0.0\"}}}\n elif method == \"tools/list\":\n resp = {\"jsonrpc\": \"2.0\", \"id\": rid, \"result\": {\"tools\": TOOLS}}\n elif rid is not None:\n resp = {\"jsonrpc\": \"2.0\", \"id\": rid, \"result\": {}}\n else:\n continue\n sys.stdout.write(json.dumps(resp) + \"\\n\")\n sys.stdout.flush()\n```\n\n2. Point `~/.copilot/mcp-config.json` at it:\n\n```json\n{\"mcpServers\": {\"slowdummy\": {\"type\": \"stdio\", \"command\": \"python3\", \"args\": [\"/tmp/slowmcp.py\"], \"tools\": [\"*\"]}}}\n```\n\n3. Run `copilot -p 'Reply with exactly: PONG'`\n4. Inspect `~/.copilot/session-state/\u003csession\u003e/events.jsonl`: two `user.message` events, the second with empty content. Change `range(7)` to `range(6)` and rerun: one `user.message`, correct answer.\n\n### Expected behavior\n\nThe model answers the prompt (`PONG`). The session log contains exactly one `user.message` event, regardless of how many tools the configured MCP servers expose.\n\n### Actual behavior\n\nWith ≥7 tools on one MCP server, the CLI appends a second, empty `user.message` 100-200 ms after the prompt. The model responds to the empty turn; on some runs it echoes system-prompt tool listings starting mid-word instead of answering.\n\n### Additional context\n\n- Ruled out via the same bisection setup: slow startup (3 s delayed handshake: no bug), `notifications/tools/list_changed` after the prompt (no bug), `instructions` in the initialize result (no bug), full capability set including prompts/resources/completions/logging (no bug). Tool count is the single deciding variable.\n- First seen with `notebooklm-mcp` (about 20 tools); reproduced with the dummy above to remove third-party code from the equation.\n- Workaround: keep every MCP server at 6 or fewer exposed tools via the `tools` allowlist in `mcp-config.json`.\n- I can share full redacted `events.jsonl` excerpts from the bisection runs if useful.\n","author":{"url":"https://github.com/marcelsafin","@type":"Person","name":"marcelsafin"},"datePublished":"2026-07-06T16:42:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/4038/copilot-cli/issues/4038"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cfe8ca61-7e31-b017-a2a5-83de92b65d6c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C78C:147A05:C968DE:1107D2D:6A4EFC00 |
| html-safe-nonce | 0178b7135900b3594b90fb14ef0e5384dcadd7175185844eb484c303d89dfcec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzhDOjE0N0EwNTpDOTY4REU6MTEwN0QyRDo2QTRFRkMwMCIsInZpc2l0b3JfaWQiOiI3MzYyMjU1MjU3Nzg5NzI1Njk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c66f1b30f1ec07d20335302e0b1f14d7b60dfc1bd5da7c7cd68e9a58167bff36 |
| hovercard-subject-tag | issue:4821210016 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/copilot-cli/4038/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5864d6b5f6dec297ebb39a9a78303a73689c05a818c4ab45e94f3c1b0e4c1d4d/github/copilot-cli/issues/4038 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5864d6b5f6dec297ebb39a9a78303a73689c05a818c4ab45e94f3c1b0e4c1d4d/github/copilot-cli/issues/4038 |
| og:image:alt | Describe the bug Run copilot -p "..." with an MCP server that exposes 7 or more tools. The CLI appends an empty user message right after the real prompt. The model then answers the empty turn inste... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | marcelsafin |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/github/copilot-cli git https://github.com/github/copilot-cli.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 585860664 |
| octolytics-dimension-repository_nwo | github/copilot-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 585860664 |
| octolytics-dimension-repository_network_root_nwo | github/copilot-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b8f23afb982271f1b22258a94aede67a6b77760 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width