Skip to content

[codex] Add dev text-turn test endpoint#5

Open
monkeyin92 wants to merge 2 commits into
streamcoreai:mainfrom
monkeyin92:codex/dev-test-turn-endpoint
Open

[codex] Add dev text-turn test endpoint#5
monkeyin92 wants to merge 2 commits into
streamcoreai:mainfrom
monkeyin92:codex/dev-test-turn-endpoint

Conversation

@monkeyin92
Copy link
Copy Markdown

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 registers POST /test-turn and accepts a single text turn (text or customerText) plus optional prior messages. The handler reuses the configured LLM, plugins, skills, and optional RAG context, then returns a Voice TestOps-compatible JSON response with spoken, 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 ./...

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_endpoint config and documents it in README + config.toml.example.
  • Registers POST /test-turn when 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.

Comment thread main.go Outdated

if cfg.Test.TurnEndpoint {
log.Println("Dev test-turn endpoint enabled at POST /test-turn")
mux.HandleFunc("/test-turn", testturn.NewHandler(cfg, pluginMgr, ragClient))
Comment thread internal/testturn/handler.go Outdated
Comment on lines +150 to +154
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)
}
Comment thread internal/testturn/handler.go Outdated
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()})
Comment on lines +61 to +65
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
@monkeyin92
Copy link
Copy Markdown
Author

Addressed the automated review hardening points in 62ce374:

  • /test-turn now reuses the existing JWT middleware when server.jwt_secret is configured.
  • Runner/provider failures are logged server-side but return a generic client error.
  • Oversized request bodies now return 413 Request Entity Too Large.
  • The text harness skips vision.analyze, since that tool depends on the realtime pipeline camera/image injection path.
  • Added regression coverage for the generic error response, 413 handling, and vision-tool filtering.

Validation: go test ./....

@monkeyin92 monkeyin92 marked this pull request as ready for review May 13, 2026 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants