-// layoutFileName is the file of the view layout in the directory of an agent.
-const layoutFileName = "layout.json"
-
-// viewLayout splits the view of a turn request into user messages that only
-// grow between batches. The view goes out as the same messages as in the
-// request before, while their lines give the same text, and the new lines
-// follow as one new message. So the end of the view of each earlier turn stays
-// a message end. On the ChatGPT backend, the first request of a turn with this
-// layout read the view of the turn before from the prompt cache in each of 10
-// turns, and with the view in one message it missed once in 5.
-//
-// The first message starts with "<chat>\n". The closing tag goes into the
-// state message after the view, so that no view message changes when lines
-// come. The layout keeps the line count and a hash of the text of each message
-// in layout.json, so it outlives a restart.
-type viewLayout struct {
- path string
- Messages []layoutMessage `json:"messages"`
-}
-
-// layoutMessage is one view message: its number of lines and the hash of its
-// text.
-type layoutMessage struct {
- Lines int `json:"lines"`
- Hash string `json:"hash"`
-}
-
-// loadLayout reads the layout at path. A missing file gives an empty layout.
-func loadLayout(path string) (*viewLayout, error) {
- layout := &viewLayout{
+// viewLayoutFileName is the file of the view layout in the directory of an
+// agent.
+const viewLayoutFileName = "layout.json"
+
+// loadViewLayout reads the layout at path. A missing file gives an empty
+// layout.
+func loadViewLayout(path string) (*ViewLayout, error) {
+ layout := &ViewLayout{