Title: [Specification] Reframe sampling as a basis for bidirectional agent-to-agent communication · Issue #503 · modelcontextprotocol/modelcontextprotocol · GitHub
Open Graph Title: [Specification] Reframe sampling as a basis for bidirectional agent-to-agent communication · Issue #503 · modelcontextprotocol/modelcontextprotocol
X Title: [Specification] Reframe sampling as a basis for bidirectional agent-to-agent communication · Issue #503 · modelcontextprotocol/modelcontextprotocol
Description: Is your feature request related to a problem? Please describe. Sampling in its current form is a powerful tool, featuring support for: Preloaded message histories: The server can preload a conversation history in the messages property of...
Open Graph Description: Is your feature request related to a problem? Please describe. Sampling in its current form is a powerful tool, featuring support for: Preloaded message histories: The server can preload a conversa...
X Description: Is your feature request related to a problem? Please describe. Sampling in its current form is a powerful tool, featuring support for: Preloaded message histories: The server can preload a conversa...
Opengraph URL: https://github.com/modelcontextprotocol/modelcontextprotocol/issues/503
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Specification] Reframe sampling as a basis for bidirectional agent-to-agent communication","articleBody":"**Is your feature request related to a problem? Please describe.**\nSampling in its current form is a powerful tool, featuring support for:\n- **Preloaded message histories:** The server can preload a conversation history in the `messages` property of the sampling request, and have the client LLM generate the next message in the conversation. The server can also send new sampling requests with any subset (real or fictional) of a conversation history to induce a given client response (setting context security aside for the moment -- that is important but deserves its own discussion).\n- **Context sharing:** The server can summarize information into the `systemPrompt` property to bootstrap a collaborative task. The server can also suggest a context the client should use when responding, via the undocumented `includeContext` property.\n- **Nested execution:** The server can dispatch sampling requests at any time, such as within an active tool call. Combining tool calls with sampling enables collaborative task execution.\n\nDespite being documented as a solution for agentic behaviors, [sampling](https://modelcontextprotocol.io/specification/2025-03-26/client/sampling) has seen very limited uptake for this purpose, even in toy examples. [Issues](https://github.com/modelcontextprotocol/modelcontextprotocol/issues?q=is%3Aissue%20sampling) and [discussions](https://github.com/modelcontextprotocol/modelcontextprotocol/discussions?discussions_q=sampling) related to sampling are also scarce, and only a small number discuss improvements that can be made for agent communication (honorable mentions: #105, #124, #186). The proposed spec for elicitations (#382) also overlaps significantly with what sampling in its flow, but has a distinctly-different use case (requesting data from a human, bypassing model ambiguity).\n\nI think the understated importance of sampling is the result of several interrelated issues:\n1. **Poorly-documented usage patterns:** I imagine this is at least partially because demonstrating how sampling can actually be used is hard to do in an easily-digestible manner. I tried my hand at a simple two-agent deep sequence diagram and it's 63 lines long (I'll include it in a separate comment). Usage with tools is actually not discussed at all in either the specification or the docs, which is a huge gap when it comes to conceptualizing sampling in general. It's very unintuitive to imagine sampling outside of the context of using it in response to a tool call (even if there may be use cases for this). This is really a microcosm of a broader documentation gap around building end-to-end MCP applications.\n2. **Documentation noise:** A significant portion of the sampling specification and documentation is devoted to clarifying the usage of `modelPreferences`, which is perhaps the least-important aspect of the specification.\n3. **Lack of cohesion with other protocol elements:** Resources and Embedded Resources are not supported as message types.\n4. **Lack of client support:** [Almost zero](https://modelcontextprotocol.io/clients) end-user clients support sampling at all, likely because few servers use it (and servers are unlikely to use it if clients don't support it).\n\n**Describe the solution you'd like**\n1. Update the documentation to offer specific working examples of sampling in at least one SDK.\n2. Update the documentation and the specification to discuss using `messages` and `systemPrompt` for interesting tasks.\n3. Update the documentation and the specification to discuss using sampling with tool calls and other specification features.\n4. Revise the specification to add support for Resources and Embedded Resources in sampling messages.\n5. Revise the specification to define the existing `includeContext` property.\n\n**Describe alternatives you've considered**\n- [A2A](https://google.github.io/A2A/topics/a2a-and-mcp/) and [ACP](https://agentcommunicationprotocol.dev/about/mcp-and-a2a) support agent-to-agent communication with their own mechanisms on top of MCP, and interestingly don't mention sampling in their justifications for standing up new agent-oriented protocols at all -- I don't believe that this was (entirely) for business/product reasons, but rather is a consequence of the how the specification and documentation don't do a good job of framing sampling as a potential solution for that problem.","author":{"url":"https://github.com/LucaButBoring","@type":"Person","name":"LucaButBoring"},"datePublished":"2025-05-09T23:24:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":16},"url":"https://github.com/503/modelcontextprotocol/issues/503"}
| 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:78b6432e-e2fe-ed8d-ee38-0f2cf98ea3a1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD22:7B76D:96A58B:C990B9:6A593A06 |
| html-safe-nonce | 0020e9e2b9ab691dd2bbcfcf905ca2c5b566c55e14b1878a4c0494bbd1f675b9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDIyOjdCNzZEOjk2QTU4QjpDOTkwQjk6NkE1OTNBMDYiLCJ2aXNpdG9yX2lkIjoiMzk3OTU3MDkwOTg4NzkzNzAzMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 81cf98c273a5a59975b51a3d7e0f79ceea3118fece0f981727c4227da4ad8c2e |
| hovercard-subject-tag | issue:3053380213 |
| 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/modelcontextprotocol/modelcontextprotocol/503/issue_layout |
| twitter:image | https://opengraph.githubassets.com/971d7c0a1830f59034d155c6d04ef5666a372750847390d401e3ab9476a08672/modelcontextprotocol/modelcontextprotocol/issues/503 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/971d7c0a1830f59034d155c6d04ef5666a372750847390d401e3ab9476a08672/modelcontextprotocol/modelcontextprotocol/issues/503 |
| og:image:alt | Is your feature request related to a problem? Please describe. Sampling in its current form is a powerful tool, featuring support for: Preloaded message histories: The server can preload a conversa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LucaButBoring |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1b31c9453e1607b2781513084b4770f67217e549834c85b76960d7b13626f7c8 |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/modelcontextprotocol git https://github.com/modelcontextprotocol/modelcontextprotocol.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862570523 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/modelcontextprotocol |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862570523 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/modelcontextprotocol |
| 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 | 220f27779da5b92b5e17fcaef93e474cc8affba3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width