Edit

Security and limits

The agents behind this API are the ones LearnHouse runs in its own interface, with the same rules. Nothing in a request can widen what the caller is allowed to do.

Organization isolation

API tokens and embed sessions belong to one organization; member sessions name it with org_id. Conversations, approvals, tool calls and retrieved course content never cross organizations: another organization's conversation is simply not found (404 conversation_not_found).

What each credential reaches

API tokenMember sessionEmbed session
AgentsAll the token's rights allowAll the member's role allowscopilot, agent_<uuid>
ConversationsThose it createdTheir ownThat learner's own
ToolsCapped by the token's rights and its creator's current roleThe member's roleLearner tools only
Approve risky actionsWith AI agents: UpdateYes, in their own conversationsNo

A token can never do more than the user who created it: its rights are capped by that user's current role on every request, and it stops working when they leave the organization. See API tokens.

The token's AI agents permission only opens the Agent API. What Atlas can then read or change still depends on the token's other permissions: a token without Courses: Update can't have Atlas edit a course.

Embed sessions

An embed session acts as one learner:

  • only copilot and custom learner agents; Atlas answers 403 agent_not_available;
  • only that learner's conversations;
  • never approvals, and none of the staff tools;
  • the same limits as any embed session: short-lived, no refresh, one organization, refused for admins and maintainers.

Learner content filtering

Learner agents answer from course content (pages, PDFs and documents, assignments, video and audio transcripts) of courses indexed for AI. Retrieval is filtered by what the learner can open in LearnHouse right now, with the same access checks as the course pages. A lesson they can't open is never retrieved, so it can't be quoted or cited. A custom agent is further limited to the courses it was given.

context.course_uuid and context.activity_uuid focus the agent; they don't grant access. Pointing at a course the learner can't open gives them nothing from it.

AI settings and credits

Every message is checked against the organization's AI settings:

  • Enable AI Features off: AI_DISABLED.
  • AI Copilot off: learner agents answer AI_FEATURE_DISABLED.
  • AI limited to staff: learners get AI_STAFF_ONLY.
  • Monthly AI cap reached: AI_MONTHLY_CAP_REACHED.
  • No credits left: 402 out_of_credits.

Before a run they are HTTP errors; during a run they arrive as an error event. Credits are reserved before a run and given back if it fails, like every AI action in LearnHouse. See AI credits.

Rate limits

Every model turn (a message, an approval or denial that resumes the agent, client tool results) counts against three limits, each over a rolling minute:

LimitDefault
Per API token60 turns (AGENT_API_TOKEN_PER_MINUTE on self-hosted instances)
Per member or embedded learner30 turns, shared with every other AI feature they use
Per organization120 turns, shared with every other AI feature
Per conversation20 turns (AGENT_API_CONVERSATION_PER_MINUTE)

Reading (agents, conversations, messages, streams, the view schema) is not counted. Over a limit, the API answers:

HTTP/1.1 429 Too Many Requests
Retry-After: 12

{"detail": {"code": "rate_limited", "message": "Too many agent requests. Slow down and retry.", "retry_after": 12}}

Wait Retry-After seconds before trying again. A conversation also runs one reply at a time: a message sent while one is running answers 409 run_in_progress. Wait for message.done, or cancel.

Size limits

WhatLimit
Message content8000 characters
instructions2000 characters
metadata20 keys; values are strings, numbers or booleans
external_user_id128 characters
tools.allow100 tool names
tools.client8 tools; name matches ^[a-z][a-z0-9_]{1,47}$; description up to 500 characters
Deny reason1000 characters
json_schema16 KB, 8 levels deep
Template20 KB source, 200 KB output, 8 levels of nesting
JSON output3 attempts
View12 components, 64 KB

Bodies over the limits answer 413 payload_too_large or 422 invalid_request.

Prompt injection

Agents read text other people wrote: course content, learner messages, tool results, your instructions. LearnHouse assumes any of it may try to steer the agent, and doesn't rely on the model to say no:

  • Developer instructions are an overlay. They are added after LearnHouse's own system rules and can change tone, language and focus. They can't turn off a safety rule, unlock a tool or change who the agent acts for.
  • Permissions are checked by the server, not the model. Every tool call is checked against the caller's rights when it runs, whatever the model was told.
  • Risky tools always need approval. No prompt, instruction or allowlist turns an approval off. Only an approver with the right to approve can let it through.
  • No personal data of the token's creator. A conversation started with an API token runs as the organization, not as a person: it gets none of the creator's Atlas memory, inbox or private conversations.
  • Views and templates are data. Views are validated against fixed schemas and cleaned; templates can't run code and escape every value.

On your side:

  • Treat the agent's text, views and tool arguments as untrusted input. Escape them when you render them, and validate client-tool args before acting on them.
  • Don't put secrets in instructions, metadata or client tool results. The model can repeat them.
  • Keep humans on approvals for anything you can't undo.

Audit log

Every change an agent makes is recorded in the organization's audit log as an Atlas action, with the approval that let it through and the conversation id. For API tokens the entry's actor is the member who created the token and its details carry api_token_id; token activity on the API itself is logged too: conversations created and deleted (ai.agent_api_conversation_created, ai.agent_api_conversation_deleted) and every approval decision (ai.agent_api_approval_decided, with the tool and the decision). Changes made with a member session are logged under the member, as in LearnHouse.

Browsers and CORS

  • Learner chat in your frontend: mint an embed session on your server and use it from the browser. It only reaches learner agents.
  • Staff tools in your frontend: call your own backend, which holds the token and decides who may do what, or use the member's own LearnHouse session.

LearnHouse answers cross-origin browser requests that carry a bearer token and no cookies, so embed sessions work from your own domain, streaming included. Self-hosters can turn this off with LEARNHOUSE_BEARER_CORS=false.