---
title: pydo.harness.update_session()
description: Update a session&#39;s settings.
product: Reference
url: https://docs.digitalocean.com/reference/pydo/reference/harness/update_session/
last_updated: "2026-11-20"
---

> **For AI agents:** The documentation index is at [https://docs.digitalocean.com/llms.txt](https://docs.digitalocean.com/llms.txt). Markdown versions of pages use the same URL with `index.html.md` in place of the HTML page (for example, append `index.html.md` to the directory path instead of opening the HTML document).

# pydo.harness.update_session()

Generated on 20 Nov 2026 from `pydo` version [`v0.47.0`](https://github.com/digitalocean/pydo/releases/tag/v0.47.0)

## Usage

```python
client.harness.update_session(
    session_id="a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    body={
        "resume_on_topoff": False,
        "manifest_yaml": "{your_manifest_yaml}",
    },
)
```

Returns `JSON` Raises `HttpResponseError`

## Description

Updates the settings of an existing session. Changes apply to this session only; the agent config the session was created from is not modified.

Each request makes one of two kinds of update, and the two can’t be combined:

- **Session preferences**: set `resume_on_topoff`. Applied immediately; returns `200`.
- **Session settings**: set `manifest_yaml` to a partial manifest that holds only the sections to change. Applied in the background; returns `202`.

An empty body (`{}`) returns `400`.

### Updatable session settings

| Section | What it changes | Agent restart |
|---|---|---|
| `tools` | The session’s Action Gateway tools (`do.actions` entries). Custom MCP servers can’t be changed. | No |
| `env` | Environment variables (name and value). | Yes |
| `env.HARNESS_INFERENCE_MODEL` | The model, for sessions that use DigitalOcean Serverless Inference. | Yes |
| `secrets` | Plain secrets (name and value). | Yes |

Sections you omit are not changed. Each section you include replaces that section in full; see `manifest_yaml` for the exact rules.

The only way to change a session’s model is to set `HARNESS_INFERENCE_MODEL` in `env`. This works only for sessions that were created with a DigitalOcean Serverless Inference model; sessions that use a third-party model provider can’t change their model. A top-level `model` section returns `400`.

The following can’t be changed on an existing session: custom MCP servers (`422`), egress rules, GitHub OAuth connections, URL-bound secrets, platform-managed model keys, and `permissions` (`400`). To use a different custom MCP server, create a new session.

### Tracking an update

1. A request that changes the session settings returns `202` with `outcome` set to `ACCEPTED`. The session status becomes `SESSION_STATUS_UPDATING`.
2. Poll [`GET /v2/harness-runtime/sessions/{session_id}`](#operation/harness_get_session) every 2 to 5 seconds until the status is `SESSION_STATUS_READY`, or `SESSION_STATUS_PAUSED` if the session was paused when you sent the update. The session returns to that status whether the update succeeded or failed.
3. Read `session.update.state`:

   - `APPLIED`: the update is live.
   - `APPLIED_RESTARTED`: the update is live and the agent was restarted to apply it.
   - `FAILED`: the update did not take effect. `session.update.detail` explains why, and `session.update.reverted` is `true` if the previous settings were restored.

Tool updates usually finish within a few seconds. Updates to `env` (including the model) or `secrets` restart the agent and can take up to about two minutes.

If the request matches the session’s current settings, it returns `200` with `outcome` set to `UNCHANGED` and nothing is applied.

### Versioning

Each accepted update is recorded with its own `update_id` and the manifest hashes before and after the change (`session.update.previous_hash` and `session.update.manifest_hash`). When an update fails, the session is rolled back to its previous settings and `session.update.reverted` is `true`. Once a session’s settings differ from its agent config, the session reports `config_drifted: true`, `config_diff` lists the changed entries, and `manifest` holds the settings the session now runs with (without secret values).

### Requirements

- The session status must be `SESSION_STATUS_READY`, `SESSION_STATUS_DETACHED`, or `SESSION_STATUS_PAUSED`. A paused session is resumed to apply the update and paused again afterwards, unless it was paused for zero balance. Any other status returns `409`, including `SESSION_STATUS_PROVISIONING`, `SESSION_STATUS_UPDATING`, a session paused for zero balance, and a destroyed or failed session. A locked session returns `423`.
- The session must be idle: no agent turn running and no approval pending (`409`).
- Session settings updates must be enabled for your team.
- Not every agent runtime supports every section. An unsupported change returns `409`.

## Parameters

`session_id` string required

Example: `a1b2c3d4-e5f6-7890-abcd-ef1234567890`

The session UUID.

`resume_on_topoff` boolean optional

Example: `False`

Whether this session resumes automatically after it is paused for low balance and your team's prepaid balance is topped up. Applies to this session only. Can't be combined with `manifest_yaml`.

`manifest_yaml` string optional

Example: `tools: - do.actions: tools: [toolbelt:read-only@1]`

A partial agent manifest, as a YAML string, that holds only the sections to change. Can't
be combined with `resume_on_topoff`. Requires session settings updates to be enabled for
your team (`403` otherwise).

Supported sections are `tools`, `env`, and `secrets`. Sections you omit are not changed.
Any other top-level key returns `400`, including `model` (to change the model, set
`HARNESS_INFERENCE_MODEL` in `env`) and `permissions` (can't be changed on an existing
session).

Each section you include replaces that section in full:

\- `tools`: the complete list of tools for the session. Only Action Gateway tools
(`do.actions` entries) can be added, removed, or changed. Custom MCP servers can't be
changed on an existing session: include the session's current custom MCP servers
exactly as they are. Adding, removing, or changing one returns `422`. To remove all Action Gateway tools from a session that has no custom
MCP servers, send `tools: []`. `tools: null` returns `400`.
\- `env`: the complete set of environment variables, as name-value pairs. A variable you
leave out is removed. `env: {}` removes all variables; `env: null` returns `400`.
\- `secrets`: the complete set of secrets, as name-value pairs. A secret you leave out is
removed. For each secret, set the value to a string to add or rotate it, or to `{}` to
keep its current value. A `null` value returns `400`.

**Changing the model.** The only way to change a session's model is through `env`. Set
`HARNESS_INFERENCE_MODEL` to a DigitalOcean Serverless Inference model ID, or to
`router:<name>` for an inference router. This works
only on sessions created with `HARNESS_INFERENCE_MODEL` set and without their own
inference endpoint. Adding, removing, or changing the key on any other session, or moving
a session to its own endpoint, returns `422`. A malformed value (empty, multi-line, or over
256 bytes) returns `400`. Whether the model exists is not checked when you send the
request; an unknown model fails on the agent's next turn.

**Reserved keys.** `HARNESS_INFERENCE_API_KEY` and `HARNESS_INFERENCE_BASE_URL` are
managed by the platform: include them with their current values, or the request returns
`422`. Framework keys can't be changed either (`422`). Secrets that are not plain values
(such as URL-bound or OAuth secrets) can't be changed on an existing session (`422`).

Example that changes the model, keeps one secret, and rotates another. Because each
section is a full replacement, the example assumes the session has no other env
variables or secrets:

\```yaml env: HARNESS_INFERENCE_MODEL: llama3.3-70b-instruct LOG_LEVEL: info secrets: GITHUB_TOKEN: {} JIRA_API_TOKEN: new-token-value`\`\`

## Request Sample

## Show Request Sample

```python
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "resume_on_topoff": False,
  "manifest_yaml": "tools:\n  - do.actions:\n      tools: [toolbelt:read-only@1]\n"
}

resp = client.harness.update_session(session_id="a1b2c3d4-e5f6-7890-abcd-ef1234567890", body=req)
```

## Response Example

## Show Response Example

```json
{
  "session": {
    "session_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "demo-agent",
    "parent_session_id": "example",
    "fork_id": "11111111-2222-3333-4444-555555555555",
    "fork_from_checkpoint_id": "example",
    "agent_kind": "AGENT_KIND_UNSPECIFIED",
    "status": "SESSION_STATUS_UNSPECIFIED",
    "sandbox_id": "example",
    "created_at": "2026-08-01T12:00:00Z",
    "last_event_at": "2026-08-01T12:00:00Z",
    "keep_warm": false,
    "resume_on_topoff": false,
    "pause_reason": "manual",
    "idle_timeout_seconds": 60,
    "repo_hint": "example",
    "warnings": [],
    "config_id": "11111111-2222-3333-4444-555555555555",
    "openai_session_id": "example",
    "openai_environment_id": "example",
    "region": "ric1",
    "workspace_id": "019a2f4e-8c1d-7b3a-9e5f-2d6c8a1b4e70",
    "update": {
      "update_id": "019b0000-0000-7000-8000-000000000001",
      "session_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "kind": "update",
      "state": "APPLIED",
      "sections": [
        "tools"
      ],
      "error": "update_failed",
      "reverted": true,
      "detail": "agent restart did not become healthy; reverted to previous config",
      "manifest_hash": "9f2c1a7e",
      "previous_hash": "3b8d0e54",
      "user_uuid": "4f3c2b1a-0000-4000-8000-000000000000",
      "user_email": "user@example.com",
      "started_at": "2026-11-11T12:00:00Z",
      "finished_at": "2026-11-11T12:00:20Z"
    },
    "config_drifted": true
  },
  "outcome": "ACCEPTED",
  "warnings": [
    "string"
  ]
}
```

## More Information

See [`/v2/harness-runtime/sessions/{session_id}`](https://docs.digitalocean.com/reference/api/reference/harness-runtime/index.html.md#harness_update_session) in the API reference for additional detail on responses, headers, parameters, and more.