# Feedback AI Summaries Attendees submit ratings and comments through the existing event and session feedback forms. Admin generates summaries manually in **Activity > Event feedback** or **Activity > Session feedback**. Each session has an independent button. There is no background generation and no provider call on feedback submission. ## Configuration **Settings > Feedback AI** stores one global configuration for all events: - **LLM endpoint:** the complete HTTPS URL of an OpenAI-compatible Chat Completions API, for example `https://api.openai.com/v1/chat/completions`. The server does not append a path. URLs with embedded credentials, query parameters or fragments are rejected. - **Model:** the provider's model identifier, maximum 200 characters. - **API key:** optional; sent as `Authorization: Bearer `. Leaving this field blank preserves an existing key. The checkbox explicitly removes it. Changing the endpoint requires entering or clearing the key to prevent forwarding a previously stored credential to a different endpoint. The endpoint must resolve to public IP addresses. HTTP, localhost, private networks, link-local metadata endpoints and reserved IP ranges are not supported. DNS lookups have a 10-second timeout. Results are validated and the HTTPS connection is pinned to a validated address, preserving TLS hostname verification. Redirects are not followed. Private Ollama installations need a public, authenticated HTTPS gateway exposing the compatible API. Azure-style `api-key` headers and native Responses/Ollama APIs are not implemented by this adapter. Stored keys are server-only: `llm_settings` has RLS enabled and no grants for anonymous or authenticated clients. Authenticated admins use the sidecar routes, which return only endpoint, model, update time and `has_api_key`. The key is stored in the protected database table, not encrypted by this feature; privileged database operators and database backups can access it. ## API and Generation All routes below require the Admin user's bearer token, verified with Supabase Auth `/auth/v1/user`, followed by the existing contact admin rule (`is_admin` or an existing `@appe.at` contact). They return `Cache-Control: no-store`. | Route | Purpose | | --- | --- | | `GET /sidecar/llm-settings` | Read redacted configuration. | | `PUT /sidecar/llm-settings` | Save `{ endpoint, model, api_key? }`. | | `POST /sidecar/feedback-summary` | Generate `{ scope: "event", event_id }` or `{ scope: "session", event_id, session_id }`. | | `POST /sidecar/llm-test` | Make one real chat request with the **stored** settings and return a verdict. | ### Connection validation (`POST /sidecar/llm-test`) Always answers **`200 OK` with a verdict** (only the auth layer returns 401/403, and 405 for `GET`), because the reason a connection fails is the useful part: ```json {"ok":true,"model":"Qwen3.8","endpoint":"https://ai.lago.dev/v1/chat/completions", "latency_ms":412,"reasoning_disabled":true,"reasoning_tokens":0,"content":"OK", "warning":null,"error":null} ``` - `reasoning_tokens` is the provider's own `usage.completion_tokens_details.reasoning_tokens`, or **`null` when the provider sent no `usage` block**. `null` is not "off"; `reasoning_disabled` is `true` only when it is exactly `0`. - `ok` answers "would generating a summary work?" — transport, auth and parsing all fine. A working connection whose provider still reports reasoning tokens is therefore `ok: true` with `reasoning_disabled: false` and a `warning`, so the honest signal about cost stays separate from the pass/fail answer. The Admin UI colours that case amber, not green. - It never writes to the database, and the API key never appears in any field: provider error text is flattened, truncated to 300 characters and the stored key is replaced with `[redacted]` (a provider that echoes the Authorization header in its own error body is covered by a test). - An endpoint that fails the SSRF/DNS guard is reported **without ever contacting it**. ### Disabling model thinking Both requests (summaries and the test) are built by one helper, `buildChatCompletionsBody`, so they cannot drift apart. It sends `stream: false`, `reasoning_effort: "none"` **and** `chat_template_kwargs: { enable_thinking: false }`. Measured against the `ai.lago.dev` gateway (Bifrost → vLLM) serving `Qwen3.8`: - Either field alone takes reasoning tokens from ~235 to `0`, about **3.5× faster**. Both are sent because they cover different OpenAI-compatible gateways and each silently drops the other; they agree, so the precedence rule never matters. - `thinking: { type: "disabled" }` (the Anthropic-style spelling) is **silently ignored** by this endpoint and still cost ~235 reasoning tokens, so it is deliberately not used. - `max_tokens` is accepted and ignored, so it is not sent. - **A `200 OK` proves nothing**: this endpoint ignores unknown fields entirely. Only `usage.completion_tokens_details.reasoning_tokens === 0` is evidence. Reasoning *levels* are validated though — `reasoning_effort: "banana"` is an HTTP 400 `unsupported_value`, which is how the field was confirmed to be live. The sidecar checks that the event exists and that a selected session belongs to it. It reads all feedback in ordered 500-row pages, selecting only `rating` and `comment`. The LLM receives the scope, event/session title, response count, ratings and comments; contact names, associated email columns, IDs and timestamps are excluded. Free-text comments can still contain personal information supplied by attendees: use an approved provider and appropriate privacy/retention terms. Requests contain `model`, `stream: false` and system/user `messages`. The response must contain a nonempty string at `choices[0].message.content`. The prompt asks for sentiment, strengths, concerns and actionable improvements in the predominant comment language (English for rating-only feedback), without inventing evidence. Feedback content is explicitly treated as untrusted input. Output is displayed as plain text, never HTML; AI output still requires human review. No-feedback requests fail before calling the provider. Generation also requires saved configuration. Input is capped at approximately 190 KB of feedback (the adapter additionally caps its complete input at 200 KB). Provider calls time out after 60 seconds; output is capped at 100 KB and summaries at 20,000 characters. Provider failures return sanitized errors, without raw provider bodies or keys. Concurrent generation of the same target is rejected in the single sidecar process; this is not a distributed lock across replicas. ## Persistence and Permissions Migration [20261011163332_feedback_ai_summaries.sql](../../supabase/migrations/20261011163332_feedback_ai_summaries.sql) adds `llm_settings` and `feedback_summaries`. Only the service role writes them. Summary reads are restricted to admins by RLS; attendees cannot read these organizer summaries. A successful generation upserts the latest result for its scope and target, storing response count, model, generation timestamp and a SHA-256 fingerprint of the exact rating/comment snapshot. It does not overwrite ratings or comments. Deleting its event or session cascades the summary. The UI restores saved summaries and offers manual regeneration. A provider failure leaves the previous summary untouched. A response-count change is shown; same-count comment edits are not currently flagged by the UI even though the saved fingerprint records the generation snapshot. There is no summary history. Activity reads event-scoped feedback in ordered pages, so counts and available session controls are not truncated by the database API's row limit. Mobile tabs wrap into two columns and feedback tables scroll within their own containers. The old `evaluate_session_feedback` RPC is a deprecated stub with client execution revoked. Its Schedule button and legacy AI state display were removed. The legacy `sessions.ai_generated_feedback` field is not used to store these summaries. Attendee feedback submission, points and average-rating behavior are unchanged. ## Local Validation The migration was applied alone to the local database and recorded in its ledger; older pending migrations were not applied. No seed or reset was run. Production deployment was completed on 2026-10-15; see the [release record](../releases/2026-10-15.md#activation-scope) for backup, deployment scope and production verification. No real LLM was configured or called. Admin Settings must be configured before manual generation is enabled. For an alternate local instance, leaving the existing servers intact: ```sh PORT=3003 SUPABASE_URL=http://127.0.0.1:54321 SESSIONIZE_SYNC_INTERVAL_MS=0 PRETIX_SYNC_INTERVAL_MS=2147483647 node apps/sidecar/src/server.js SIDECAR_TARGET=http://127.0.0.1:3003 npm run dev --prefix apps/admin -- --host 127.0.0.1 --port 3004 --strictPort ``` This preview sidecar has no immediate Sessionize poll, and its Pretix loop has a long interval. These values are for isolated local validation only, not deployment. The usual Admin proxy target remains port 3002 when `SIDECAR_TARGET` is unset. See [tests](./tests.md#feedback-ai-summary-regression) for automated checks. For this validation, the existing Admin on `http://127.0.0.1:3001` is connected to the updated sidecar on port 3003 through the ignored local file `apps/admin/.env.development.local` (`SIDECAR_TARGET=http://127.0.0.1:3003`). This preserves the existing allowlisted magic-link callback. The isolated 3004 preview was used for mocked browser testing and then stopped; real magic-link login on another port requires allowlisting its exact callback first. Auth configuration and existing server processes were not changed or stopped. Validation passed: 28 sidecar tests, eight rollback-only SQL assertions, the 54-test combined browser regression suite, Admin build, test TypeScript and editor checks. Desktop/mobile screenshots were inspected, including explicit grid and bounding-box checks for the mobile feedback tabs and summary panel. A real local Auth smoke used a disposable confirmed account, verified redacted settings and no-feedback rejection through the proxy, then deleted its account, contact and inactive event. No mail or provider request was sent.