Package: tutor
Generated from api/packages/tutor
Source: api/packages/tutor. The sections after the README are extracted from the code on every docs build.
README
Section titled “README”A learner asks a question inside a course and gets a short answer built only from that course’s own
content, with citations that link back to the lesson. Outside the course it says so. During an open quiz
attempt it never gives or confirms quiz answers. Off by default per tenant (tutor.enabled).
Records: ADR 0060 (proposed), ADR 0061 (privacy); plan docs/plans/phase-4.md section 8.
TutorIndexer: chunks of the applied blueprint (lesson blocks and the source text they cite) for Course Builder courses, rich text topics split at headings for other courses, with a PostgreSQLtsvectorand a GIN index. Quiz questions, options, explanations and final tests are never indexed. The index rebuilds itself when the applied version or the topic content changes (tutor:indexforces it).PostgresRetriever: the words of the question OR-ed, ranked withts_rank_cd, plus up to four chunks of the open topic;LikeRetrieveris the fallback for databases without full-text search. No embeddings, no vector database.TutorService: checks the switch, course access and limits (30 questions per learner and day, 6 per minute, a monthly tenant budget), asks thetutortask (profilelight) with the chunks, the last six messages and the question, each learner text inside an escaped<learner_message>wrapper. The answer must cite chunks that were provided; an in-scope answer needs a citation. While the learner has a quiz attempt open (AttemptGuard), the mode isattempt_activeand an answer that contains a correct option (Support/Leak, 80 % of the words of a longer option, the phrase of a short one) is replaced by a standard refusal and flagged.ai_calls.user_idis null; the subject is the conversation.- Streamed answers (ADR 0105):
POST messageswithstream: truestores the question, writesRUN_STARTEDtotutor_eventsand queuesAnswerJob(202 with a run id; 409 while the conversation has an answer running). The job reusesTutorService::answer()withLlmClient::stream()and appends grouped text events and atutor.finalevent with the checked answer and citations; nothing streams during an open quiz attempt.GET /api/tutor/runs/{run}/eventstails the log with the SSE loop incore(Ulams\Core\Http\Sse\EventStream). Events are pruned a day after the run ends or with their conversation.tutor.stream.enabledswitches it off. - Conversations belong to the learner (list, show, delete) and are deleted after 90 days
(
tutor:prune) or with the account. Analytics for authors and admins are counts only, for groups of at leastlearner_insights.min_group_sizelearners.
vendor/bin/phpunit --testsuite tutor # fake driver, a course built through the real builder pipelinephp artisan tutor:index --course=1php artisan tutor:eval --fixtures=all --author=1 # golden questions on the fake driver; --live for the real modeltutor:eval and learner-insights:eval are documented in front/docs-site/src/content/docs/developers/learner-evals.mdx.
- Settings, env variables, privacy:
front/docs-site/src/content/docs/admin/tutor.mdx
API endpoints
Section titled “API endpoints”| Method | Path | Auth | Action |
|---|---|---|---|
GET |
/api/tutor/courses/{course}/status |
yes | TutorController@status |
POST |
/api/tutor/courses/{course}/messages |
yes | TutorController@ask |
GET |
/api/tutor/courses/{course}/conversations |
yes | TutorController@conversations |
GET |
/api/tutor/conversations/{conversation} |
yes | TutorController@show |
DELETE |
/api/tutor/conversations/{conversation} |
yes | TutorController@destroy |
GET |
/api/tutor/runs/{run}/events |
yes | RunEventsController@stream |
GET |
/api/admin/tutor/courses/{course}/analytics |
yes | TutorController@analytics |
Permissions
Section titled “Permissions”None.
Settings
Section titled “Settings”Registered with AdministrableConfig::registerConfig (editable in the admin panel under Configuration → Settings).
| Key | Rules | Public | Read-only |
|---|---|---|---|
tutor.enabled |
boolean | no | |
tutor.limits.daily_questions |
integer, min:1, max:1000 | no | |
tutor.stream.enabled |
boolean | no | |
tutor.retention_days |
integer, min:1, max:3650 | no |
Events
Section titled “Events”None.
Artisan commands
Section titled “Artisan commands”| Command | Description | Signature |
|---|---|---|
tutor:eval |
Evaluate the course tutor on golden questions (fake driver by default, –live for the real model) | tutor:eval {--fixtures=all : all, or a comma list of coffee, git, injection} {--live : call the real model} {--record : write cassettes (tests/cassettes) from this run} {--author= : user id that owns the eval sessions (default: the first admin)} {--max-p95-seconds=20 : the latency check of a live run} {--max-usd-per-answer=0.03 : the cost check of a live run} |
tutor:index |
Rebuild the tutor search index of one course or of every course | tutor:index {--course= : Only this course id} |
tutor:prune |
Delete expired tutor conversations | tutor:prune |
Scheduled jobs
Section titled “Scheduled jobs”| Kind | Target | Frequency |
|---|---|---|
| command | 'tutor:prune' |
dailyAt('02:50')->withoutOverlapping()) |
Environment variables read
Section titled “Environment variables read”AI_TASK_TUTOR_PROFILE, TUTOR_DAILY_QUESTIONS, TUTOR_ENABLED, TUTOR_EVAL_MONTHLY_USD, TUTOR_PER_MINUTE, TUTOR_RETENTION_DAYS, TUTOR_STREAM_COALESCE_MS, TUTOR_STREAM_ENABLED, TUTOR_STREAM_EVENTS_RETENTION_DAYS, TUTOR_STREAM_POLL_MS, TUTOR_STREAM_QUEUE, TUTOR_STREAM_QUEUE_CONNECTION, TUTOR_STREAM_SSE_SECONDS, TUTOR_STREAM_TIMEOUT_SECONDS, TUTOR_TENANT_MONTHLY_USD