Reference/Optional workers & sessions

Mark session completed

Mark session completed through the retained LedgerService adapter.

op_sys_legacy_mark_session_completed
Optional local execution integrationOptional integrationRead as Markdown ↗
On this page

Use this capability

CLI invocation · Shell
op-sys --output json tools call op_sys_legacy_mark_session_completed \  --arguments '{"actor":"<actor>","session_id":"<session_id>"}'

Request template: replace placeholder identities and supply complete contract-specific objects before use. Required arguments are shown; optional arguments are listed below. MCP requests assume an initialized connection.

SDK convenience: client.ledger().mark_session_completed(…). The capability adapter wraps the method value in result. Nested fields arguments are expanded into keyword arguments by the adapter.

Parameters

Arguments are a JSON object. The published schema does not permit unknown top-level fields. Native record payloads and structured arguments are JSON values, not JSON-encoded strings.

actorstringRequired

Cooperative local actor. This does not change the authenticated hosted principal.

errornull | stringOptional

Schema default: null. Omit the field; send null only if its schema permits null.

executionnull | objectOptional
execution_patchnull | objectOptional

Schema default: null. Omit the field; send null only if its schema permits null.

exit_codeintegerOptional

Schema default: 0

metadata_patchnull | objectOptional

Schema default: null. Omit the field; send null only if its schema permits null.

session_idstringRequired
stopped_atnull | stringOptional

Schema default: null. Omit the field; send null only if its schema permits null.

Complete input JSON Schema
Complete input schema · JSON
{  "additionalProperties": false,  "properties": {    "actor": {      "type": "string"    },    "error": {      "default": null,      "type": [        "null",        "string"      ]    },    "execution": {      "additionalProperties": {},      "type": [        "null",        "object"      ]    },    "execution_patch": {      "additionalProperties": {},      "default": null,      "type": [        "null",        "object"      ]    },    "exit_code": {      "default": 0,      "type": "integer"    },    "metadata_patch": {      "additionalProperties": {},      "default": null,      "type": [        "null",        "object"      ]    },    "session_id": {      "type": "string"    },    "stopped_at": {      "default": null,      "type": [        "null",        "string"      ]    }  },  "required": [    "actor",    "session_id"  ],  "type": "object"}

Behavior & authority

Process control requires verified native identity and custody, not simply a PID or a recorded session ID. This is separate from ledger-first record storage.

Rules shared by optional workers & sessions operations
  • Worker and session views redact configured secrets. A redacted response is not a credential configuration round trip.
  • A record-only stop changes recorded state without claiming process termination. Verified stop and restart require the full process-control contract.
  • After uncertain lifecycle operations, inspect session status and provenance before retrying. Never treat pid_alive alone as control authority.

Response

Returns {result: value}. The result retains the SDK method’s value, including null where allowed. It is not the resource-keyed CLI command envelope.

SDK return annotation: dict[str, typing.Any].

CLI tools/call result: payload.tool.result. Response envelopes across CLI, SDK and MCP ↗

The runtime does not publish a standalone response JSON Schema for this operation. Use the response description and linked output manual; the downloadable input schema is not a response contract.

Errors & retries

session_process_unverified
Use the documented recovery path; do not assume process control from a PID.
session_stop_required
Complete the supported stop flow before restart.

The family-level reasons above are representative, not an exhaustive operation error list.

For an uncertain write, preserve the original request and retry identity. On conflict, inspect current state before deciding what to change.