(t *testing.T)
| 359 | } |
| 360 | |
| 361 | func TestController_Exec_InternalOnly(t *testing.T) { |
| 362 | ctx := context.Background() |
| 363 | cid := "test-conv-internal" |
| 364 | |
| 365 | log := &executortest.MemoryEventLog{} |
| 366 | |
| 367 | // Create an agent that emits one internal-only message and one regular message. |
| 368 | a := &mockAgentFunc{ |
| 369 | connectFunc: func(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, o agent.OutputHandler) error { |
| 370 | // If we already have the public message in history, don't emit anything. |
| 371 | for _, m := range start.Messages { |
| 372 | if m.GetContent().GetText().GetText() == "public message" { |
| 373 | return nil |
| 374 | } |
| 375 | } |
| 376 | // Emit internal-only message |
| 377 | if err := o(&proto.AgentOutputs{ |
| 378 | Messages: []*proto.Message{ |
| 379 | { |
| 380 | Role: "assistant", |
| 381 | InternalOnly: true, |
| 382 | Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "internal message"}}}, |
| 383 | }, |
| 384 | }, |
| 385 | }); err != nil { |
| 386 | return err |
| 387 | } |
| 388 | // Emit regular message |
| 389 | return o(&proto.AgentOutputs{ |
| 390 | Messages: []*proto.Message{ |
| 391 | {Role: "assistant", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "public message"}}}}, |
| 392 | }, |
| 393 | }) |
| 394 | }, |
| 395 | } |
| 396 | |
| 397 | c, err := New(ctx, Config{ |
| 398 | EventLogBuilder: func() (executor.EventLog, error) { |
| 399 | return log, nil |
| 400 | }, |
| 401 | PlannerBuilder: func(ctx context.Context, r *Registry) (agent.Agent, error) { |
| 402 | return a, nil |
| 403 | }, |
| 404 | }) |
| 405 | if err != nil { |
| 406 | t.Fatal(err) |
| 407 | } |
| 408 | defer c.Close() |
| 409 | |
| 410 | var msgs []*proto.Message |
| 411 | handler := ExecHandler(func(resp *proto.ExecResponse) error { |
| 412 | msgs = append(msgs, resp.Outputs...) |
| 413 | return nil |
| 414 | }) |
| 415 | |
| 416 | err = c.Exec(ctx, &proto.ExecRequest{ |
| 417 | ConversationId: cid, |
| 418 | Inputs: []*proto.Message{ |
nothing calls this directly
no test coverage detected