---
title: "Update Session"
method: PATCH
path: "/mle-agent/sessions/{session_id}"
tags: ["agent-chat-sessions"]
---

# Update Session

`PATCH /mle-agent/sessions/{session_id}`

Update a chat session's title or archive status.

Args:
    request: FastAPI request used by the rate-limiter.
    session_id: Chat session primary key.
    body: Partial update payload.
    auth: Authenticated caller.
    service: Chat-session service.

Returns:
    ChatSessionResponse after the update.

Raises:
    HTTPException: 404 when the session is missing or not owned.

## Path parameters

- `session_id` string, required

## Request body

- ChatSessionUpdate — Request model for updating a chat session.
  - `title` string, nullable — New title for the session
  - `is_archived` boolean, nullable — Archive status of the session
  - `images_retention_days` integer, nullable — Per-session image retention window in days. 0 means keep forever (the UI 'forever' option). Omit to leave unchanged; when never set, the session inherits the 30-day default. Note: once any value is persisted the session keeps that explicit value even if the system default later changes — this endpoint has no path back to the NULL/inherit state (send 30 to match today's default).

## Response `200`

Successful Response

- ChatSessionResponse — Response model for a chat session (without messages).
  - `id` string, required
  - `user_id` string, required
  - `title` string, required
  - `created_at` string, required
  - `updated_at` string, required
  - `is_archived` boolean
  - `project_id` string, nullable
  - `images_retention_days` integer, nullable — Per-session image retention window in days for this chat's image attachments. NULL inherits the 30-day default; 0 means keep forever. Drives image eviction by the nightly cleanup job.
  - `modal_sandbox_id` string, nullable — Modal sandbox id for the persistent MLE agent runtime, if a sandbox is associated with this session. Surfaced for nightly smoke tests and observability — never used for client routing.
  - `first_user_attached_resources` AttachedResourceRef[] — Resource chips the user attached to the *first* user message of this session, parsed from its attached-context preamble. Powers the threads-sidebar preview so users can see at a glance what context a thread was anchored on without opening it. Empty when the session has no user messages or none of them carry a preamble.
    - `id` string, required — Type-prefixed resource id used by the frontend chip rendering. For example ``dataset:abc-123`` or ``model:tj-99``.
    - `name` string, required — Human-readable label rendered inside the chip.
    - `type` string, required — Resource type slug — one of ``dataset``, ``model``, ``evaluation``, or ``base-model``.

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/pioneer/apis/brain-api.md) · [All operations](https://skmtc.net/pioneer/apis/brain-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/pioneer/brain-api/versions/31dfe831e079/schema)
