Files
Agent-System/internal/agentx/session/jsonl_test.go
T
weichen fd1b676e28 feat(agentx): add the turn loop and JSONL transcripts
Persist each message as it happens and keep going after a tool failure, including steering and follow-up messages between turns.
2026-09-21 14:53:09 +00:00

39 lines
823 B
Go

package session
import (
"path/filepath"
"testing"
"chat-agent-system/internal/agentx/llm"
)
func TestAppendAndReplay(t *testing.T) {
path := filepath.Join(t.TempDir(), "transcript.jsonl")
st, err := Open(path)
if err != nil {
t.Fatal(err)
}
msgs := []llm.Message{
{Role: llm.RoleSystem, Content: "sys"},
{Role: llm.RoleUser, Content: "hi"},
{Role: llm.RoleAssistant, Content: "ok", StopReason: llm.StopEnd},
}
for _, m := range msgs {
if err := st.Append(m); err != nil {
t.Fatal(err)
}
}
got, err := st.Load()
if err != nil {
t.Fatal(err)
}
if len(got) != len(msgs) {
t.Fatalf("len %d", len(got))
}
for i := range msgs {
if got[i].Role != msgs[i].Role || got[i].Content != msgs[i].Content || got[i].StopReason != msgs[i].StopReason {
t.Fatalf("msg %d %#v", i, got[i])
}
}
}