(t *testing.T)
| 176 | } |
| 177 | |
| 178 | func TestController_Exec_LastSeq(t *testing.T) { |
| 179 | ctx := context.Background() |
| 180 | cid := "test-conv-seq" |
| 181 | |
| 182 | log := &executortest.MemoryEventLog{} |
| 183 | // Pre-populate history |
| 184 | log.AllEvents = []*proto.ConversationEvent{ |
| 185 | { |
| 186 | ConversationId: cid, |
| 187 | Seq: 1, |
| 188 | Messages: []*proto.Message{ |
| 189 | {Role: "user", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 1"}}}}, |
| 190 | }, |
| 191 | State: proto.State_STATE_COMPLETED, |
| 192 | }, |
| 193 | { |
| 194 | ConversationId: cid, |
| 195 | Seq: 2, |
| 196 | Messages: []*proto.Message{ |
| 197 | {Role: "assistant", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 2"}}}}, |
| 198 | }, |
| 199 | State: proto.State_STATE_COMPLETED, |
| 200 | }, |
| 201 | } |
| 202 | |
| 203 | c, err := New(ctx, Config{ |
| 204 | EventLogBuilder: func() (executor.EventLog, error) { |
| 205 | return log, nil |
| 206 | }, |
| 207 | PlannerBuilder: func(ctx context.Context, r *Registry) (agent.Agent, error) { |
| 208 | return &dummyAgent{}, nil |
| 209 | }, |
| 210 | }) |
| 211 | if err != nil { |
| 212 | t.Fatal(err) |
| 213 | } |
| 214 | defer c.Close() |
| 215 | |
| 216 | var msgs []*proto.Message |
| 217 | handler := ExecHandler(func(resp *proto.ExecResponse) error { |
| 218 | msgs = append(msgs, resp.Outputs...) |
| 219 | return nil |
| 220 | }) |
| 221 | |
| 222 | err = c.Exec(ctx, &proto.ExecRequest{ |
| 223 | ConversationId: cid, |
| 224 | LastSeq: 1, |
| 225 | }, handler) |
| 226 | if err != nil { |
| 227 | t.Fatal(err) |
| 228 | } |
| 229 | |
| 230 | // We expect to receive messages from Seq 2 (since LastSeq is 1). |
| 231 | if len(msgs) != 1 { |
| 232 | t.Fatalf("expected 1 message, got %d", len(msgs)) |
| 233 | } |
| 234 | if msgs[0].GetContent().GetText().GetText() != "msg 2" { |
| 235 | t.Fatalf("expected 'msg 2', got %v", msgs[0].GetContent().GetText().GetText()) |
nothing calls this directly
no test coverage detected