Complete the Codex host initialization handshake once

This commit is contained in:
2026-11-05 15:49:44 +00:00
parent 46f85556af
commit 1e886faa41
6 changed files with 62 additions and 9 deletions
+5
View File
@@ -117,6 +117,11 @@ func Serve(ctx context.Context, options Options) error {
if failure := h.initialize["error"]; len(failure) > 0 && string(failure) != "null" {
return errors.New("Codex App Server refused initialization")
}
// Complete the upstream handshake once before accepting Pipelines clients.
// Reattached clients only initialize their downstream connection.
if err := h.write(upstream, message{"method": json.RawMessage(`"initialized"`)}); err != nil {
return fmt.Errorf("complete Codex App Server initialization: %w", err)
}
server := &http.Server{Handler: http.HandlerFunc(h.accept), ReadHeaderTimeout: 5 * time.Second}
defer server.Close()
go func() { <-child.Done(); _ = server.Close() }()