Conversation
docs/rfds/next-edit-suggestions.mdx
Outdated
|
|
||
| ### Session lifecycle | ||
|
|
||
| If the `nes` capability is present, the client may call `nes/start` to begin an NES session. The agent can also use the existing `configOptions` mechanism to expose NES-related settings (model selection, debounce preferences, enabled/disabled state, etc.). |
There was a problem hiding this comment.
Better to clarify how to handle Auth.
End user may not open the Agent Chat panel during an IDE session. User may have not login yet, and just start type in editor area and want to get NES feature.
Just like session/new, nes/start need to check whether auth is required, and retrun auth_required error.
Auth could be shared — authenticate once, use for both NES and Chat
There was a problem hiding this comment.
User may have not login yet, and just start type in editor area and want to get NES feature.
I think that from the protocol perspective we can handle auth the same way — auth_required will be thrown if user should authenticate first. Then it would be a UX question for the client how it wants to handle it — either by showing a login dialog during setup, or via popup or some other way
benbrandt
left a comment
There was a problem hiding this comment.
Our Edit Prediction folks thought this looked good!
One question came up: Some of these events / context might also be useful outside of the edit prediction case (events around file edits for example might be useful to a coding agent)
Not sure what you think about that, but it might be interesting to see which of these would be NES specific and which might be more generally useful (if the agent opts-in)
It's funny that I've just discussed the same thing with a colleague yesterday, that it would be nice to inform the agent that a file that agent has read before has changed. Should we maybe change the names for the "nes/didChange", "nes/didFocus" for something more generic, like "editor/didChange" ? Then we'll be able to allow this methods not only in nes sessions in the future |
|
nice rfd. I see the client already announces NES capabilities during initialize with ideActions — that's the right approach. just want to reinforce that this should be the hard gate for the entire NES surface. if client doesn't announce NES support, agent should not send anything NES related — no events, no suggestions, nothing. zero noise on the stream. there's a growing category of ACP clients that don't do keystroke typing at all. tools like fabriqa and toad are ACP clients where the ai manages files directly, no editor, no cursor. autonomous agentic orchestrators are also increasingly using ACP. these clients will never need NES and shouldn't have to deal with ignoring messages they didn't ask for. NES makes total sense for IDEs and text editors like zed and jetbrains. just make sure client-side capability announcement is the single source of truth for whether NES is active or not. |
| ```json | ||
| { | ||
| "capabilities": { | ||
| "nes": { |
There was a problem hiding this comment.
Ok nitpick, but I keep thinking about nintendo when I see nes... maybe I'm just old 😜
I wonder if we could use the namespace next_edit or something? Downside is we usually do snake case next_edit/* in methods and it would be nextEdit in capabilities, but I guess that is consistent with other methods so it is fine.
Doesn't have to be a blocker, but after several days it still throws me off haha
There was a problem hiding this comment.
There was no Nintendos in my childhood =) so I don't have this association. If you feel we should switch to next_edit — we can do that
| ```json | ||
| { | ||
| "capabilities": { | ||
| "nes": { |
There was a problem hiding this comment.
Do you think these would be better top-level as well?
There was a problem hiding this comment.
the ide actions? But maybe they are somehow NES specific?
|
|
||
| ### Position encoding | ||
|
|
||
| All `Position` objects in NES use zero-based line and zero-based character offsets, following the same conventions as [LSP 3.17](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position). The meaning of the `character` offset depends on the negotiated **position encoding**. |
There was a problem hiding this comment.
Note: One thing we'll need to be careful of is so far all line numbers have been 1-based in the protocol
|
|
||
| Three encoding kinds are supported: | ||
|
|
||
| - `"utf-16"` — character offsets count UTF-16 code units. This is the **default** and must be supported by all clients and agents. |
There was a problem hiding this comment.
Another difference as far as I know. I think this is a difference between LSP and the other protocols.
I assume this is just in terms of the position units though and shouldn't affect the fact the the protocol requires all json-rpc messages to be utf-8 encoded?
There was a problem hiding this comment.
yes, it's only for positions. I've talked to the team that does NES in JetBrains and they claimed it's super-important thing to support — they've encountered some related problems already
There was a problem hiding this comment.
Ok as long as we don't have to change the encoding of messages I think this is ok
| { | ||
| "capabilities": { | ||
| "nes": { ... }, | ||
| "positionEncoding": "utf-32" |
There was a problem hiding this comment.
So this basically captures the "decision" of what both sides should use?
we could I guess also add this to the position type itself but it might be noisy. I guess we can keep an eye on it during implementation.
There was a problem hiding this comment.
Here I wanted to keep it similar to lsp spec
| "uri": "file:///path/to/file.rs", | ||
| "languageId": "rust", | ||
| "version": 1, | ||
| "text": "fn main() {\n println!(\"hello\");\n}\n" |
There was a problem hiding this comment.
I guess all of these will still always be utf-8 encoded?
| - `"replaced"` — the suggestion was superseded by a newer suggestion before the user could act on it. | ||
| - `"cancelled"` — the request was cancelled before the agent returned a response (e.g. the user typed quickly and the previous request became stale). | ||
|
|
||
| The `reason` field is optional. If omitted, the agent should treat it as `"rejected"`. Providing granular reasons allows agents to improve their models — for example, a `"replaced"` suggestion carries different training signal than an explicit `"rejected"`. |
There was a problem hiding this comment.
Is there a reason to have the default be "rejected"?
There was a problem hiding this comment.
no, not really, what do you think the default should be? Or do you want to make the field mandatory?
There was a problem hiding this comment.
Hmm I guess it just is weird that we default to the one that has strong user intent vs a more passive one, but I'm not familiar with how others handle this
| Parameters: | ||
|
|
||
| - `uri` (`string`) — the file URI containing the symbol. | ||
| - `position` (`Position`) — the position of the symbol to rename. |
There was a problem hiding this comment.
this would be a potential reason not to expose this method outside of NES context, since it is tied to this Position type.
Though maybe it still works if we have a good story about these different utf encodings or allow for the position to have a type of the encoding it maps to
Elevator pitch
Add a Next Edit Suggestion (NES) capability to ACP, allowing agents to provide predictive code edits. The protocol is designed around capability negotiation: agents declare what events and context they can consume, and clients provide only what was requested.
Status quo
ACP currently has no mechanism for agents to provide inline edit predictions. Each client–agent pair implements NES through proprietary protocols.
What we propose to do about it
Introduce a
nescapability that agents advertise during initialization. The capability declares:The client inspects these declarations and provides only what was requested, minimizing overhead for simple agents while allowing rich context for advanced ones.
Capability advertisement
During
initialize, the agent includes anesfield in its capabilities:{ "capabilities": { "nes": { "events": { "didOpen": {}, "didChange": { "syncKind": "incremental" }, "didClose": {}, "didSave": {}, "didFocus": {} }, "context": { "recentFiles": { "maxCount": 10 }, "relatedSnippets": {}, "editHistory": { "maxCount": 6 }, "userActions": { "maxCount": 16 }, "openFiles": {}, "diagnostics": {} } } } }All fields under
eventsandcontextare optional — an agent advertises only what it can use.Client capabilities
The client advertises its own NES-related capabilities in the
initializerequest. Currently, the client can declare which well-known IDE actions it supports by listing their IDs. The agent reads these and may later include"action"kind suggestions that reference them.{ "capabilities": { "nes": { "ideActions": { "rename": {}, "searchAndReplace": {} } } } }Each entry in
ideActionsis the ID of a well-known action (see Well-known IDE actions below). Agents should only suggest actions that the client has advertised.Session lifecycle
If the
nescapability is present, the client may callnes/startto begin an NES session. The agent can also use the existingconfigOptionsmechanism to expose NES-related settings (model selection, debounce preferences, enabled/disabled state, etc.).Implementation details and plan
Events
Events are fire-and-forget notifications from client to agent. The client sends them only if the corresponding key is present in
nes.events.nes/didOpenSent when a file is opened in the editor.
{ "jsonrpc": "2.0", "method": "nes/didOpen", "params": { "uri": "file:///path/to/file.rs", "languageId": "rust", "version": 1, "text": "fn main() {\n println!(\"hello\");\n}\n" } }nes/didChangeSent when a file is edited. Supports two sync modes declared by the agent:
"full"— client sends entire file content each time."incremental"— client sends only the changed ranges.Incremental:
{ "jsonrpc": "2.0", "method": "nes/didChange", "params": { "uri": "file:///path/to/file.rs", "version": 2, "contentChanges": [ { "range": { "start": { "line": 1, "character": 4 }, "end": { "line": 1, "character": 4 } }, "text": "let x = 42;\n " } ] } }Full:
{ "jsonrpc": "2.0", "method": "nes/didChange", "params": { "uri": "file:///path/to/file.rs", "version": 2, "contentChanges": [ { "text": "fn main() {\n let x = 42;\n println!(\"hello\");\n}\n" } ] } }nes/didCloseSent when a file is closed.
{ "jsonrpc": "2.0", "method": "nes/didClose", "params": { "uri": "file:///path/to/file.rs" } }nes/didSaveSent when a file is saved.
{ "jsonrpc": "2.0", "method": "nes/didSave", "params": { "uri": "file:///path/to/file.rs" } }nes/didFocusSent when a file becomes the active editor tab. Unlike
nes/didOpen(which fires once when a file is first opened),nes/didFocusfires every time the user switches to a file, including files that are already open. This is the primary trigger for agents that need to refresh context on tab switch (e.g. re-indexing relevant code snippets).{ "jsonrpc": "2.0", "method": "nes/didFocus", "params": { "uri": "file:///path/to/file.rs", "version": 2, "position": { "line": 5, "character": 12 }, "visibleRange": { "start": { "line": 0, "character": 0 }, "end": { "line": 45, "character": 0 } } } }The
positionis the current cursor position. ThevisibleRangeis the portion of the file currently visible in the editor viewport.Suggestion request
The client requests a suggestion by calling
nes/suggest. Context fields are included only if the agent declared interest in the correspondingnes.contextkey.{ "jsonrpc": "2.0", "id": 42, "method": "nes/suggest", "params": { "uri": "file:///path/to/file.rs", "version": 2, "position": { "line": 5, "character": 12 }, "selection": { "start": { "line": 5, "character": 4 }, "end": { "line": 5, "character": 12 } }, "triggerKind": "automatic", "context": { "recentFiles": [ { "uri": "file:///path/to/utils.rs", "languageId": "rust", "text": "pub fn helper() -> i32 { 42 }\n" } ], "relatedSnippets": [ { "uri": "file:///path/to/types.rs", "excerpts": [ { "startLine": 10, "endLine": 25, "text": "pub struct Config {\n pub name: String,\n ...\n}" } ] } ], "editHistory": [ { "uri": "file:///path/to/file.rs", "diff": "--- a/file.rs\n+++ b/file.rs\n@@ -3,0 +3,1 @@\n+ let x = 42;" } ], "userActions": [ { "action": "insertChar", "uri": "file:///path/to/file.rs", "line": 5, "offset": 12, "timestampMs": 1719400000000 }, { "action": "cursorMovement", "uri": "file:///path/to/file.rs", "line": 10, "offset": 0, "timestampMs": 1719400001200 } ], "openFiles": [ { "uri": "file:///path/to/utils.rs", "languageId": "rust", "visibleRange": { "start": { "line": 0, "character": 0 }, "end": { "line": 30, "character": 0 } }, "lastFocusedMs": 1719399998000 }, { "uri": "file:///path/to/types.rs", "languageId": "rust", "visibleRange": null, "lastFocusedMs": 1719399990000 } ], "diagnostics": [ { "uri": "file:///path/to/file.rs", "range": { "start": { "line": 5, "character": 0 }, "end": { "line": 5, "character": 10 } }, "severity": "error", "message": "cannot find value `foo` in this scope" } ] } } }selectionis the current text selection range, if any. When the selection is empty (cursor is a point), this field may be omitted or havestartequal toend. Agents can use selection state to predict replacements or transformations of the selected text.triggerKindis one of:"automatic"— triggered by user typing or cursor movement"diagnostic"— triggered by a diagnostic (error/warning) appearing at or near the cursor position. The client includes the relevant diagnostics in thediagnosticscontext field so the agent can target a fix."manual"— triggered by explicit user action (keyboard shortcut)Suggestion response
A suggestion is one of three kinds: an edit (text changes), a jump (navigate to a different file), or an action (trigger an IDE action).
Edit suggestion:
{ "jsonrpc": "2.0", "id": 42, "result": { "suggestions": [ { "id": "sugg_001", "kind": "edit", "uri": "file:///path/to/other_file.rs", "edits": [ { "range": { "start": { "line": 5, "character": 0 }, "end": { "line": 5, "character": 10 } }, "newText": "let result = helper();" } ], "cursorPosition": { "line": 5, "character": 22 } } ] } }Jump suggestion:
{ "jsonrpc": "2.0", "id": 42, "result": { "suggestions": [ { "id": "sugg_002", "kind": "jump", "uri": "file:///path/to/other_file.rs", "position": { "line": 15, "character": 4 } } ] } }Action suggestion:
{ "jsonrpc": "2.0", "id": 42, "result": { "suggestions": [ { "id": "sugg_003", "kind": "action", "actionId": "rename", "arguments": { "uri": "file:///path/to/file.rs", "position": { "line": 5, "character": 10 }, "newName": "calculateTotal" } } ] } }Action suggestions reference an IDE action that the client previously advertised in its capabilities:
actionId— matches anidfrom the client's advertisedideActions.arguments— matches the parameter schema declared by the client for that action.A response may contain a mix of edit, jump, and action suggestions. The client decides how to present them (e.g. inline ghost text for edits, a navigation hint for jumps).
Each suggestion contains:
id— unique identifier for accept/reject tracking.kind—"edit","jump", or"action".Edit suggestions additionally contain:
edits— one or more text edits to apply.cursorPosition— optional suggested cursor position after applying edits.Jump suggestions additionally contain:
uri— the file to navigate to.position— the target position within that file.Action suggestions additionally contain:
actionId— the IDE action to perform (must match a client-advertised actionid).arguments— action parameters matching the schema from the client's capability.Accept / Reject
{ "jsonrpc": "2.0", "method": "nes/accept", "params": { "id": "sugg_001" } }{ "jsonrpc": "2.0", "method": "nes/reject", "params": { "id": "sugg_001", "reason": "rejected" } }reasonis one of:"rejected"— the user explicitly dismissed the suggestion (e.g. pressed Escape or typed something incompatible)."ignored"— the suggestion was shown but the user continued editing without interacting with it, and the context changed enough to invalidate it."replaced"— the suggestion was superseded by a newer suggestion before the user could act on it."cancelled"— the request was cancelled before the agent returned a response (e.g. the user typed quickly and the previous request became stale).The
reasonfield is optional. If omitted, the agent should treat it as"rejected". Providing granular reasons allows agents to improve their models — for example, a"replaced"suggestion carries different training signal than an explicit"rejected".NES session start
The client provides workspace metadata when starting a session. This information is static for the lifetime of the session.
{ "jsonrpc": "2.0", "id": 1, "method": "nes/start", "params": { "workspaceUri": "file:///Users/alice/projects/my-app", "workspaceFolders": [ { "uri": "file:///Users/alice/projects/my-app", "name": "my-app" } ], "repository": { "name": "my-app", "owner": "alice", "remoteUrl": "https://github.com/alice/my-app.git" } } }All fields in
paramsare optional. Therepositoryfield is omitted if the workspace is not a git repository or the info is unavailable.Response:
{ "jsonrpc": "2.0", "id": 1, "result": { "sessionId": "nes_abc123" } }Well-known IDE actions
The following actions are well-known and have standardized parameter schemas. Clients that support these actions should use the IDs and parameter shapes defined here.
rename— Rename a symbol across the workspace.Parameters:
uri(string) — the file URI containing the symbol.position(Position) — the position of the symbol to rename.newName(string) — the new name for the symbol.searchAndReplace— Search and replace text within a file.Parameters:
uri(string) — the file URI to search within.search(string) — the text or pattern to find.replace(string) — the replacement text.isRegex(boolean, optional) — whethersearchis a regular expression. Defaults tofalse.Additional well-known actions may be added to the protocol in the future. Agents should only suggest actions whose
idmatches an entry the client has advertised.Config options
The agent can use the existing
configOptionsmechanism from ACP to expose NES-related settings. For example, an agent might return config options like:{ "configOptions": [ { "id": "nes_model", "name": "Prediction Model", "category": "model", "type": "enum", "currentValue": "fast", "options": [ { "value": "fast", "label": "Fast" }, { "value": "accurate", "label": "Accurate" } ] } ] }Frequently asked questions
Why separate events from context?
Events and context serve different purposes and have different delivery models:
A note about Cursor: Cursor has a separate context-collection phase (
RefreshTabContext) that involves vector DB lookup and is triggered on file open, tab switch, and significant edits. The event-based approach supports this flow: an NES agent can listen fornes/didOpen,nes/didFocus, and accumulatednes/didChangeevents to self-trigger its own context refresh. Thenes/didFocusevent (with cursor position and visible range) and workspace metadata fromnes/startprovide all the inputs Cursor'sRefreshTabContextneeds.An agent may want both (events for incremental file tracking + context for edit history), or just one. The capability split lets each agent pick the model that fits its architecture.
Why not reuse LSP's
textDocument/didOpenetc. directly?LSP's document sync notifications carry the same information, but:
nes/makes capability negotiation cleaner.How does this relate to PR #325?
This RFD covers the session lifecycle and also suggests a protocol that would cover a variety of different nes providers
Why provide workspace info in
nes/start?Agents that perform server-side indexing (embedding-based retrieval, semantic search) need to know which repository they're working with. This metadata — workspace root, repo name/owner, remote URL — is static for the session lifetime, so it belongs in the session start rather than being repeated on every request or requiring a separate query.
What alternative approaches did you consider?
nes/suggestrequest, with no event notifications. This is simpler for stateless agents but forces the client to assemble and transmit potentially large payloads on every request, even when nothing changed. It also prevents agents from maintaining their own incremental state (e.g. an internal file mirror or semantic index).didOpen,didChange, etc.) and have the agent maintain all state internally, withnes/suggestsending only the cursor position. This is efficient on the wire but requires every agent to implement stateful document tracking, which is a high barrier for simple agents that just want the code around the cursor.Revision history