Taskbase — Agent Sessions: Chatting with an Agent¶
An agent session is a private conversation between one person and one session persona about a
subject. There are three subjects. The first is a new project request: instead of typing a request into the request
box and waiting for the project manager to come back with questions, the person chats with the
request-builder persona. The agent asks what is unclear and looks up work that already exists. It
fills in a structured draft beside the chat. When the person confirms, Taskbase files the
draft as an ordinary request for the project-manager persona. The second is a task on Needs
attention: the attention-helper persona explains why the task needs the person and drafts an
action plan, which Taskbase runs as the person when they confirm
(Sessions about a task). The third is a general chat, scoped to no
project: the assistant persona answers questions across every organization the person reaches
and drafts an action plan that may also create tasks, epics and requests
(General chats).
Every session, of any subject, lives on one page, /chat, and is answered only
by the runner the person chose for it, on the model they chose.
The design and its reasoning are in ADR-0013, for sessions about a task ADR-0015, and for the chat page, the runner and model choice and general chats ADR-0016. How runners answer turns is in Runners and Runs, the agent's tools in MCP Server, and the tables in Database Schema.
Code: api/internal/session/ (sessions, draft, limits, secret scan, long-poll; runners.go for the
runner and model choice), api/internal/session/plan.go and execute.go (the action plan and its
executor), api/internal/sessionframe/ (a task turn's frame, and general.go for a general turn's),
api/internal/runner/session_turns.go and session_runners.go (runner turn API, availability, which
runners a person may choose), api/internal/authz/turnscope.go (turn scope),
mcp/internal/tools/sessions.go, and the UI's ChatPage.jsx, SessionRunner.jsx (the runner and
model panel), RequestSession.jsx, AttentionSession.jsx and the shared sessionChat.jsx.
How it works¶
sequenceDiagram
participant P as Person
participant T as Taskbase
participant R as agent-runner
participant A as request-builder
P->>T: message
T->>T: store message and a pending turn
T-->>R: long-poll claim returns the turn
R->>A: fresh process, transcript and draft replayed
A->>T: read-only lookups and save_request_draft
R->>T: progress, then finish with the reply
T-->>P: long-poll returns partial text, then the reply
P->>T: confirm
T->>T: file the request for project-manager
- Each message is a turn. A runner answers it with a short, stateless agent run: a fresh process in an empty directory, with the persona, the transcript and the current draft replayed from Taskbase. Nothing lives on the runner between turns, so the person can switch the session to another runner between turns, and a restart loses nothing. Only the session's chosen runner claims its turns (below).
- The transcript lives in Taskbase. It holds the person's messages and the agent's final replies. It holds no tool calls, tool results, partial text or provider session data.
- The draft is the agent's working memory. Existing work it found is recorded in
related, so the next turn knows it without looking again. - Nothing is created before confirm. The agent can only read and save the draft. Only the person's Confirm files the request, and Taskbase files it, not the agent.
The chat page¶
Every session opens on one page, outside any organization (ADR-0016 §6):
/chatlists the person's open chats in every organization, with Resume and Abandon, a filter by subject (request chats, task chats, General chats), and New chat, which starts a general chat. Any signed-in person can open it./chat/{id}shows one session of any subject: the chat list on the left (collapsible; a drawer behind Chats below 768 px), the runner and model bar and the chat in the centre, and beside it, by subject:project_request: the draft editor with Confirm request (Chat | Draft tabs on a phone);task: the Needs attention item (context header, PR and CI, its options with Confirm) above the plan card with Confirm (Chat | Item & plan);general: what the assistant can do until the plan has actions, then the plan card (Chat | Plan, the Plan tab appearing with its action count).
- How to reach it. The user menu's Agent chat item (it was My open chats) links to
/chat, with the open-chat count badge. So does the round robot button in the bottom-right corner of every page except the chat page itself and the full-screen diagram pages: it asks "Do you want to open the chat page to chat with the agent?", Open chat goes to/chat, and Cancel, Esc or a click outside closes the dialog. Build with an agent on a project's request box and Discuss with an agent on Needs attention open or resume their session and then navigate to/chat/{id}; the page's back link returns to the project or the item. A chat page has + New chat in its toolbar. - Old URLs redirect, so Mattermost notices and bookmarks keep working:
/organizations/{o}/projects/{p}/requests/sessions/{id}→/chat/{id},/attention/{event}?session={id}→/chat/{id}, and/chats→/chat.
Choosing the runner and the model¶
Each session has a runner and a model, chosen by its owner
(ADR-0016 §2 and §2a).
Every turn of the session is claimed only by that runner and runs on that model. Taskbase
enforces this in the claim, so runner versions need nothing for it. The choice is stored on the
session (sessions.runner_id, sessions.model) and applies to every subject.
- Who may choose which runner. A person may choose a runner they own (runner owners) that takes session turns and serves the session's organization. An administrator may choose any such runner, theirs or not. A general chat's runner must serve at least one organization; its turns read only what it serves (Turn scope). A runner with no owners can therefore answer only administrators' chats.
- The model is the persona's
default_model(stored as NULL), a tier (small,medium,large), or a model id, limited to what the chosen runner's adapters offer (its reported adapters with the Runners page's model overrides), held subscriptions included. A model the runner does not offer is refused with400. - Default. Opening a session without
runner_idgives it the person's own runner used last (the runner of their most recent session, if they may still choose it), else their first own runner that is online, else their first own runner. An administrator who owns no runner gets no default and chooses one in scope. Each message also resolves the choice: a runner the person may no longer choose is replaced by that default. - Changing it.
PATCH /api/sessions/{id}withrunner_idand/ormodel, by the owner, while the session is open. A field left out is kept;"model": nullgoes back to the persona's default;runner_idcannot be cleared. A runner or model the person may not choose answers400with the reason. The change applies from the next turn to be claimed: a running turn finishes where it is, and a pending one waits for the new runner. Switching runner keeps the model even when the new runner does not offer it; availability then reportsown_runners_cannot_serveuntil the person picks one it offers. - No runner at all. When the session has no runner and none can be defaulted, sending a
message, opening a task session (its opening turn) and restarting one answer
409withcode: "no_own_runner"("You have no runner of your own that takes chats for this organization, so no agent can answer…"), orcode: "no_runner_chosen"for an administrator, who chooses one. Turns that no runner may ever claim do not pile up. - Offline, busy or held. The message is accepted and the turn waits pending for the chosen runner; no other runner steps in. It expires after 10 minutes as any unclaimed turn. The page names the runner and links Switch runner; switching moves the waiting turn with the choice.
- A runner that stops being choosable (an owner removed, its scope narrowed) is not offered any more. A non-admin owner's pending turn on a runner they no longer own stays pending until they switch.
- Recorded. The turn records the session's choice as
requested_modeland the model that ran asmodel, with its runner, so usage names both; cost lands on the chosen runner's subscription.
The runner and model panel. Each chat column starts with a bar ("laptop · medium (default)")
that opens two pickers built from availability's choices. The runner picker lists the runners the
person may choose, an administrator's own runners apart from the others, with free session slots,
offline and held subscriptions; an offline or held runner cannot be chosen unless it already is.
The model picker lists the persona's default, then the tiers, then the model ids the runner offers;
a kept model the runner does not offer stays listed, disabled. A change is sent as
PATCH /api/sessions/{id}. The panel is read-only once the session is closed.
Using it¶
- On a project, open the request box and choose Build with an agent. Taskbase starts a
session and opens it on the chat page,
/chat/{id}. The classic text box stays, for people who prefer it. - The page shows the chat in the centre, under the runner and model bar, and the draft on the right (Chat and Draft tabs below 768 px). While the agent answers, the chat shows its partial text, a muted activity line ("looking up project tasks") and a typing indicator. A message waiting for a runner shows how long it has waited.
- Edit the draft at any time. A save names the
draft_revisionit is based on. If the agent saved meanwhile, the page shows the agent's newer draft and offers Re-apply my edit (save your edit on that revision) or Use the agent's draft. The agent always gets the current draft on its next turn. - Confirm request needs a title and is disabled while a turn runs. It saves an unsaved edit, confirms, and returns to the project with the request box open.
- Resume or abandon. The request box lists your open sessions ("Draft in progress: title, 2 h
ago") with Resume and Abandon. Opening one restores the transcript and the draft.
Agent chat in the user menu, or the robot button in the bottom-right corner (page
/chat, with the open-chat count badge), lists your open sessions in every organization, of every subject, most recently active first, with Resume and Abandon. - Start again. An expired session stays readable but read-only, with a Start again from this draft button (below).
The draft¶
| Field | Content | Limit |
|---|---|---|
title |
Short imperative title; required to confirm | 200 characters |
goal |
Why, in one or two sentences | 2,000 characters |
scope |
in and out lists |
|
acceptance_criteria |
"Done when" statements | |
constraints |
Deadlines, technologies, things not to touch | |
affected |
Ids of projects of this organization | |
related |
Existing work: {type: task \| epic \| milestone, id, note}, the note saying how the request relates ("covers X; extend it rather than duplicate") |
Note 500 characters |
open_questions |
What is still undecided; a request may be confirmed with questions left |
List items are at most 1,000 characters, and a list holds at most 30 items. The draft is checked against this schema on every save, from the person or the agent; the runner gives the agent the same JSON Schema with each turn.
What confirm does¶
- The session becomes
confirmedfirst, so a request is filed only once. A turn still unfinished is closed (session_closed). - Taskbase files the draft through the request box's own path (
CreateRequest): aRequest: …task forproject-managerin the project's Backlog. The description is the rendered draft, with a footer naming the session and its persona. - The transcript is attached as one comment on the request task, authored by the person, so the project manager reads it with the comment tools it already uses. The comment is at most 60,000 bytes. In a longer conversation the earliest messages after the first are left out, with a notice naming the session. A message with images names them in the comment ("2 image(s) attached in the session: …"); the images stay with the session.
- The session links to the request (
result_task_id) and becomes read-only. The request then behaves like any other: the project manager plans it, or asks back through Needs attention.
When no agent is available¶
The page asks GET /api/sessions/availability?subject_type=…&subject_id=… (subject_type=general
takes no subject_id; GET /api/projects/{id}/sessions/availability is the request page's older
form). With session_id= it answers for that open session's runner and model. The answer says
whether a turn could start now, why not, and which runners the pickers offer:
{ "available": false, "persona": "request-builder", "model": "small", "runners": 1,
"free_session_slots": 0, "pending_turns": 0, "own_runners": 1,
"reason_code": "own_runners_offline",
"reason": "Your runner is offline right now; your message will wait for it, or choose another runner.",
"choices": [
{ "id": 7, "name": "laptop", "own": true, "online": false, "free_session_slots": 0,
"held_subscriptions": [], "models": ["small", "medium", "large", "claude-opus-5-5"],
"can_run_model": true, "current": true } ] }
Only the runners the caller may choose count: their own, or for an administrator every runner in scope. With a session, only its runner counts.
| Field | Meaning |
|---|---|
model |
The session's model, else the persona's default |
runners, free_session_slots |
Choosable runners that are online and can run the model now, and their free session slots |
own_runners |
How many session-capable runners the caller owns, whatever they serve |
choices[] |
The pickers' list, own first: id, name, own, online (online and running), free_session_slots, held_subscriptions (held, usage-limited or at a cap), models (tiers and model ids offered), can_run_model (offers the model on an unheld subscription now), current (the session's runner, or the one a new session would get) |
reason_code |
One of the codes below |
reason_code |
When | The page |
|---|---|---|
available |
The chosen (or default) runner has a free slot for the model | Composer works |
no_own_runner |
Not an administrator, and owns no runner that may answer | The composer is replaced by "You don't own an agent runner, so the chat can't act for you", with links to Runners and the agent-runner install guide; the transcript and draft stay readable, and the request page keeps Send as a classic request |
no_runner_chosen |
An administrator's session (or new chat) with no runner chosen | Composer disabled, with Choose a runner |
own_runners_offline |
The chosen runner is offline, paused or draining | The message may be sent and waits, naming the runner, with Switch runner |
own_runners_cannot_serve |
The runner does not offer the session's model, or its subscription is held; also when the caller owns runners but none takes chats for this organization | As offline |
own_runners_busy |
Every session slot of the runner is in use | The message waits for the next free slot |
no_persona |
The organization (for a general chat: none of the caller's) has no active session persona for the subject | — |
On Needs attention, Discuss with an agent stays visible without a runner: on no_own_runner or
no_runner_chosen (from availability or the opening 409) it leads to the chat page's no-runner state,
where an administrator who owns no runner picks one in scope and opens the chat with it.
When the turn cannot start now, the person can still:
- Send the first message and wait. The turn stays pending, the page shows "Waiting for an agent…" with the time waited, and the session's runner takes it as soon as it can (online, a free slot, the model on an unheld subscription). A turn nobody claims expires after 10 minutes.
- Send as a classic request. This files the typed text (else what the person has said so far) through the request box's endpoint, and abandons the session, so nothing typed is lost.
Privacy¶
- A session is private to its owner until it is confirmed. Every person-facing route is for
people only (
humansOnly) and for the owner only; anyone else gets404, so even a session's existence is private. Administrators may read a session, and so may the session's own running turn. - The owner must still reach the session's organization: the guard checks it on every route, and the runner claim fails a turn whose owner lost access. A general chat belongs to no organization: the guard lets its owner through to its routes and the handler keeps it to them; each turn reads only the organizations fixed at its claim.
- The chosen runner's machine processes the conversation: the owner's own runner, or, for an administrator, possibly another person's runner and subscription. The session, the chat and the turn's usage record name the runner.
- After confirm, the transcript is a comment on the request task, visible to everyone in the organization. The page says so above the chat.
- Retention. An open session with no message from the person for 24 hours expires (below). Abandoned, expired and resolved sessions, and confirmed sessions about a task or general chats, stay readable to their owner for 30 days after closing and are then deleted. Confirmed request sessions are kept with their request.
- Sessions about a task and general chats stay private after confirm: their transcript is never attached to the task, or to anything a general chat's plan creates.
Limits¶
Enforced in Taskbase. Rate limits answer 429, with Retry-After when waiting helps; the page shows
the retry time.
| Limit | Value |
|---|---|
| Open sessions per person and organization | 3 request sessions, and apart from them 5 sessions about a task (one per task) |
| Open general chats per person | 3, in no organization, counted apart from the others |
| Unfinished turns per session | 1 (409 on a new message while one is pending or running) |
| Messages per person | 10 a minute, 200 a day |
| Message length | 4,000 characters (MaxMessageChars, 400) |
| Images | 5 MB each, 4 a message, 12 unsent per session, 100 uploads per person a day (Images in chats) |
| Turns per session | 40 for a request or a general chat, 20 for a task (the opening turn counts) |
| Actions in a plan | 5 for a task session, 10 for a general chat |
| A turn's run time | 3 minutes, then it fails ("send again") |
| Unclaimed turn | expires after 10 minutes |
The message limits are shared by all subjects. The chosen runner and model change no limit.
Message length on the page. The message box under Build with an agent and Resolve with an agent never cuts what is typed or pasted. A live counter next to Send shows the count against 4,000 ("3,950 / 4,000"); past the limit it turns into an error ("Too long by 12 characters. Shorten it to 4,000 or fewer — nothing is cut for you.") and Send is disabled until the person shortens the text. Characters are counted as the API counts them (Unicode characters, not UTF-16 units). The project's request box behaves the same way at its own limit of 20,000 characters (Project requests).
Open sessions (MaxOpenSessions, MaxOpenTaskSessions) count a person's open sessions in the
session's organization only, so chats in another organization do not use them up.
MaxOpenGeneralSessions counts their open general chats, wherever they are ("you already have 3 open
general chats; resume or abandon one first"; New chat then lists them). Over the limit,
starting a session (or starting again) answers 429 with "you
already have 3 open chats in organization; resume or abandon one first" ("… 5 open chats about
tasks in …" for task sessions). The body (schema OpenSessionsLimit) carries open_sessions: that
organization's open sessions of that subject type, in the shape of GET /api/sessions/mine. The
request box and Discuss with an agent show them in place with Resume and Abandon.
Idle expiry¶
The session timers in the runner sweeper move an open session to expired when it has had no person
message for 24 hours (SessionIdleExpiry; counted from creation when it has none). This holds
for task sessions too. A session never expires while a turn is pending or running; the turn ends
first (an unclaimed turn after 10 minutes, a running one after 3). abandoned is only for an
explicit Abandon. Closed sessions are deleted 30 days after closing, as before.
Start again from this draft¶
POST /api/sessions/{id}/restart (owner only, an expired session only, else 409) opens a new
session (201) about the same subject with the same persona and a copy of the old draft. Its first
message is a system note: "Started again from the draft of chat #N, which expired after 24 hours
without a message. The earlier conversation was not copied." A task session gets its opening turn
as usual; when the person already has an open session about the task, that one is returned with
200. Starting again counts against the open-session limit (429 as above).
Secret scan. A message, a draft or an action plan (with its checklist) that looks like it holds a credential is refused with 400
("this looks like a secret; remove it"). The page keeps the text so it can be fixed. The scan looks
for private-key blocks, GitHub-style tokens, sk- keys, Slack tokens, AWS key ids, JWTs, and long hex
strings next to words like "token" or "password". The agent's replies and its live partial text are
masked instead. The agent's environment carries no secrets to leak.
Images in chats¶
A person can send images with their messages in any session: screenshots, photos. Each image is
uploaded on its own first, then sent with a message, and the agent's next turn receives it. Source:
api/internal/session/attachments.go and the Taskbase CLAUDE.md paragraphs "Images in chats"
(task #1787, read 2026-10-27).
On the page. Both chat composers take images pasted, dropped, or picked with Attach image. Each uploads at once and shows a preview with a remove button until it is sent. Refusals (wrong type, over 5 MB, more than 4 in a message) show under the previews, and Send waits for uploads still running. The transcript shows a message's images as thumbnails.
Upload. POST /api/sessions/{id}/attachments?name= takes one image's raw bytes as the body, with
an optional file name of at most 200 characters (400 otherwise). The type is sniffed from the bytes,
not taken from the request.
| Rule | Answer |
|---|---|
| PNG, JPEG, WebP or GIF only | 415 for another type or an empty body |
| At most 5 MB | 413 |
| Only the owner, only while the session is open | 404 for anyone else, 409 when closed |
| 12 unsent uploads per session, 100 uploads per person a day | 429 (with Retry-After for the daily limit) |
It answers 201 with the attachment, unsent (message_id null).
Send. POST /api/sessions/{id}/messages takes {body, attachment_ids}. attachment_ids names at
most 4 of the session's unsent uploads, each once; anything else answers 400. A message may be
images alone, with an empty body.
Attachment fields. Messages in GET /api/sessions/{id} carry attachments[], metadata only:
id, session_id, message_id, name, mime, size, sha256, created_by, created_at. The
table is session_attachments.
Download. GET /api/sessions/{id}/attachments/{aid} serves the bytes to the owner and
administrators, as the session itself (404 for an image of another session). The answer has the
image's own Content-Type, X-Content-Type-Options: nosniff and
Content-Security-Policy: default-src 'none', so a browser shows it only as an image.
The agent's turn. The turn claim gives each attachment a url that only the turn's runner reads,
while the turn runs (Runners — Session turns).
Retention. The sweeper deletes unsent uploads 24 hours after upload. Sent images are deleted with their session. A confirmed request's transcript comment names the images, which stay with the session (What confirm does).
What the agent can do¶
The request-builder persona (kind: session, default_model: small, in Skatzi/skatzi-agents) asks
at most three questions per reply, looks up open tasks, epics, milestones and projects before asking,
and saves the draft after every reply that changes it. Its reach is bounded in Taskbase, not in the
prompt:
- Read-only, in the organizations fixed at claim. Its requests carry
X-Taskbase-Turn. They are accepted only from the runner running the turn, and only for GET routes open to agents in the turn's organizations. When a runner claims a turn, Taskbase stores those organizations on it (session_turns.scope_org_ids): the session's one organization for a request or task session; for a general chat, the organizations the owner reaches now (their grants and groups, every organization for an administrator) intersected with the chosen runner's scope. Switching runner can therefore change what the next turn reads. The scope is fail-closed: a turn without a stored scope is refused, an empty one reaches nothing, and a general turn whose runner serves none of the owner's organizations fails ("the chat's runner serves none of the organizations you can reach; choose another runner"). The turn never gets the owner's admin rights or groups (Turn-scoped access). - One write. It may save its own session's draft (
save_request_draft, orsave_action_planfor a session about a task or a general chat) and read its own session (get_session). The session's/updates, messages, confirm and abandon routes stay closed to it. - Read files, never change them. It reads its own project's repository and the platform docs through four read-only Taskbase tools; a general chat reads only the docs (Reading files).
- No tools on the machine. Claude runs with no built-in tools; Codex runs in a read-only sandbox without its shell tool or web search. Neither gets the Gitea token or other secrets.
A prompt injection, in the chat or in a task the agent reads, can at most read organization data the person can already see and change the person's own draft, which they review before confirming. A grant revoked during a turn takes effect at the next claim; confirm checks again as the person.
Reading files¶
A session agent reads two sources, both read-only and both enforced by Taskbase
(ADR 0023,
decision #1662; Taskbase tasks #1755–#1757, api/internal/repository/, read 2026-10-27):
| Source | Tools | API | Open to |
|---|---|---|---|
The session's project's repository: its gitea_repo, on the default branch unless ref names another |
list_repository_files, read_repository_file |
GET /api/projects/{id}/repository/tree?path=&ref=, GET /api/projects/{id}/repository/file?path=&ref=&offset=&limit= |
A request session or a session about a task, for its own project only; never a general chat |
The platform docs: Skatzi/platform docs/content on its default branch (PLATFORM_DOCS_REPO, PLATFORM_DOCS_PATH, configuration) |
list_platform_docs, read_platform_doc |
GET /api/platform-docs/tree?path=, GET /api/platform-docs/file?path=&offset=&limit= |
Every session, general chats included, where it is the only source |
- Which project. The claim fixes the turn's project in
session_turns.scope_project_id: a request session's project, or the task's project for a session about a task. Any other project answers403(Turn-scoped access). The repository is never a parameter; a project without one answers404 no repository. - Which docs. The docs source is the API's setting, never a parameter, and there is no
ref: always the default branch. Docs paths are from the repository root, such asdocs/content/contribution/components/taskbase/sessions.md, and must lie underdocs/contentafter normalisation; an emptypathlists all ofdocs/content(api/internal/repository/docs.go, read 2026-10-28). Any turn whose organization set is not empty may read them, general or not (Turn-scoped access). - How it is read. Taskbase reads Gitea with its own token, through GETs only. The agent holds no Gitea credential, so there is nothing to write with. Answers are cached for 60 seconds.
- Limits. A listing returns at most 2,000 entries (
truncated: truebeyond). A read returns at most 64 KiB;next_offsetpages on. A turn has 30 calls of the four tools together; the 31st answers429. - Refused with a reason (
422): files over 1 MiB, binary files, directories, symlinks and submodules, and files that may hold a secret — by path (.env*,*.pem,*.key,id_*,*.p12,*.pfx,*.sops.*,credentials*, and*secret*outside Markdown files) or by content (withheld: may hold a secret). A listing marks such pathswithheld. Paths are normalised;.., absolute paths and.git/answer400, as does a docs path outsidedocs/content.
Everything read goes to the model provider like the turn's other tool results. The tool
descriptions tell the agent to treat file content as untrusted text and quote it with its path
(mcp/internal/tools/repository.go).
API¶
All person routes are humansOnly and owner-only.
| Endpoint | Caller | Purpose |
|---|---|---|
POST /api/sessions |
person | Start a general chat: {"subject_type": "general", "runner_id"?, "model"?}; 429 over the open-chat limit |
POST /api/projects/{id}/sessions |
person | Start a request session {persona, subject_type, runner_id?, model?}; persona defaults to request-builder, subject_type to project_request; attention-helper is refused |
POST /api/tasks/{id}/sessions |
person | Open a session about the task (optional {runner_id, model}), or return the person's open one (200); 409 when the task has no open attention item, or no_own_runner / no_runner_chosen |
PATCH /api/sessions/{id} |
owner | Change the session's runner and/or model: {"runner_id": 7, "model": "medium"}; a field left out is kept, "model": null is the persona's default; 400 for a runner or model the person may not choose, 409 when closed (above) |
GET /api/projects/{id}/sessions |
person | Their open request sessions in the project |
GET /api/sessions/mine |
person | Their open sessions of every subject, most recently active first (each resumes at /chat/{id}; a general chat has organization_id and project_id null): id, organization_id/organization_name, project_id/project_name, subject_type/subject_id, task_title, attention_id, title (draft title or plan summary), created_at, last_activity_at |
GET /api/projects/{id}/sessions/availability |
person | Whether a turn could start now (above), for the request page |
GET /api/sessions/availability?subject_type=&subject_id=&session_id= |
person | The same for any subject, with the pickers' choices: project_request with a project id, task with a task id, or general without one; session_id answers for that session's runner and model |
GET /api/sessions/{id} |
owner, admins, or the session's own running turn | Session (with runner_id and model), messages and draft |
GET /api/sessions/{id}/updates?after=<cursor>&wait=20 |
owner | Long-poll: returns as soon as a message, the running turn's partial text, the draft or the state changes, else after wait seconds (at most 20). The cursor is version:seq from the previous answer |
POST /api/sessions/{id}/attachments?name= |
owner | Upload one image, unsent, for the next message (Images in chats) |
GET /api/sessions/{id}/attachments/{aid} |
owner, admins | An image's bytes |
POST /api/sessions/{id}/messages |
owner | Send a message {body, attachment_ids}; stores it with a pending turn for the session's runner; 409 while a turn is unfinished, or with code no_own_runner / no_runner_chosen when no runner may answer |
PUT /api/sessions/{id}/draft |
owner, or the session's own running turn | {draft, draft_revision}; 409 with the current draft when the revision is stale |
POST /api/sessions/{id}/confirm |
owner | A request session: file the request with the draft and the transcript. A task session or general chat: optional {draft_revision}; run the plan as the person and answer {session, ok, results} (below); a general chat whose plan has no actions answers 409 |
POST /api/sessions/{id}/abandon |
owner | Close the session |
POST /api/sessions/{id}/restart |
owner | Start an expired session again from its draft (above) |
The runner side (…/session-turns/claim, progress, finish, and PUT /api/runners/{id}/session-slots)
is in Runners and Runs.
Change notification. Every write to a session, its messages or its turns calls the SQL function
session_touch(id), which bumps sessions.version and sends NOTIFY session_updated. Each API replica
listens and wakes the long-polls waiting on that session, so this works with more than one replica. A
new or requeued turn also notifies session_turn_pending, which wakes the runners' claims.
Usage¶
Turns use subscription usage outside tasks. Each claimed turn counts as one run of role session with
the session's persona. A request session's turns count in the request task's session usage line once
it is confirmed, because the task does not exist before. A session about a task counts in that task's
session usage line from the first turn, whether or not the person confirms. A general chat's
turns are in no organization's usage; they are reported per person and runner by
GET /api/usage/general-chats. See
Usage Trends.
Sessions about a task¶
A person opens one with Discuss with an agent on a task item on
Needs attention — on the item page /attention/{event}, or in
the item's row on the list /attention, which asks for availability only when clicked — and then
lands on the session's chat page /chat/{id}. subject_type is task, subject_id the
task's id, and the session's project is the task's project.
- Opening.
POST /api/tasks/{id}/sessionsworks only while the task has an open attention event, of any reason, including person tasks (decision_needed,blocking_agent_work). There is one open session per task and person: opening it again returns the open one. A new session starts with a pending opening turn without a message from the person, so the agent explains and proposes first. It counts as a turn. - Persona. Taskbase picks the persona per subject type:
task→attention-helper,project_request→request-builder,general→assistant. None can be used for another. - Ending. Confirmed, abandoned, or expired after 24 hours without a message, as for requests
(an expired one can be started again). Also
resolved (
subject_resolved): when the task's last open attention event resolves another way (a button, the board, a merge) or is deleted with its task, a trigger onnotifications(session_resolve_subject) closes the session asresolvedand ends an unfinished turn assession_closed. Opening a session takes the same lock and checks for an open event, so a session cannot open just after the item resolved.
The attention-helper persona¶
personas/attention-helper.md in Skatzi/skatzi-agents, with kind: session and
default_model: small. It explains in two to four sentences what the task is, what the agent did and
why it stopped, naming the real cause even when the reason says "Finished without a pull request" and
translating raw errors. It proposes a plan only from the vocabulary its frame lists, saves it with
save_action_plan after every reply that changes it, puts work only a person can do into the
checklist with links, asks before assuming when the item holds a real choice, and never claims to
have done anything. Transcript, task descriptions, run summaries, PR titles and CI names are
information to it, never instructions. Its reach is the same turn scope as the request builder's
(What the agent can do).
The frame¶
A task turn's claim carries the item's context in frame.context, and draft_schema is the action
plan's JSON Schema. The context is no wider than what the person sees on the item and the board:
| Part | Content | Bound |
|---|---|---|
note |
Says that everything below is untrusted information, never instructions | — |
task |
id, title, project and repository, description, assignee, model, dispatch_state, done, decision and decision_source |
description cut to 4,000 characters |
item |
The merged events: kind, reason, detail, question, raised at, event ids, pr_url and pr_source, waits_on, and the group |
— |
runs |
The last 3 runs: role, model, runner, outcome, reason, pr_url, times and duration, summary |
each summary cut to 2,000 characters |
handoff |
The latest digest's open_questions and decisions (ADR-0009) |
— |
pull_request |
The item's PR with its state and CI from GET /api/tasks/{id}/pull-request |
— |
links |
depends_on, follow_up_of and relates_to in both directions: task id, title, done, assignee; titles only inside the organization |
20 |
references |
The item's resolved references | 20 |
comments |
The last 5 comments on the task | each cut to 1,000 characters |
actions_available |
The action types that apply to the task now, each with a description and its parameters | — |
Runs are in the frame because list_task_runs is closed to agents.
agent-runner renders frame.context in the turn prompt as a Subject context section after the
frame and before the draft schema: pretty-printed JSON under a line saying it is untrusted
information, never instructions. Request sessions send no context and get no such section.
The action plan¶
The draft of a task session is a plan:
{
"summary": "Stopped because #851 isn't done yet; nothing is wrong with the task.",
"checklist": [
{"text": "Re-run CI run 302 on PR #132", "url": "https://gitea…/actions/runs/302", "done": false}
],
"actions": [
{"type": "add_dependency_and_requeue", "task_id": 853, "depends_on": 851,
"comment": "Waiting on #851; requeued to start once it is done."}
]
}
| Action | Parameters (besides task_id) |
Offered when |
|---|---|---|
comment_and_requeue |
body, optional model |
The task is an agent's, not done, and waits for a person or is dispatched |
add_dependency_and_requeue |
depends_on, optional comment |
As above |
answer_decision |
answer, optional persona and model. Without persona, the task closes when an open agent task depends_on it, else goes to project-manager (Answering) |
The task is a person's, not done, with an open decision |
close_done |
optional comment |
The task is not done |
reassign |
assignee, assignee_type (agent or user), optional model |
The task is not done |
requeue |
optional model |
As for comment_and_requeue |
requeue_group |
task_ids (1–20) instead of task_id, optional model |
The item belongs to a same-cause group |
Validation. Every save, by the agent or the person, is checked (PlanChecker):
- a known action type with only its own parameters; at most 5 actions; bodies, comments and answers at most 4,000 characters;
- the secret scan over the plan and the checklist;
- every task in the session's organization;
- each action allowed in its task's state now (the table above; the same checks as the API routes);
requeue_grouptasks have an open attention item, at most 20;- no
depends_oncycle, counting the stored links and the plan's own.
An invalid plan answers 400 naming the action and the reason (for example
actions[0] (comment_and_requeue): #12 is not waiting for a person, so it cannot be requeued), so
the agent can fix it within the same turn. The person edits the plan as they edit a request draft:
remove an action, edit a body, tick checklist items, against draft_revision. Ticks change nothing
outside the draft. Nobody can add a type outside the vocabulary.
Confirm runs the plan as the person¶
- Confirm takes an optional
{draft_revision}. When the plan moved since that revision, it answers409and runs nothing. - The plan is checked again against the state now. A stale plan answers
409naming the action; nothing runs and the session stays open. - The session becomes
confirmedbefore the first action runs, so the plan runs once. Confirm is refused (409) while a turn is pending or running. Only the owner may confirm: administrators and turns get404, run agents and service keys403. - The actions run in order through the same services as the Needs attention API routes, each with the person's principal, so a revoked grant stops the plan at its first action. Taskbase stops at the first refusal.
- Each action's result is stored in
sessions.plan_resultsand served asresultson the session, on/updatesand in the confirm answer:type,task_id,status(done,refused,failedornot_run),reason,summary("Comment posted; requeue refused: …"),steps, and forrequeue_groupthe outcome per task.
Comments the plan posts are the person's, with Drafted with attention-helper. under the text. The transcript is not attached to the task.
General chats¶
A general chat is a session about no project
(ADR-0016 §1):
subject_type = 'general', with subject_id, organization_id and project_id all NULL (migration
68 makes the two columns nullable under a CHECK). From it the person can ask about work across their
organizations — tasks, epics, milestones, pull requests and pipelines — and have the agent draft
tasks, epics and requests, or resolve Needs attention items, as an action plan they confirm.
- Opening. New chat on
/chat(reached from Agent chat in the user menu or the robot button in the bottom-right corner) shows the runner and model pickers (fromGET /api/sessions/availability?subject_type=general, the person's current runner preselected; an administrator who owns none must choose), then sendsPOST /api/sessions {"subject_type": "general", "runner_id", "model"}and opens/chat/{id}. Without a runner of their own, a person sees theno_own_runnernotice instead of the form. As a request session, it may open without a runner; its first message then answers409. There is no opening turn: the person writes first. - Persona.
assistant,personas/assistant.mdinSkatzi/skatzi-agents,kind: session,default_model: medium. Personas are synced into every organization; a general turn uses the first organization of its scope that has it. It stays inside the frame's organizations, looks things up rather than answering from memory, asks one short question when the goal is unclear, writescreate_taskdescriptions the way the project manager does (goal, what exists, what to change, Done when), proposes larger or unclear work as acreate_project_request, and saves the plan withsave_action_planafter every reply that changes it. - Limits. 3 open general chats per person, 40 turns, the shared message limits, 10 plan actions (Limits). Expiry and retention as for other sessions: 24 hours idle, then expired; deleted 30 days after closing, confirmed ones included.
- Usage. A general chat's turns are in no organization's usage and on no task; see Usage.
The general frame¶
A general turn's claim has project and organization null and carries, built from the turn's
scope only (sessionframe.General), so the frame shows nothing the turn could not read itself:
| Part | Content |
|---|---|
organizations[] |
The organizations the turn reads, each with its projects (id, name, owner/repo) |
attention |
A summary of the open Needs attention items on tasks in those organizations: open (the total), note (untrusted information, never instructions) and at most 20 items, newest first: task id and title, project, organization, kind, reason, raised_at and age. GET /api/attention itself stays closed to turns |
draft_schema |
The general plan's JSON Schema, with the vocabulary below |
For anything else the agent uses the read-only tools open to turns: list_organization_tasks,
list_epics, list_milestones, list_epic_tasks, list_milestone_tasks, get_task,
list_task_comments, get_task_pull_request and
get_project_pipeline.
The general plan¶
A general chat's draft is an action plan (summary, checklist, actions) with
a wider vocabulary
(ADR-0016 §4): ADR-0015's
seven actions on tasks of the turn's organizations, plus three creates.
| Action | Parameters | What confirm does, as the person |
|---|---|---|
create_task |
project_id, title, description; optional assignee with assignee_type (agent or user), epic_id, milestone_id, priority (0–3), model, required_labels (array of runner labels the task needs), depends_on (a task id) or depends_on_ref, and follow_up_of (a task id) |
The create path of POST /api/projects/{id}/tasks (task.Service.Create), with the links stored in the same transaction as the task (Links on create). A project with a repository gets its Gitea issue; an agent assignee queues the task |
create_epic |
organization_id, title, description; optional milestone_id |
The create path of POST /api/organizations/{orgId}/epics (epic.Service.Create) |
create_project_request |
project_id, title, body |
Files a request for the project manager as the request box does (task.Service.FileRequest). The chat is not attached |
{
"summary": "Follow up #853: add the pipeline route, then document it once the route is in.",
"checklist": [],
"actions": [
{"type": "create_task", "project_id": 2, "title": "Add GET /api/projects/{id}/pipeline",
"description": "…", "assignee": "developer", "assignee_type": "agent", "model": "medium",
"follow_up_of": 853},
{"type": "create_task", "project_id": 2, "title": "Document GET /api/projects/{id}/pipeline",
"description": "…", "assignee": "technical-writer", "assignee_type": "agent",
"depends_on_ref": 1, "follow_up_of": 853}
]
}
- Give a new task its links on the create. A
create_tasktakesdepends_on(a task id) ordepends_on_ref(not both), andfollow_up_of(a task id);follow_up_ofapplies to no other action. Each must be a task in the chat's scope and in the project's organization, and adepends_ontakes part in the cycle check. Confirm stores the links in the same transaction as the task, so an agent-assigned task is never queued without its dependency. The assistant is told to use them rather than a lateradd_dependency_and_requeue, which stays the action for making an existing task wait (api/internal/session/plan.go,execute.go; task #1140, Taskbase PR #497). - Refer to created tasks by position.
task_refanddepends_on_ref(the 1-based position of an earliercreate_taskin the plan) stand fortask_idanddepends_on. They are checked at save time against the task the create would make (new, open, and queued with an agent assignee), so an action its state refuses — a requeue of a task that waits for no one — is refused as for any task. They are resolved to the new task's id when the plan runs. - Validation (
ValidateGeneral,PlanChecker.CheckGeneral), on every save: the action types and their own parameters; at most 10 actions; titles at most 200 characters and descriptions and bodies at most 4,000; the secret scan over every title, description, body and the checklist; every task, project, epic, milestone and organization in scope; an agent assignee akind: taskpersona; an epic or milestone in the project's organization (acreate_epic's milestone in the epic's), and so acreate_task'sdepends_onandfollow_up_of;required_labelsonly oncreate_task, with the task API's label rules (empty labels, whitespace and commas refused; duplicates dropped; at most 32 labels of 128 bytes each; Taskbaseapi/internal/session/plan.go,api/internal/task/model.go, PR #670); the task-state checks of the seven actions; nodepends_oncycle, the plan's own edges included. In scope is the turn's organizations when the agent saves, and the organizations the person reaches when they save or confirm. - Confirm runs as for a task session: the plan is checked
again as the person, then runs in order with their principal through the routes' own services,
stopping at the first refusal. A plan with no actions cannot be confirmed (
409). A result of a create carriescreated:kind(task,epicorrequest),id,title, the organization and project,url(its page in Taskbase) andgitea_issuewhen one was opened. - Attribution. A created task or epic is the person's, with Created by person from a general chat; drafted with assistant. under its description. Comments the plan posts carry Drafted with assistant., as in task sessions.
- The plan card names each action in plain words: "Create task “title” in project, waiting for
task — creates an issue in owner/repo" (the waiting part only with a
depends_on), "Create epic “title” in organization", "File request “title” in project", and a ref as "the task created in step N". After confirm, each result links what was created, with its Gitea issue.