perf: open long sessions without re-reading every tool result
A chat page carried every finished tool result, and the app fetched it twice when opening a chat, with a 20 second deadline. On a slow link a long session (this one was ~530 KB per page) timed out. - ask for shelled pages (x-openchamber-part-shells: v1), which drops finished tool results: ~180 KB for the same page - fetch one message by id when its tool row is opened - keep tool and step updates local from events instead of re-reading the page on every step, and only resync after a real disconnect - 60 second deadline with a retry button Bump version to 0.1.11 (build 12).
This commit is contained in:
1 parent
0e34d82a06
commit
e67490e768
8 files changed
+256
-20
No files matched your search
@@ -155,3 +155,40 @@ func TestCertificateFingerprint(t *testing.T) {
|
||||
t.Fatalf("insecure option did not work: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartShellsHeaderAndGetMessage(t *testing.T) {
|
||||
var gotHeader string
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case "/api/session/ses_1/message":
|
||||
gotHeader = r.Header.Get("x-openchamber-part-shells")
|
||||
fmt.Fprint(w, `{"data":[{"id":"msg_1","type":"assistant","content":[
|
||||
{"type":"tool","id":"call_1","name":"shell","state":{"status":"completed","input":{},"content":[],"metadata":{"openchamberContentShell":{}}}}]}],"cursor":{}}`)
|
||||
case "/api/session/ses_1/message/msg_1":
|
||||
fmt.Fprint(w, `{"id":"msg_1","type":"assistant","content":[
|
||||
{"type":"tool","id":"call_1","name":"shell","state":{"status":"completed","input":{},"content":[{"type":"text","text":"full output"}]}}]}`)
|
||||
default:
|
||||
t.Errorf("unexpected path %q", r.URL.Path)
|
||||
}
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
c, _ := New(srv.URL, Options{})
|
||||
page, err := c.ListMessages(context.Background(), "ses_1", ListMessagesOptions{Limit: 10, PartShells: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if gotHeader != "v1" {
|
||||
t.Errorf("header = %q", gotHeader)
|
||||
}
|
||||
if len(page.Data) != 1 || len(page.Data[0].Content[0].State.Content) != 0 {
|
||||
t.Fatalf("page = %+v", page)
|
||||
}
|
||||
msg, err := c.GetMessage(context.Background(), "ses_1", "msg_1", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := msg.Content[0].State.Content[0].Text; got != "full output" {
|
||||
t.Fatalf("message = %+v", msg)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user