chat: separate create operation identity

Use an explicit chat_create operation_id as the durable bootstrap key while retaining envelope IDs for reply correlation. Legacy requests receive fresh server-scoped identities, so independent cli-1/android-1 requests do not collide; clients that retry retain one operation_id.

Update Android creation state and repository calls to preserve an operation identity across retries, and cover durable reconnect retries, duplicate barriers, changed input, legacy correlation reuse, and protocol serialization.

Checked packaged templates: none describe chat_create. Checked packaged authoring-skill references: the existing description is stale, but shared references and README must not be edited by an item; docs/notes/bootstrap-create-identity.md records the required docs-fold update and rollout compatibility.
This commit is contained in:
2026-10-18 16:50:12 +01:00
parent 134bd0611a
commit 5946f1abc8
14 changed files with 203 additions and 46 deletions
+8 -4
View File
@@ -172,11 +172,15 @@ type ChatCloseResult struct {
}
// ChatCreateRequest is the chat_create request body: a title and an optional
// working directory (the server's configured location when empty). The response
// carries the created session in Message.ChatSession.
// working directory (the server's configured location when empty). OperationID
// is the durable idempotency key for this create intent; it is deliberately
// separate from Message.ID, which remains connection-local response
// correlation. Clients retrying a create across reconnects must retain it. The
// response carries the created session in Message.ChatSession.
type ChatCreateRequest struct {
Title string `json:"title,omitempty"`
Directory string `json:"directory,omitempty"`
Title string `json:"title,omitempty"`
Directory string `json:"directory,omitempty"`
OperationID string `json:"operation_id,omitempty"`
}
// ChatAdoptRequest is the chat_adopt request body: the id of a session that
+1 -1
View File
@@ -24,7 +24,7 @@ func chatSamples() []struct {
{"session_busy", ChatSession{ID: "ses_2", Title: "held", Busy: true}},
{"session_closed", ChatSession{ID: "ses_3", Title: "done", Closed: true, ClosedAt: 1792112367999}},
{"close_result", ChatCloseResult{SessionID: "ses_3", ClosedAt: 1792112367999, Interrupted: true}},
{"create", ChatCreateRequest{Title: "demo", Directory: "/work"}},
{"create", ChatCreateRequest{Title: "demo", Directory: "/work", OperationID: "create-1"}},
{"adopt", ChatAdoptRequest{SessionID: "ses_1"}},
{"query", ChatQuery{SessionID: "ses_1", Limit: 50}},
{"prompt", ChatPromptRequest{SessionID: "ses_1", Text: "hello", Model: "m", Agent: "build", Files: []string{"file:///tmp/a.png"}, Client: "Pixel 9 Pro XL"}},