Copilot
PRD-007 S-51 (session history). Newest-first, with message_count + last_message_at per session. # ponytail ceiling: no search param in v1 (S-51 asks for search over history — deferred; see the FE handoff gap register).
BearerAuthAuthorizationBearer <token>JWT access token. Obtain via POST /v1/auth/login.
limit?Limit1 <= value <= 10020offset?Offset0 <= value0Successful Response
application/json- response
sessions*array<>curl -X GET 'https://api.aisc.sa/v1/copilot/sessions'{ "sessions": [ { "code_id": "string", "created_at": "2019-08-24T14:15:22Z", "ended_at": "2019-08-24T14:15:22Z", "last_message_at": "2019-08-24T14:15:22Z", "message_count": 0, "session_id": "1ffd059c-17ea-40a8-8aef-70fd0307db82", "updated_at": "2019-08-24T14:15:22Z" } ]}PRD-007 S-50 (session-persistent Copilot panel). Opens an agent.sessions row scoped to the caller + optionally a project. code_id selects which code's corpus subsequent messages in this session will query against — stored as the session's first agent.messages system row (see module docstring; agent.sessions has no code_id column, this is a v1 convention, not a schema change).
BearerAuthAuthorizationBearer <token>JWT access token. Obtain via POST /v1/auth/login.
application/json- body
code_id*Code IdShort code id (e.g. '801').
1 <= length <= 50project_id?|Optional project this session is scoped to.
Session created.
application/json- response
created_at*Created Atdate-timesession_id*Session Iduuidcurl -X POST 'https://api.aisc.sa/v1/copilot/sessions' \ -H 'Content-Type: application/json' \ -d '{ "code_id": "string"}'{ "created_at": "2019-08-24T14:15:22Z", "session_id": "1ffd059c-17ea-40a8-8aef-70fd0307db82"}PRD-007 S-50 (session-persistent panel). Ordered role/content/model/created_at rows; the bookkeeping role='system' row (see module docstring's code_id convention) is excluded — only user/assistant/tool chat turns are returned.
BearerAuthAuthorizationBearer <token>JWT access token. Obtain via POST /v1/auth/login.
session_id*Session IduuidSuccessful Response
application/json- response
messages*array<>curl -X GET 'https://api.aisc.sa/v1/copilot/sessions/497f6eca-6276-4993-bfeb-53cbbbba6f08/messages'{ "messages": [ { "content": "string", "created_at": "2019-08-24T14:15:22Z", "model": "string", "role": "string" } ]}Runs the SAME hardened pipeline as POST /codes/{code_id}/qa — rate limit, retrieval, LLM synthesis, AG-C1 recovery, citation policy, CODE_QA_INTERACTION audit emit — scoped to the session's code_id (set at session creation). Persists both the user question and the assistant answer as agent.messages rows (see module docstring for the assistant JSON-envelope convention) and returns the QAResponse shape plus session_id/message ids and an optional plan (numbered-step surface parsed from the answer — no executor; lands with the G2 lanes).
BearerAuthAuthorizationBearer <token>JWT access token. Obtain via POST /v1/auth/login.
session_id*Session Iduuidapplication/json- body
lang?Lang"ar""ar""en"question_text*Question Text1 <= length <= 2000Answer + citations + session/message ids.
application/json- response
QAResponse + session/message ids + the optional step-plan surface.
answer_text*Answer TextFinal answer in the requested language.
assistant_message_id*Assistant Message Iduuidcitations?array<>Rules the LLM grounded its answer in.
dropped_sentence_count?Dropped Sentence CountPRD-004 enforcement (emt-zi2): sentences removed from the raw LLM answer because a citation marker did not resolve to a retrieved rule. 0 = the model cited cleanly. Additive field; wire-compatible.
0 <= value0lang*LangLanguage of answer_text (echoes request.lang).
"ar""en"model_version*Model VersionLLM model_version used for synthesis (e.g. 'qwen.qwen3-235b-a22b-2507-v1:0').
plan?array<string>|Numbered-step structure parsed from answer_text, when present. SURFACE ONLY — no executor; see module docstring.
prompt_hash*Prompt Hashsha256: of the rendered prompt — replay-by-hash anchor.
prompt_version*Prompt VersionVersion string of the prompt template (e.g. 'system_qa_ar.v1').
session_id*Session Iduuiduser_message_id*User Message Iduuidcurl -X POST 'https://api.aisc.sa/v1/copilot/sessions/497f6eca-6276-4993-bfeb-53cbbbba6f08/messages' \ -H 'Content-Type: application/json' \ -d '{ "question_text": "string"}'{ "answer_text": "string", "assistant_message_id": "bb34c082-20a7-446a-a2d9-976d65d15191", "citations": [ { "code_edition_id": "4a5f38c5-02cb-48ac-ba22-00d46bdf8402", "recovered": false, "relevance_score": 0, "rule_id": "string", "rule_text_ar": "string", "rule_text_en": "string", "section_number": "string" } ], "dropped_sentence_count": 0, "lang": "ar", "model_version": "string", "plan": [ "string" ], "prompt_hash": "string", "prompt_version": "string", "session_id": "1ffd059c-17ea-40a8-8aef-70fd0307db82", "user_message_id": "1798585b-bc85-46b6-801b-ecb7c9ceed07"}