[codex] Add dev text-turn test endpoint#5
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in, local-only text-turn testing harness to the StreamCoreAI voice agent server, allowing smoke/regression testing of LLM + plugins/skills (+ optional RAG) without driving the WebRTC audio pipeline.
Changes:
- Introduces
test.turn_endpointconfig and documents it in README +config.toml.example. - Registers
POST /test-turnwhen enabled and implements the request/response handler. - Adds unit tests for the new HTTP handler.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new test.turn_endpoint dev-only flag and endpoint. |
| main.go | Conditionally registers the /test-turn route when enabled. |
| internal/testturn/handler.go | Implements the text-turn HTTP handler, prompt construction, optional RAG injection, and tool/skill wiring. |
| internal/testturn/handler_test.go | Adds basic request/response and error-mapping tests for the handler. |
| internal/config/config.go | Adds [test] section to the config struct (turn_endpoint). |
| config.toml.example | Adds an example [test] configuration block. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if cfg.Test.TurnEndpoint { | ||
| log.Println("Dev test-turn endpoint enabled at POST /test-turn") | ||
| mux.HandleFunc("/test-turn", testturn.NewHandler(cfg, pluginMgr, ragClient)) |
| client.SetToolHandler(func(callCtx context.Context, call llm.ToolCall) (string, error) { | ||
| tool, ok := a.pluginMgr.GetTool(call.Name) | ||
| if !ok { | ||
| return "", fmt.Errorf("unknown tool: %s", call.Name) | ||
| } |
| resp, err := run(r.Context(), req) | ||
| if err != nil { | ||
| log.Printf("[test-turn] error: %v", err) | ||
| writeJSON(w, http.StatusBadGateway, map[string]string{"error": err.Error()}) |
| var req TurnRequest | ||
| decoder := json.NewDecoder(http.MaxBytesReader(w, r.Body, maxRequestBytes)) | ||
| if err := decoder.Decode(&req); err != nil { | ||
| writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid JSON request"}) | ||
| return |
|
Addressed the automated review hardening points in
Validation: |
|
One last follow-up from my side: the dev-only /test-turn harness is still open and mergeable, and the current scope is the one I intended for local regression testing. If anything needs adjustment before review or merge, please let me know; otherwise I’ll stop nudging this thread. |
Summary
Adds an opt-in local text-turn harness for regression and smoke testing without driving the live WebRTC audio path.
When
test.turn_endpoint = true, the server registersPOST /test-turnand accepts a single text turn (textorcustomerText) plus optional prior messages. The handler reuses the configured LLM, plugins, skills, and optional RAG context, then returns a Voice TestOps-compatible JSON response withspoken, streamed response events, and latency.Why
This gives local test tools a deterministic way to exercise assistant behavior without exposing or testing against a shared live demo agent. The endpoint is disabled by default and documented as dev-only.
Validation
go test ./...