archastro.platform.v1.resources.agent_sessions

  1# Copyright (c) 2026 ArchAstro Inc. All Rights Reserved.
  2# This file is auto-generated by @archastro/sdk-generator. Do not edit.
  3# Content hash: 81fe3e9b6e29
  4
  5from __future__ import annotations
  6
  7import builtins
  8from typing import Any, Required, TypedDict
  9
 10from ...runtime.http_client import HttpClient, SyncHttpClient
 11from ...types.common import AgentSession, AgentSessionListResponse
 12
 13
 14class AgentSessionCreateInput(TypedDict, total=False):
 15    "Create an agent session"
 16
 17    agent: Required[str]
 18    "Agent ID (`agi_...`) of the agent that will execute the session."
 19    instructions: Required[str]
 20    "Plain-text task description given to the agent as its primary objective for this session."
 21    max_runs_per_turn: int | None
 22    "Maximum number of tool invocations allowed within a single agent turn. Defaults to 25."
 23    max_tokens: int | None
 24    "Maximum number of tokens the agent may consume across all turns. Defaults to 20,000."
 25    max_turns: int | None
 26    "Maximum number of agent turns before the session is automatically terminated. Defaults to 100."
 27    metadata: dict[str, Any] | None
 28    "Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform."
 29    name: str | None
 30    "Human-readable display name for the session. Useful for identifying sessions in the dashboard. `null` if omitted."
 31    start_idle: bool | None
 32    'When `true`, create the session without running an opening turn. The session starts in `"waiting"` status and runs its first turn only when you post a message. Defaults to `false`, which runs an initial turn from `instructions` immediately.'
 33    team: str | None
 34    "Team ID (`tea_...`) to associate with this session for access-control and attribution purposes. `null` if omitted."
 35    thread: str | None
 36    "Thread ID (`thr_...`) to link this session to an existing conversation thread. `null` if omitted."
 37    user: str | None
 38    "User ID to associate with this session for attribution purposes. `null` if omitted."
 39
 40
 41class AgentSessionUpdateInput(TypedDict, total=False):
 42    "Update an agent session"
 43
 44    metadata: dict[str, Any] | None
 45    "Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged."
 46
 47
 48class AgentSessionMessageInput(TypedDict, total=False):
 49    "Send a message to an agent session"
 50
 51    content: Required[str]
 52    "Plain-text body of the message to deliver to the agent."
 53    metadata: dict[str, Any] | None
 54    "Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform."
 55    role: str | None
 56    'Role of the message sender. Typically `"user"` or `"tool"`. Defaults to `"user"`.'
 57
 58
 59class AsyncAgentSessionResource:
 60    def __init__(self, http: HttpClient):
 61        self._http = http
 62
 63    async def list(
 64        self,
 65        *,
 66        agent: str | None = None,
 67        status: builtins.list[str] | None = None,
 68        routine_run: builtins.list[str] | None = None,
 69        exclude_system: bool | None = None,
 70        limit: int | None = None,
 71    ) -> AgentSessionListResponse:
 72        """
 73        List agent sessions
 74        Returns a flat list of agent sessions visible to the authenticated app,
 75        ordered by creation time descending. Use the `agent`, `status`, and
 76        `routine_run` filters to narrow results.
 77        All filters are optional and can be combined. The `status` and `routine_run`
 78        parameters each accept multiple values; pass the parameter more than once or
 79        as a comma-separated array to match any of the supplied values.
 80        Requires an app-scoped API key. Results are limited to sessions that belong
 81        to agents owned by the authenticated app.
 82
 83        Args:
 84            agent: Filter by agent ID (`agi_...`). Omit to return sessions for all agents in the app.
 85            status: Filter by one or more session statuses. Accepted values are `"pending"`, `"running"`, `"waiting"`, `"completed"`, `"failed"`, and `"cancelled"`. Omit to return sessions in any status.
 86            routine_run: Filter to sessions that were created by the specified routine run IDs. Accepts up to 100 IDs. Omit to return sessions regardless of their originating routine run.
 87            exclude_system: When `true`, omits sessions that were created automatically by the platform rather than by your app. Defaults to `false`.
 88            limit: Maximum number of sessions to return. Defaults to 25; maximum is 100.
 89
 90        Returns:
 91            A list of agent sessions matching the supplied filters.
 92        """
 93        query: dict[str, object] = {}
 94        if agent is not None:
 95            query["agent"] = agent
 96        if status is not None:
 97            query["status"] = status
 98        if routine_run is not None:
 99            query["routine_run"] = routine_run
100        if exclude_system is not None:
101            query["exclude_system"] = exclude_system
102        if limit is not None:
103            query["limit"] = limit
104        return await self._http.request(
105            "/api/v1/agent_sessions",
106            query=query,
107            response_type=AgentSessionListResponse,
108        )
109
110    async def create(self, input: AgentSessionCreateInput) -> AgentSession:
111        """
112        Create an agent session
113        Creates a new agent session and enqueues it for execution. The session begins
114        in `"pending"` status and transitions to `"running"` once the platform picks
115        it up. Subscribe to the session stream endpoint to receive real-time status
116        updates.
117        You must supply the ID of an agent that the authenticated app owns and a
118        plain-text `instructions` string describing the task. All other parameters
119        are optional and default to the agent's configured limits when omitted.
120        Set `start_idle` to `true` to create the session without running an opening
121        turn it begins in `"waiting"` status and runs its first turn only once you
122        post a message (see the message endpoint). Use this when you want the first
123        message to drive the session instead of the `instructions` alone.
124        Requires an app-scoped API key. Returns HTTP 201 on success.
125
126        Args:
127            input: Request body.
128            input.agent: Agent ID (`agi_...`) of the agent that will execute the session.
129            input.instructions: Plain-text task description given to the agent as its primary objective for this session.
130            input.max_runs_per_turn: Maximum number of tool invocations allowed within a single agent turn. Defaults to 25.
131            input.max_tokens: Maximum number of tokens the agent may consume across all turns. Defaults to 20,000.
132            input.max_turns: Maximum number of agent turns before the session is automatically terminated. Defaults to 100.
133            input.metadata: Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform.
134            input.name: Human-readable display name for the session. Useful for identifying sessions in the dashboard. `null` if omitted.
135            input.start_idle: When `true`, create the session without running an opening turn. The session starts in `"waiting"` status and runs its first turn only when you post a message. Defaults to `false`, which runs an initial turn from `instructions` immediately.
136            input.team: Team ID (`tea_...`) to associate with this session for access-control and attribution purposes. `null` if omitted.
137            input.thread: Thread ID (`thr_...`) to link this session to an existing conversation thread. `null` if omitted.
138            input.user: User ID to associate with this session for attribution purposes. `null` if omitted.
139
140        Returns:
141            The newly created agent session.
142        """
143        return await self._http.request(
144            "/api/v1/agent_sessions",
145            method="POST",
146            body=input,
147            response_type=AgentSession,
148        )
149
150    async def delete(self, agent_session: str) -> None:
151        """
152        Delete an agent session
153        Permanently deletes an agent session and its associated data. This action is
154        irreversible the session record, its trajectory, and all inbox messages are
155        removed.
156        To stop a running session without deleting it, use the cancel endpoint
157        instead. The session must be in a terminal state (`"completed"`, `"failed"`,
158        or `"cancelled"`) before it can be deleted; attempting to delete an active
159        session returns 422.
160        Requires an app-scoped API key. Returns HTTP 204 with no body on success.
161
162        Args:
163            agent_session: Agent session ID (`ase_...`) of the session to delete.
164
165        Returns:
166            Empty body. HTTP 204 indicates the session was permanently deleted.
167        """
168        await self._http.request(f"/api/v1/agent_sessions/{agent_session}", method="DELETE")
169
170    async def get(self, agent_session: str) -> AgentSession:
171        """
172        Retrieve an agent session
173        Returns the agent session identified by `agent_session`. Use this endpoint
174        to poll session status or to inspect the final result after execution
175        completes.
176        For real-time updates without polling, subscribe to the session stream
177        endpoint instead, which delivers server-sent events whenever the session
178        state changes.
179        Requires an app-scoped API key. The session must belong to an agent owned
180        by the authenticated app.
181
182        Args:
183            agent_session: Agent session ID (`ase_...`) of the session to retrieve.
184
185        Returns:
186            The requested agent session.
187        """
188        return await self._http.request(
189            f"/api/v1/agent_sessions/{agent_session}",
190            response_type=AgentSession,
191        )
192
193    async def update(self, agent_session: str, input: AgentSessionUpdateInput) -> AgentSession:
194        """
195        Update an agent session
196        Updates the mutable fields of an agent session. Currently only `metadata`
197        can be changed; supply any key-value pairs you want to store alongside the
198        session. Omitting `metadata` leaves it unchanged.
199        This endpoint may be called while the session is in any status, including
200        while it is actively running.
201        Requires an app-scoped API key. The session must belong to an agent owned
202        by the authenticated app.
203
204        Args:
205            agent_session: Agent session ID (`ase_...`) of the session to update.
206            input: Request body.
207            input.metadata: Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged.
208
209        Returns:
210            The agent session with the updated fields applied.
211        """
212        return await self._http.request(
213            f"/api/v1/agent_sessions/{agent_session}",
214            method="PATCH",
215            body=input,
216            response_type=AgentSession,
217        )
218
219    async def cancel(self, agent_session: str) -> AgentSession:
220        """
221        Cancel an agent session
222        Requests cancellation of an active agent session. The session status is set
223        to `"cancelled"` and any in-progress agent turn is interrupted as soon as the
224        platform can safely stop it.
225        If the session is already in a terminal state (`"completed"`, `"failed"`, or
226        `"cancelled"`), the call succeeds and returns the session unchanged it is
227        safe to call this endpoint more than once.
228        Requires an app-scoped API key. The session must belong to an agent owned by
229        the authenticated app.
230
231        Args:
232            agent_session: Agent session ID (`ase_...`) of the session to cancel.
233
234        Returns:
235            The agent session after the cancellation request is applied.
236        """
237        return await self._http.request(
238            f"/api/v1/agent_sessions/{agent_session}/cancel",
239            method="POST",
240            response_type=AgentSession,
241        )
242
243    async def message(self, agent_session: str, input: AgentSessionMessageInput) -> AgentSession:
244        """
245        Send a message to an agent session
246        Appends a message to the inbox of the specified agent session. The agent
247        reads inbox messages at the start of each turn; sending a message to a
248        `"waiting"` session signals it to resume execution.
249        Use `role` to identify the sender type. The default role is `"user"`.
250        Arbitrary key-value metadata may be attached to the message for tracking
251        or display purposes.
252        Requires an app-scoped API key. The session must belong to an agent owned
253        by the authenticated app.
254
255        Args:
256            agent_session: Agent session ID (`ase_...`) of the session whose inbox should receive the message.
257            input: Request body.
258            input.content: Plain-text body of the message to deliver to the agent.
259            input.metadata: Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform.
260            input.role: Role of the message sender. Typically `"user"` or `"tool"`. Defaults to `"user"`.
261
262        Returns:
263            The agent session with the new message appended to its `inbox`.
264        """
265        return await self._http.request(
266            f"/api/v1/agent_sessions/{agent_session}/message",
267            method="POST",
268            body=input,
269            response_type=AgentSession,
270        )
271
272
273class AgentSessionResource:
274    def __init__(self, http: SyncHttpClient):
275        self._http = http
276
277    def list(
278        self,
279        *,
280        agent: str | None = None,
281        status: builtins.list[str] | None = None,
282        routine_run: builtins.list[str] | None = None,
283        exclude_system: bool | None = None,
284        limit: int | None = None,
285    ) -> AgentSessionListResponse:
286        """
287        List agent sessions
288        Returns a flat list of agent sessions visible to the authenticated app,
289        ordered by creation time descending. Use the `agent`, `status`, and
290        `routine_run` filters to narrow results.
291        All filters are optional and can be combined. The `status` and `routine_run`
292        parameters each accept multiple values; pass the parameter more than once or
293        as a comma-separated array to match any of the supplied values.
294        Requires an app-scoped API key. Results are limited to sessions that belong
295        to agents owned by the authenticated app.
296
297        Args:
298            agent: Filter by agent ID (`agi_...`). Omit to return sessions for all agents in the app.
299            status: Filter by one or more session statuses. Accepted values are `"pending"`, `"running"`, `"waiting"`, `"completed"`, `"failed"`, and `"cancelled"`. Omit to return sessions in any status.
300            routine_run: Filter to sessions that were created by the specified routine run IDs. Accepts up to 100 IDs. Omit to return sessions regardless of their originating routine run.
301            exclude_system: When `true`, omits sessions that were created automatically by the platform rather than by your app. Defaults to `false`.
302            limit: Maximum number of sessions to return. Defaults to 25; maximum is 100.
303
304        Returns:
305            A list of agent sessions matching the supplied filters.
306        """
307        query: dict[str, object] = {}
308        if agent is not None:
309            query["agent"] = agent
310        if status is not None:
311            query["status"] = status
312        if routine_run is not None:
313            query["routine_run"] = routine_run
314        if exclude_system is not None:
315            query["exclude_system"] = exclude_system
316        if limit is not None:
317            query["limit"] = limit
318        return self._http.request(
319            "/api/v1/agent_sessions",
320            query=query,
321            response_type=AgentSessionListResponse,
322        )
323
324    def create(self, input: AgentSessionCreateInput) -> AgentSession:
325        """
326        Create an agent session
327        Creates a new agent session and enqueues it for execution. The session begins
328        in `"pending"` status and transitions to `"running"` once the platform picks
329        it up. Subscribe to the session stream endpoint to receive real-time status
330        updates.
331        You must supply the ID of an agent that the authenticated app owns and a
332        plain-text `instructions` string describing the task. All other parameters
333        are optional and default to the agent's configured limits when omitted.
334        Set `start_idle` to `true` to create the session without running an opening
335        turn it begins in `"waiting"` status and runs its first turn only once you
336        post a message (see the message endpoint). Use this when you want the first
337        message to drive the session instead of the `instructions` alone.
338        Requires an app-scoped API key. Returns HTTP 201 on success.
339
340        Args:
341            input: Request body.
342            input.agent: Agent ID (`agi_...`) of the agent that will execute the session.
343            input.instructions: Plain-text task description given to the agent as its primary objective for this session.
344            input.max_runs_per_turn: Maximum number of tool invocations allowed within a single agent turn. Defaults to 25.
345            input.max_tokens: Maximum number of tokens the agent may consume across all turns. Defaults to 20,000.
346            input.max_turns: Maximum number of agent turns before the session is automatically terminated. Defaults to 100.
347            input.metadata: Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform.
348            input.name: Human-readable display name for the session. Useful for identifying sessions in the dashboard. `null` if omitted.
349            input.start_idle: When `true`, create the session without running an opening turn. The session starts in `"waiting"` status and runs its first turn only when you post a message. Defaults to `false`, which runs an initial turn from `instructions` immediately.
350            input.team: Team ID (`tea_...`) to associate with this session for access-control and attribution purposes. `null` if omitted.
351            input.thread: Thread ID (`thr_...`) to link this session to an existing conversation thread. `null` if omitted.
352            input.user: User ID to associate with this session for attribution purposes. `null` if omitted.
353
354        Returns:
355            The newly created agent session.
356        """
357        return self._http.request(
358            "/api/v1/agent_sessions",
359            method="POST",
360            body=input,
361            response_type=AgentSession,
362        )
363
364    def delete(self, agent_session: str) -> None:
365        """
366        Delete an agent session
367        Permanently deletes an agent session and its associated data. This action is
368        irreversible the session record, its trajectory, and all inbox messages are
369        removed.
370        To stop a running session without deleting it, use the cancel endpoint
371        instead. The session must be in a terminal state (`"completed"`, `"failed"`,
372        or `"cancelled"`) before it can be deleted; attempting to delete an active
373        session returns 422.
374        Requires an app-scoped API key. Returns HTTP 204 with no body on success.
375
376        Args:
377            agent_session: Agent session ID (`ase_...`) of the session to delete.
378
379        Returns:
380            Empty body. HTTP 204 indicates the session was permanently deleted.
381        """
382        self._http.request(f"/api/v1/agent_sessions/{agent_session}", method="DELETE")
383
384    def get(self, agent_session: str) -> AgentSession:
385        """
386        Retrieve an agent session
387        Returns the agent session identified by `agent_session`. Use this endpoint
388        to poll session status or to inspect the final result after execution
389        completes.
390        For real-time updates without polling, subscribe to the session stream
391        endpoint instead, which delivers server-sent events whenever the session
392        state changes.
393        Requires an app-scoped API key. The session must belong to an agent owned
394        by the authenticated app.
395
396        Args:
397            agent_session: Agent session ID (`ase_...`) of the session to retrieve.
398
399        Returns:
400            The requested agent session.
401        """
402        return self._http.request(
403            f"/api/v1/agent_sessions/{agent_session}",
404            response_type=AgentSession,
405        )
406
407    def update(self, agent_session: str, input: AgentSessionUpdateInput) -> AgentSession:
408        """
409        Update an agent session
410        Updates the mutable fields of an agent session. Currently only `metadata`
411        can be changed; supply any key-value pairs you want to store alongside the
412        session. Omitting `metadata` leaves it unchanged.
413        This endpoint may be called while the session is in any status, including
414        while it is actively running.
415        Requires an app-scoped API key. The session must belong to an agent owned
416        by the authenticated app.
417
418        Args:
419            agent_session: Agent session ID (`ase_...`) of the session to update.
420            input: Request body.
421            input.metadata: Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged.
422
423        Returns:
424            The agent session with the updated fields applied.
425        """
426        return self._http.request(
427            f"/api/v1/agent_sessions/{agent_session}",
428            method="PATCH",
429            body=input,
430            response_type=AgentSession,
431        )
432
433    def cancel(self, agent_session: str) -> AgentSession:
434        """
435        Cancel an agent session
436        Requests cancellation of an active agent session. The session status is set
437        to `"cancelled"` and any in-progress agent turn is interrupted as soon as the
438        platform can safely stop it.
439        If the session is already in a terminal state (`"completed"`, `"failed"`, or
440        `"cancelled"`), the call succeeds and returns the session unchanged it is
441        safe to call this endpoint more than once.
442        Requires an app-scoped API key. The session must belong to an agent owned by
443        the authenticated app.
444
445        Args:
446            agent_session: Agent session ID (`ase_...`) of the session to cancel.
447
448        Returns:
449            The agent session after the cancellation request is applied.
450        """
451        return self._http.request(
452            f"/api/v1/agent_sessions/{agent_session}/cancel",
453            method="POST",
454            response_type=AgentSession,
455        )
456
457    def message(self, agent_session: str, input: AgentSessionMessageInput) -> AgentSession:
458        """
459        Send a message to an agent session
460        Appends a message to the inbox of the specified agent session. The agent
461        reads inbox messages at the start of each turn; sending a message to a
462        `"waiting"` session signals it to resume execution.
463        Use `role` to identify the sender type. The default role is `"user"`.
464        Arbitrary key-value metadata may be attached to the message for tracking
465        or display purposes.
466        Requires an app-scoped API key. The session must belong to an agent owned
467        by the authenticated app.
468
469        Args:
470            agent_session: Agent session ID (`ase_...`) of the session whose inbox should receive the message.
471            input: Request body.
472            input.content: Plain-text body of the message to deliver to the agent.
473            input.metadata: Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform.
474            input.role: Role of the message sender. Typically `"user"` or `"tool"`. Defaults to `"user"`.
475
476        Returns:
477            The agent session with the new message appended to its `inbox`.
478        """
479        return self._http.request(
480            f"/api/v1/agent_sessions/{agent_session}/message",
481            method="POST",
482            body=input,
483            response_type=AgentSession,
484        )
class AgentSessionCreateInput(typing.TypedDict):
15class AgentSessionCreateInput(TypedDict, total=False):
16    "Create an agent session"
17
18    agent: Required[str]
19    "Agent ID (`agi_...`) of the agent that will execute the session."
20    instructions: Required[str]
21    "Plain-text task description given to the agent as its primary objective for this session."
22    max_runs_per_turn: int | None
23    "Maximum number of tool invocations allowed within a single agent turn. Defaults to 25."
24    max_tokens: int | None
25    "Maximum number of tokens the agent may consume across all turns. Defaults to 20,000."
26    max_turns: int | None
27    "Maximum number of agent turns before the session is automatically terminated. Defaults to 100."
28    metadata: dict[str, Any] | None
29    "Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform."
30    name: str | None
31    "Human-readable display name for the session. Useful for identifying sessions in the dashboard. `null` if omitted."
32    start_idle: bool | None
33    'When `true`, create the session without running an opening turn. The session starts in `"waiting"` status and runs its first turn only when you post a message. Defaults to `false`, which runs an initial turn from `instructions` immediately.'
34    team: str | None
35    "Team ID (`tea_...`) to associate with this session for access-control and attribution purposes. `null` if omitted."
36    thread: str | None
37    "Thread ID (`thr_...`) to link this session to an existing conversation thread. `null` if omitted."
38    user: str | None
39    "User ID to associate with this session for attribution purposes. `null` if omitted."

Create an agent session

agent: Required[str]

Agent ID (agi_...) of the agent that will execute the session.

instructions: Required[str]

Plain-text task description given to the agent as its primary objective for this session.

max_runs_per_turn: int | None

Maximum number of tool invocations allowed within a single agent turn. Defaults to 25.

max_tokens: int | None

Maximum number of tokens the agent may consume across all turns. Defaults to 20,000.

max_turns: int | None

Maximum number of agent turns before the session is automatically terminated. Defaults to 100.

metadata: dict[str, typing.Any] | None

Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform.

name: str | None

Human-readable display name for the session. Useful for identifying sessions in the dashboard. null if omitted.

start_idle: bool | None

When true, create the session without running an opening turn. The session starts in "waiting" status and runs its first turn only when you post a message. Defaults to false, which runs an initial turn from instructions immediately.

team: str | None

Team ID (tea_...) to associate with this session for access-control and attribution purposes. null if omitted.

thread: str | None

Thread ID (thr_...) to link this session to an existing conversation thread. null if omitted.

user: str | None

User ID to associate with this session for attribution purposes. null if omitted.

class AgentSessionUpdateInput(typing.TypedDict):
42class AgentSessionUpdateInput(TypedDict, total=False):
43    "Update an agent session"
44
45    metadata: dict[str, Any] | None
46    "Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged."

Update an agent session

metadata: dict[str, typing.Any] | None

Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged.

class AgentSessionMessageInput(typing.TypedDict):
49class AgentSessionMessageInput(TypedDict, total=False):
50    "Send a message to an agent session"
51
52    content: Required[str]
53    "Plain-text body of the message to deliver to the agent."
54    metadata: dict[str, Any] | None
55    "Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform."
56    role: str | None
57    'Role of the message sender. Typically `"user"` or `"tool"`. Defaults to `"user"`.'

Send a message to an agent session

content: Required[str]

Plain-text body of the message to deliver to the agent.

metadata: dict[str, typing.Any] | None

Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform.

role: str | None

Role of the message sender. Typically "user" or "tool". Defaults to "user".

class AsyncAgentSessionResource:
 60class AsyncAgentSessionResource:
 61    def __init__(self, http: HttpClient):
 62        self._http = http
 63
 64    async def list(
 65        self,
 66        *,
 67        agent: str | None = None,
 68        status: builtins.list[str] | None = None,
 69        routine_run: builtins.list[str] | None = None,
 70        exclude_system: bool | None = None,
 71        limit: int | None = None,
 72    ) -> AgentSessionListResponse:
 73        """
 74        List agent sessions
 75        Returns a flat list of agent sessions visible to the authenticated app,
 76        ordered by creation time descending. Use the `agent`, `status`, and
 77        `routine_run` filters to narrow results.
 78        All filters are optional and can be combined. The `status` and `routine_run`
 79        parameters each accept multiple values; pass the parameter more than once or
 80        as a comma-separated array to match any of the supplied values.
 81        Requires an app-scoped API key. Results are limited to sessions that belong
 82        to agents owned by the authenticated app.
 83
 84        Args:
 85            agent: Filter by agent ID (`agi_...`). Omit to return sessions for all agents in the app.
 86            status: Filter by one or more session statuses. Accepted values are `"pending"`, `"running"`, `"waiting"`, `"completed"`, `"failed"`, and `"cancelled"`. Omit to return sessions in any status.
 87            routine_run: Filter to sessions that were created by the specified routine run IDs. Accepts up to 100 IDs. Omit to return sessions regardless of their originating routine run.
 88            exclude_system: When `true`, omits sessions that were created automatically by the platform rather than by your app. Defaults to `false`.
 89            limit: Maximum number of sessions to return. Defaults to 25; maximum is 100.
 90
 91        Returns:
 92            A list of agent sessions matching the supplied filters.
 93        """
 94        query: dict[str, object] = {}
 95        if agent is not None:
 96            query["agent"] = agent
 97        if status is not None:
 98            query["status"] = status
 99        if routine_run is not None:
100            query["routine_run"] = routine_run
101        if exclude_system is not None:
102            query["exclude_system"] = exclude_system
103        if limit is not None:
104            query["limit"] = limit
105        return await self._http.request(
106            "/api/v1/agent_sessions",
107            query=query,
108            response_type=AgentSessionListResponse,
109        )
110
111    async def create(self, input: AgentSessionCreateInput) -> AgentSession:
112        """
113        Create an agent session
114        Creates a new agent session and enqueues it for execution. The session begins
115        in `"pending"` status and transitions to `"running"` once the platform picks
116        it up. Subscribe to the session stream endpoint to receive real-time status
117        updates.
118        You must supply the ID of an agent that the authenticated app owns and a
119        plain-text `instructions` string describing the task. All other parameters
120        are optional and default to the agent's configured limits when omitted.
121        Set `start_idle` to `true` to create the session without running an opening
122        turn it begins in `"waiting"` status and runs its first turn only once you
123        post a message (see the message endpoint). Use this when you want the first
124        message to drive the session instead of the `instructions` alone.
125        Requires an app-scoped API key. Returns HTTP 201 on success.
126
127        Args:
128            input: Request body.
129            input.agent: Agent ID (`agi_...`) of the agent that will execute the session.
130            input.instructions: Plain-text task description given to the agent as its primary objective for this session.
131            input.max_runs_per_turn: Maximum number of tool invocations allowed within a single agent turn. Defaults to 25.
132            input.max_tokens: Maximum number of tokens the agent may consume across all turns. Defaults to 20,000.
133            input.max_turns: Maximum number of agent turns before the session is automatically terminated. Defaults to 100.
134            input.metadata: Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform.
135            input.name: Human-readable display name for the session. Useful for identifying sessions in the dashboard. `null` if omitted.
136            input.start_idle: When `true`, create the session without running an opening turn. The session starts in `"waiting"` status and runs its first turn only when you post a message. Defaults to `false`, which runs an initial turn from `instructions` immediately.
137            input.team: Team ID (`tea_...`) to associate with this session for access-control and attribution purposes. `null` if omitted.
138            input.thread: Thread ID (`thr_...`) to link this session to an existing conversation thread. `null` if omitted.
139            input.user: User ID to associate with this session for attribution purposes. `null` if omitted.
140
141        Returns:
142            The newly created agent session.
143        """
144        return await self._http.request(
145            "/api/v1/agent_sessions",
146            method="POST",
147            body=input,
148            response_type=AgentSession,
149        )
150
151    async def delete(self, agent_session: str) -> None:
152        """
153        Delete an agent session
154        Permanently deletes an agent session and its associated data. This action is
155        irreversible the session record, its trajectory, and all inbox messages are
156        removed.
157        To stop a running session without deleting it, use the cancel endpoint
158        instead. The session must be in a terminal state (`"completed"`, `"failed"`,
159        or `"cancelled"`) before it can be deleted; attempting to delete an active
160        session returns 422.
161        Requires an app-scoped API key. Returns HTTP 204 with no body on success.
162
163        Args:
164            agent_session: Agent session ID (`ase_...`) of the session to delete.
165
166        Returns:
167            Empty body. HTTP 204 indicates the session was permanently deleted.
168        """
169        await self._http.request(f"/api/v1/agent_sessions/{agent_session}", method="DELETE")
170
171    async def get(self, agent_session: str) -> AgentSession:
172        """
173        Retrieve an agent session
174        Returns the agent session identified by `agent_session`. Use this endpoint
175        to poll session status or to inspect the final result after execution
176        completes.
177        For real-time updates without polling, subscribe to the session stream
178        endpoint instead, which delivers server-sent events whenever the session
179        state changes.
180        Requires an app-scoped API key. The session must belong to an agent owned
181        by the authenticated app.
182
183        Args:
184            agent_session: Agent session ID (`ase_...`) of the session to retrieve.
185
186        Returns:
187            The requested agent session.
188        """
189        return await self._http.request(
190            f"/api/v1/agent_sessions/{agent_session}",
191            response_type=AgentSession,
192        )
193
194    async def update(self, agent_session: str, input: AgentSessionUpdateInput) -> AgentSession:
195        """
196        Update an agent session
197        Updates the mutable fields of an agent session. Currently only `metadata`
198        can be changed; supply any key-value pairs you want to store alongside the
199        session. Omitting `metadata` leaves it unchanged.
200        This endpoint may be called while the session is in any status, including
201        while it is actively running.
202        Requires an app-scoped API key. The session must belong to an agent owned
203        by the authenticated app.
204
205        Args:
206            agent_session: Agent session ID (`ase_...`) of the session to update.
207            input: Request body.
208            input.metadata: Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged.
209
210        Returns:
211            The agent session with the updated fields applied.
212        """
213        return await self._http.request(
214            f"/api/v1/agent_sessions/{agent_session}",
215            method="PATCH",
216            body=input,
217            response_type=AgentSession,
218        )
219
220    async def cancel(self, agent_session: str) -> AgentSession:
221        """
222        Cancel an agent session
223        Requests cancellation of an active agent session. The session status is set
224        to `"cancelled"` and any in-progress agent turn is interrupted as soon as the
225        platform can safely stop it.
226        If the session is already in a terminal state (`"completed"`, `"failed"`, or
227        `"cancelled"`), the call succeeds and returns the session unchanged it is
228        safe to call this endpoint more than once.
229        Requires an app-scoped API key. The session must belong to an agent owned by
230        the authenticated app.
231
232        Args:
233            agent_session: Agent session ID (`ase_...`) of the session to cancel.
234
235        Returns:
236            The agent session after the cancellation request is applied.
237        """
238        return await self._http.request(
239            f"/api/v1/agent_sessions/{agent_session}/cancel",
240            method="POST",
241            response_type=AgentSession,
242        )
243
244    async def message(self, agent_session: str, input: AgentSessionMessageInput) -> AgentSession:
245        """
246        Send a message to an agent session
247        Appends a message to the inbox of the specified agent session. The agent
248        reads inbox messages at the start of each turn; sending a message to a
249        `"waiting"` session signals it to resume execution.
250        Use `role` to identify the sender type. The default role is `"user"`.
251        Arbitrary key-value metadata may be attached to the message for tracking
252        or display purposes.
253        Requires an app-scoped API key. The session must belong to an agent owned
254        by the authenticated app.
255
256        Args:
257            agent_session: Agent session ID (`ase_...`) of the session whose inbox should receive the message.
258            input: Request body.
259            input.content: Plain-text body of the message to deliver to the agent.
260            input.metadata: Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform.
261            input.role: Role of the message sender. Typically `"user"` or `"tool"`. Defaults to `"user"`.
262
263        Returns:
264            The agent session with the new message appended to its `inbox`.
265        """
266        return await self._http.request(
267            f"/api/v1/agent_sessions/{agent_session}/message",
268            method="POST",
269            body=input,
270            response_type=AgentSession,
271        )
AsyncAgentSessionResource(http: archastro.platform.runtime.http_client.HttpClient)
61    def __init__(self, http: HttpClient):
62        self._http = http
async def list( self, *, agent: str | None = None, status: list[str] | None = None, routine_run: list[str] | None = None, exclude_system: bool | None = None, limit: int | None = None) -> archastro.platform.types.common.AgentSessionListResponse:
 64    async def list(
 65        self,
 66        *,
 67        agent: str | None = None,
 68        status: builtins.list[str] | None = None,
 69        routine_run: builtins.list[str] | None = None,
 70        exclude_system: bool | None = None,
 71        limit: int | None = None,
 72    ) -> AgentSessionListResponse:
 73        """
 74        List agent sessions
 75        Returns a flat list of agent sessions visible to the authenticated app,
 76        ordered by creation time descending. Use the `agent`, `status`, and
 77        `routine_run` filters to narrow results.
 78        All filters are optional and can be combined. The `status` and `routine_run`
 79        parameters each accept multiple values; pass the parameter more than once or
 80        as a comma-separated array to match any of the supplied values.
 81        Requires an app-scoped API key. Results are limited to sessions that belong
 82        to agents owned by the authenticated app.
 83
 84        Args:
 85            agent: Filter by agent ID (`agi_...`). Omit to return sessions for all agents in the app.
 86            status: Filter by one or more session statuses. Accepted values are `"pending"`, `"running"`, `"waiting"`, `"completed"`, `"failed"`, and `"cancelled"`. Omit to return sessions in any status.
 87            routine_run: Filter to sessions that were created by the specified routine run IDs. Accepts up to 100 IDs. Omit to return sessions regardless of their originating routine run.
 88            exclude_system: When `true`, omits sessions that were created automatically by the platform rather than by your app. Defaults to `false`.
 89            limit: Maximum number of sessions to return. Defaults to 25; maximum is 100.
 90
 91        Returns:
 92            A list of agent sessions matching the supplied filters.
 93        """
 94        query: dict[str, object] = {}
 95        if agent is not None:
 96            query["agent"] = agent
 97        if status is not None:
 98            query["status"] = status
 99        if routine_run is not None:
100            query["routine_run"] = routine_run
101        if exclude_system is not None:
102            query["exclude_system"] = exclude_system
103        if limit is not None:
104            query["limit"] = limit
105        return await self._http.request(
106            "/api/v1/agent_sessions",
107            query=query,
108            response_type=AgentSessionListResponse,
109        )

List agent sessions Returns a flat list of agent sessions visible to the authenticated app, ordered by creation time descending. Use the agent, status, and routine_run filters to narrow results. All filters are optional and can be combined. The status and routine_run parameters each accept multiple values; pass the parameter more than once or as a comma-separated array to match any of the supplied values. Requires an app-scoped API key. Results are limited to sessions that belong to agents owned by the authenticated app.

Arguments:
  • agent: Filter by agent ID (agi_...). Omit to return sessions for all agents in the app.
  • status: Filter by one or more session statuses. Accepted values are "pending", "running", "waiting", "completed", "failed", and "cancelled". Omit to return sessions in any status.
  • routine_run: Filter to sessions that were created by the specified routine run IDs. Accepts up to 100 IDs. Omit to return sessions regardless of their originating routine run.
  • exclude_system: When true, omits sessions that were created automatically by the platform rather than by your app. Defaults to false.
  • limit: Maximum number of sessions to return. Defaults to 25; maximum is 100.
Returns:

A list of agent sessions matching the supplied filters.

async def create( self, input: AgentSessionCreateInput) -> archastro.platform.types.common.AgentSession:
111    async def create(self, input: AgentSessionCreateInput) -> AgentSession:
112        """
113        Create an agent session
114        Creates a new agent session and enqueues it for execution. The session begins
115        in `"pending"` status and transitions to `"running"` once the platform picks
116        it up. Subscribe to the session stream endpoint to receive real-time status
117        updates.
118        You must supply the ID of an agent that the authenticated app owns and a
119        plain-text `instructions` string describing the task. All other parameters
120        are optional and default to the agent's configured limits when omitted.
121        Set `start_idle` to `true` to create the session without running an opening
122        turn it begins in `"waiting"` status and runs its first turn only once you
123        post a message (see the message endpoint). Use this when you want the first
124        message to drive the session instead of the `instructions` alone.
125        Requires an app-scoped API key. Returns HTTP 201 on success.
126
127        Args:
128            input: Request body.
129            input.agent: Agent ID (`agi_...`) of the agent that will execute the session.
130            input.instructions: Plain-text task description given to the agent as its primary objective for this session.
131            input.max_runs_per_turn: Maximum number of tool invocations allowed within a single agent turn. Defaults to 25.
132            input.max_tokens: Maximum number of tokens the agent may consume across all turns. Defaults to 20,000.
133            input.max_turns: Maximum number of agent turns before the session is automatically terminated. Defaults to 100.
134            input.metadata: Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform.
135            input.name: Human-readable display name for the session. Useful for identifying sessions in the dashboard. `null` if omitted.
136            input.start_idle: When `true`, create the session without running an opening turn. The session starts in `"waiting"` status and runs its first turn only when you post a message. Defaults to `false`, which runs an initial turn from `instructions` immediately.
137            input.team: Team ID (`tea_...`) to associate with this session for access-control and attribution purposes. `null` if omitted.
138            input.thread: Thread ID (`thr_...`) to link this session to an existing conversation thread. `null` if omitted.
139            input.user: User ID to associate with this session for attribution purposes. `null` if omitted.
140
141        Returns:
142            The newly created agent session.
143        """
144        return await self._http.request(
145            "/api/v1/agent_sessions",
146            method="POST",
147            body=input,
148            response_type=AgentSession,
149        )

Create an agent session Creates a new agent session and enqueues it for execution. The session begins in "pending" status and transitions to "running" once the platform picks it up. Subscribe to the session stream endpoint to receive real-time status updates. You must supply the ID of an agent that the authenticated app owns and a plain-text instructions string describing the task. All other parameters are optional and default to the agent's configured limits when omitted. Set start_idle to true to create the session without running an opening turn it begins in "waiting" status and runs its first turn only once you post a message (see the message endpoint). Use this when you want the first message to drive the session instead of the instructions alone. Requires an app-scoped API key. Returns HTTP 201 on success.

Arguments:
  • input: Request body.
  • input.agent: Agent ID (agi_...) of the agent that will execute the session.
  • input.instructions: Plain-text task description given to the agent as its primary objective for this session.
  • input.max_runs_per_turn: Maximum number of tool invocations allowed within a single agent turn. Defaults to 25.
  • input.max_tokens: Maximum number of tokens the agent may consume across all turns. Defaults to 20,000.
  • input.max_turns: Maximum number of agent turns before the session is automatically terminated. Defaults to 100.
  • input.metadata: Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform.
  • input.name: Human-readable display name for the session. Useful for identifying sessions in the dashboard. null if omitted.
  • input.start_idle: When true, create the session without running an opening turn. The session starts in "waiting" status and runs its first turn only when you post a message. Defaults to false, which runs an initial turn from instructions immediately.
  • input.team: Team ID (tea_...) to associate with this session for access-control and attribution purposes. null if omitted.
  • input.thread: Thread ID (thr_...) to link this session to an existing conversation thread. null if omitted.
  • input.user: User ID to associate with this session for attribution purposes. null if omitted.
Returns:

The newly created agent session.

async def delete(self, agent_session: str) -> None:
151    async def delete(self, agent_session: str) -> None:
152        """
153        Delete an agent session
154        Permanently deletes an agent session and its associated data. This action is
155        irreversible the session record, its trajectory, and all inbox messages are
156        removed.
157        To stop a running session without deleting it, use the cancel endpoint
158        instead. The session must be in a terminal state (`"completed"`, `"failed"`,
159        or `"cancelled"`) before it can be deleted; attempting to delete an active
160        session returns 422.
161        Requires an app-scoped API key. Returns HTTP 204 with no body on success.
162
163        Args:
164            agent_session: Agent session ID (`ase_...`) of the session to delete.
165
166        Returns:
167            Empty body. HTTP 204 indicates the session was permanently deleted.
168        """
169        await self._http.request(f"/api/v1/agent_sessions/{agent_session}", method="DELETE")

Delete an agent session Permanently deletes an agent session and its associated data. This action is irreversible the session record, its trajectory, and all inbox messages are removed. To stop a running session without deleting it, use the cancel endpoint instead. The session must be in a terminal state ("completed", "failed", or "cancelled") before it can be deleted; attempting to delete an active session returns 422. Requires an app-scoped API key. Returns HTTP 204 with no body on success.

Arguments:
  • agent_session: Agent session ID (ase_...) of the session to delete.
Returns:

Empty body. HTTP 204 indicates the session was permanently deleted.

async def get(self, agent_session: str) -> archastro.platform.types.common.AgentSession:
171    async def get(self, agent_session: str) -> AgentSession:
172        """
173        Retrieve an agent session
174        Returns the agent session identified by `agent_session`. Use this endpoint
175        to poll session status or to inspect the final result after execution
176        completes.
177        For real-time updates without polling, subscribe to the session stream
178        endpoint instead, which delivers server-sent events whenever the session
179        state changes.
180        Requires an app-scoped API key. The session must belong to an agent owned
181        by the authenticated app.
182
183        Args:
184            agent_session: Agent session ID (`ase_...`) of the session to retrieve.
185
186        Returns:
187            The requested agent session.
188        """
189        return await self._http.request(
190            f"/api/v1/agent_sessions/{agent_session}",
191            response_type=AgentSession,
192        )

Retrieve an agent session Returns the agent session identified by agent_session. Use this endpoint to poll session status or to inspect the final result after execution completes. For real-time updates without polling, subscribe to the session stream endpoint instead, which delivers server-sent events whenever the session state changes. Requires an app-scoped API key. The session must belong to an agent owned by the authenticated app.

Arguments:
  • agent_session: Agent session ID (ase_...) of the session to retrieve.
Returns:

The requested agent session.

async def update( self, agent_session: str, input: AgentSessionUpdateInput) -> archastro.platform.types.common.AgentSession:
194    async def update(self, agent_session: str, input: AgentSessionUpdateInput) -> AgentSession:
195        """
196        Update an agent session
197        Updates the mutable fields of an agent session. Currently only `metadata`
198        can be changed; supply any key-value pairs you want to store alongside the
199        session. Omitting `metadata` leaves it unchanged.
200        This endpoint may be called while the session is in any status, including
201        while it is actively running.
202        Requires an app-scoped API key. The session must belong to an agent owned
203        by the authenticated app.
204
205        Args:
206            agent_session: Agent session ID (`ase_...`) of the session to update.
207            input: Request body.
208            input.metadata: Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged.
209
210        Returns:
211            The agent session with the updated fields applied.
212        """
213        return await self._http.request(
214            f"/api/v1/agent_sessions/{agent_session}",
215            method="PATCH",
216            body=input,
217            response_type=AgentSession,
218        )

Update an agent session Updates the mutable fields of an agent session. Currently only metadata can be changed; supply any key-value pairs you want to store alongside the session. Omitting metadata leaves it unchanged. This endpoint may be called while the session is in any status, including while it is actively running. Requires an app-scoped API key. The session must belong to an agent owned by the authenticated app.

Arguments:
  • agent_session: Agent session ID (ase_...) of the session to update.
  • input: Request body.
  • input.metadata: Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged.
Returns:

The agent session with the updated fields applied.

async def cancel(self, agent_session: str) -> archastro.platform.types.common.AgentSession:
220    async def cancel(self, agent_session: str) -> AgentSession:
221        """
222        Cancel an agent session
223        Requests cancellation of an active agent session. The session status is set
224        to `"cancelled"` and any in-progress agent turn is interrupted as soon as the
225        platform can safely stop it.
226        If the session is already in a terminal state (`"completed"`, `"failed"`, or
227        `"cancelled"`), the call succeeds and returns the session unchanged it is
228        safe to call this endpoint more than once.
229        Requires an app-scoped API key. The session must belong to an agent owned by
230        the authenticated app.
231
232        Args:
233            agent_session: Agent session ID (`ase_...`) of the session to cancel.
234
235        Returns:
236            The agent session after the cancellation request is applied.
237        """
238        return await self._http.request(
239            f"/api/v1/agent_sessions/{agent_session}/cancel",
240            method="POST",
241            response_type=AgentSession,
242        )

Cancel an agent session Requests cancellation of an active agent session. The session status is set to "cancelled" and any in-progress agent turn is interrupted as soon as the platform can safely stop it. If the session is already in a terminal state ("completed", "failed", or "cancelled"), the call succeeds and returns the session unchanged it is safe to call this endpoint more than once. Requires an app-scoped API key. The session must belong to an agent owned by the authenticated app.

Arguments:
  • agent_session: Agent session ID (ase_...) of the session to cancel.
Returns:

The agent session after the cancellation request is applied.

async def message( self, agent_session: str, input: AgentSessionMessageInput) -> archastro.platform.types.common.AgentSession:
244    async def message(self, agent_session: str, input: AgentSessionMessageInput) -> AgentSession:
245        """
246        Send a message to an agent session
247        Appends a message to the inbox of the specified agent session. The agent
248        reads inbox messages at the start of each turn; sending a message to a
249        `"waiting"` session signals it to resume execution.
250        Use `role` to identify the sender type. The default role is `"user"`.
251        Arbitrary key-value metadata may be attached to the message for tracking
252        or display purposes.
253        Requires an app-scoped API key. The session must belong to an agent owned
254        by the authenticated app.
255
256        Args:
257            agent_session: Agent session ID (`ase_...`) of the session whose inbox should receive the message.
258            input: Request body.
259            input.content: Plain-text body of the message to deliver to the agent.
260            input.metadata: Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform.
261            input.role: Role of the message sender. Typically `"user"` or `"tool"`. Defaults to `"user"`.
262
263        Returns:
264            The agent session with the new message appended to its `inbox`.
265        """
266        return await self._http.request(
267            f"/api/v1/agent_sessions/{agent_session}/message",
268            method="POST",
269            body=input,
270            response_type=AgentSession,
271        )

Send a message to an agent session Appends a message to the inbox of the specified agent session. The agent reads inbox messages at the start of each turn; sending a message to a "waiting" session signals it to resume execution. Use role to identify the sender type. The default role is "user". Arbitrary key-value metadata may be attached to the message for tracking or display purposes. Requires an app-scoped API key. The session must belong to an agent owned by the authenticated app.

Arguments:
  • agent_session: Agent session ID (ase_...) of the session whose inbox should receive the message.
  • input: Request body.
  • input.content: Plain-text body of the message to deliver to the agent.
  • input.metadata: Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform.
  • input.role: Role of the message sender. Typically "user" or "tool". Defaults to "user".
Returns:

The agent session with the new message appended to its inbox.

class AgentSessionResource:
274class AgentSessionResource:
275    def __init__(self, http: SyncHttpClient):
276        self._http = http
277
278    def list(
279        self,
280        *,
281        agent: str | None = None,
282        status: builtins.list[str] | None = None,
283        routine_run: builtins.list[str] | None = None,
284        exclude_system: bool | None = None,
285        limit: int | None = None,
286    ) -> AgentSessionListResponse:
287        """
288        List agent sessions
289        Returns a flat list of agent sessions visible to the authenticated app,
290        ordered by creation time descending. Use the `agent`, `status`, and
291        `routine_run` filters to narrow results.
292        All filters are optional and can be combined. The `status` and `routine_run`
293        parameters each accept multiple values; pass the parameter more than once or
294        as a comma-separated array to match any of the supplied values.
295        Requires an app-scoped API key. Results are limited to sessions that belong
296        to agents owned by the authenticated app.
297
298        Args:
299            agent: Filter by agent ID (`agi_...`). Omit to return sessions for all agents in the app.
300            status: Filter by one or more session statuses. Accepted values are `"pending"`, `"running"`, `"waiting"`, `"completed"`, `"failed"`, and `"cancelled"`. Omit to return sessions in any status.
301            routine_run: Filter to sessions that were created by the specified routine run IDs. Accepts up to 100 IDs. Omit to return sessions regardless of their originating routine run.
302            exclude_system: When `true`, omits sessions that were created automatically by the platform rather than by your app. Defaults to `false`.
303            limit: Maximum number of sessions to return. Defaults to 25; maximum is 100.
304
305        Returns:
306            A list of agent sessions matching the supplied filters.
307        """
308        query: dict[str, object] = {}
309        if agent is not None:
310            query["agent"] = agent
311        if status is not None:
312            query["status"] = status
313        if routine_run is not None:
314            query["routine_run"] = routine_run
315        if exclude_system is not None:
316            query["exclude_system"] = exclude_system
317        if limit is not None:
318            query["limit"] = limit
319        return self._http.request(
320            "/api/v1/agent_sessions",
321            query=query,
322            response_type=AgentSessionListResponse,
323        )
324
325    def create(self, input: AgentSessionCreateInput) -> AgentSession:
326        """
327        Create an agent session
328        Creates a new agent session and enqueues it for execution. The session begins
329        in `"pending"` status and transitions to `"running"` once the platform picks
330        it up. Subscribe to the session stream endpoint to receive real-time status
331        updates.
332        You must supply the ID of an agent that the authenticated app owns and a
333        plain-text `instructions` string describing the task. All other parameters
334        are optional and default to the agent's configured limits when omitted.
335        Set `start_idle` to `true` to create the session without running an opening
336        turn it begins in `"waiting"` status and runs its first turn only once you
337        post a message (see the message endpoint). Use this when you want the first
338        message to drive the session instead of the `instructions` alone.
339        Requires an app-scoped API key. Returns HTTP 201 on success.
340
341        Args:
342            input: Request body.
343            input.agent: Agent ID (`agi_...`) of the agent that will execute the session.
344            input.instructions: Plain-text task description given to the agent as its primary objective for this session.
345            input.max_runs_per_turn: Maximum number of tool invocations allowed within a single agent turn. Defaults to 25.
346            input.max_tokens: Maximum number of tokens the agent may consume across all turns. Defaults to 20,000.
347            input.max_turns: Maximum number of agent turns before the session is automatically terminated. Defaults to 100.
348            input.metadata: Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform.
349            input.name: Human-readable display name for the session. Useful for identifying sessions in the dashboard. `null` if omitted.
350            input.start_idle: When `true`, create the session without running an opening turn. The session starts in `"waiting"` status and runs its first turn only when you post a message. Defaults to `false`, which runs an initial turn from `instructions` immediately.
351            input.team: Team ID (`tea_...`) to associate with this session for access-control and attribution purposes. `null` if omitted.
352            input.thread: Thread ID (`thr_...`) to link this session to an existing conversation thread. `null` if omitted.
353            input.user: User ID to associate with this session for attribution purposes. `null` if omitted.
354
355        Returns:
356            The newly created agent session.
357        """
358        return self._http.request(
359            "/api/v1/agent_sessions",
360            method="POST",
361            body=input,
362            response_type=AgentSession,
363        )
364
365    def delete(self, agent_session: str) -> None:
366        """
367        Delete an agent session
368        Permanently deletes an agent session and its associated data. This action is
369        irreversible the session record, its trajectory, and all inbox messages are
370        removed.
371        To stop a running session without deleting it, use the cancel endpoint
372        instead. The session must be in a terminal state (`"completed"`, `"failed"`,
373        or `"cancelled"`) before it can be deleted; attempting to delete an active
374        session returns 422.
375        Requires an app-scoped API key. Returns HTTP 204 with no body on success.
376
377        Args:
378            agent_session: Agent session ID (`ase_...`) of the session to delete.
379
380        Returns:
381            Empty body. HTTP 204 indicates the session was permanently deleted.
382        """
383        self._http.request(f"/api/v1/agent_sessions/{agent_session}", method="DELETE")
384
385    def get(self, agent_session: str) -> AgentSession:
386        """
387        Retrieve an agent session
388        Returns the agent session identified by `agent_session`. Use this endpoint
389        to poll session status or to inspect the final result after execution
390        completes.
391        For real-time updates without polling, subscribe to the session stream
392        endpoint instead, which delivers server-sent events whenever the session
393        state changes.
394        Requires an app-scoped API key. The session must belong to an agent owned
395        by the authenticated app.
396
397        Args:
398            agent_session: Agent session ID (`ase_...`) of the session to retrieve.
399
400        Returns:
401            The requested agent session.
402        """
403        return self._http.request(
404            f"/api/v1/agent_sessions/{agent_session}",
405            response_type=AgentSession,
406        )
407
408    def update(self, agent_session: str, input: AgentSessionUpdateInput) -> AgentSession:
409        """
410        Update an agent session
411        Updates the mutable fields of an agent session. Currently only `metadata`
412        can be changed; supply any key-value pairs you want to store alongside the
413        session. Omitting `metadata` leaves it unchanged.
414        This endpoint may be called while the session is in any status, including
415        while it is actively running.
416        Requires an app-scoped API key. The session must belong to an agent owned
417        by the authenticated app.
418
419        Args:
420            agent_session: Agent session ID (`ase_...`) of the session to update.
421            input: Request body.
422            input.metadata: Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged.
423
424        Returns:
425            The agent session with the updated fields applied.
426        """
427        return self._http.request(
428            f"/api/v1/agent_sessions/{agent_session}",
429            method="PATCH",
430            body=input,
431            response_type=AgentSession,
432        )
433
434    def cancel(self, agent_session: str) -> AgentSession:
435        """
436        Cancel an agent session
437        Requests cancellation of an active agent session. The session status is set
438        to `"cancelled"` and any in-progress agent turn is interrupted as soon as the
439        platform can safely stop it.
440        If the session is already in a terminal state (`"completed"`, `"failed"`, or
441        `"cancelled"`), the call succeeds and returns the session unchanged it is
442        safe to call this endpoint more than once.
443        Requires an app-scoped API key. The session must belong to an agent owned by
444        the authenticated app.
445
446        Args:
447            agent_session: Agent session ID (`ase_...`) of the session to cancel.
448
449        Returns:
450            The agent session after the cancellation request is applied.
451        """
452        return self._http.request(
453            f"/api/v1/agent_sessions/{agent_session}/cancel",
454            method="POST",
455            response_type=AgentSession,
456        )
457
458    def message(self, agent_session: str, input: AgentSessionMessageInput) -> AgentSession:
459        """
460        Send a message to an agent session
461        Appends a message to the inbox of the specified agent session. The agent
462        reads inbox messages at the start of each turn; sending a message to a
463        `"waiting"` session signals it to resume execution.
464        Use `role` to identify the sender type. The default role is `"user"`.
465        Arbitrary key-value metadata may be attached to the message for tracking
466        or display purposes.
467        Requires an app-scoped API key. The session must belong to an agent owned
468        by the authenticated app.
469
470        Args:
471            agent_session: Agent session ID (`ase_...`) of the session whose inbox should receive the message.
472            input: Request body.
473            input.content: Plain-text body of the message to deliver to the agent.
474            input.metadata: Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform.
475            input.role: Role of the message sender. Typically `"user"` or `"tool"`. Defaults to `"user"`.
476
477        Returns:
478            The agent session with the new message appended to its `inbox`.
479        """
480        return self._http.request(
481            f"/api/v1/agent_sessions/{agent_session}/message",
482            method="POST",
483            body=input,
484            response_type=AgentSession,
485        )
AgentSessionResource(http: archastro.platform.runtime.http_client.SyncHttpClient)
275    def __init__(self, http: SyncHttpClient):
276        self._http = http
def list( self, *, agent: str | None = None, status: list[str] | None = None, routine_run: list[str] | None = None, exclude_system: bool | None = None, limit: int | None = None) -> archastro.platform.types.common.AgentSessionListResponse:
278    def list(
279        self,
280        *,
281        agent: str | None = None,
282        status: builtins.list[str] | None = None,
283        routine_run: builtins.list[str] | None = None,
284        exclude_system: bool | None = None,
285        limit: int | None = None,
286    ) -> AgentSessionListResponse:
287        """
288        List agent sessions
289        Returns a flat list of agent sessions visible to the authenticated app,
290        ordered by creation time descending. Use the `agent`, `status`, and
291        `routine_run` filters to narrow results.
292        All filters are optional and can be combined. The `status` and `routine_run`
293        parameters each accept multiple values; pass the parameter more than once or
294        as a comma-separated array to match any of the supplied values.
295        Requires an app-scoped API key. Results are limited to sessions that belong
296        to agents owned by the authenticated app.
297
298        Args:
299            agent: Filter by agent ID (`agi_...`). Omit to return sessions for all agents in the app.
300            status: Filter by one or more session statuses. Accepted values are `"pending"`, `"running"`, `"waiting"`, `"completed"`, `"failed"`, and `"cancelled"`. Omit to return sessions in any status.
301            routine_run: Filter to sessions that were created by the specified routine run IDs. Accepts up to 100 IDs. Omit to return sessions regardless of their originating routine run.
302            exclude_system: When `true`, omits sessions that were created automatically by the platform rather than by your app. Defaults to `false`.
303            limit: Maximum number of sessions to return. Defaults to 25; maximum is 100.
304
305        Returns:
306            A list of agent sessions matching the supplied filters.
307        """
308        query: dict[str, object] = {}
309        if agent is not None:
310            query["agent"] = agent
311        if status is not None:
312            query["status"] = status
313        if routine_run is not None:
314            query["routine_run"] = routine_run
315        if exclude_system is not None:
316            query["exclude_system"] = exclude_system
317        if limit is not None:
318            query["limit"] = limit
319        return self._http.request(
320            "/api/v1/agent_sessions",
321            query=query,
322            response_type=AgentSessionListResponse,
323        )

List agent sessions Returns a flat list of agent sessions visible to the authenticated app, ordered by creation time descending. Use the agent, status, and routine_run filters to narrow results. All filters are optional and can be combined. The status and routine_run parameters each accept multiple values; pass the parameter more than once or as a comma-separated array to match any of the supplied values. Requires an app-scoped API key. Results are limited to sessions that belong to agents owned by the authenticated app.

Arguments:
  • agent: Filter by agent ID (agi_...). Omit to return sessions for all agents in the app.
  • status: Filter by one or more session statuses. Accepted values are "pending", "running", "waiting", "completed", "failed", and "cancelled". Omit to return sessions in any status.
  • routine_run: Filter to sessions that were created by the specified routine run IDs. Accepts up to 100 IDs. Omit to return sessions regardless of their originating routine run.
  • exclude_system: When true, omits sessions that were created automatically by the platform rather than by your app. Defaults to false.
  • limit: Maximum number of sessions to return. Defaults to 25; maximum is 100.
Returns:

A list of agent sessions matching the supplied filters.

def create( self, input: AgentSessionCreateInput) -> archastro.platform.types.common.AgentSession:
325    def create(self, input: AgentSessionCreateInput) -> AgentSession:
326        """
327        Create an agent session
328        Creates a new agent session and enqueues it for execution. The session begins
329        in `"pending"` status and transitions to `"running"` once the platform picks
330        it up. Subscribe to the session stream endpoint to receive real-time status
331        updates.
332        You must supply the ID of an agent that the authenticated app owns and a
333        plain-text `instructions` string describing the task. All other parameters
334        are optional and default to the agent's configured limits when omitted.
335        Set `start_idle` to `true` to create the session without running an opening
336        turn it begins in `"waiting"` status and runs its first turn only once you
337        post a message (see the message endpoint). Use this when you want the first
338        message to drive the session instead of the `instructions` alone.
339        Requires an app-scoped API key. Returns HTTP 201 on success.
340
341        Args:
342            input: Request body.
343            input.agent: Agent ID (`agi_...`) of the agent that will execute the session.
344            input.instructions: Plain-text task description given to the agent as its primary objective for this session.
345            input.max_runs_per_turn: Maximum number of tool invocations allowed within a single agent turn. Defaults to 25.
346            input.max_tokens: Maximum number of tokens the agent may consume across all turns. Defaults to 20,000.
347            input.max_turns: Maximum number of agent turns before the session is automatically terminated. Defaults to 100.
348            input.metadata: Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform.
349            input.name: Human-readable display name for the session. Useful for identifying sessions in the dashboard. `null` if omitted.
350            input.start_idle: When `true`, create the session without running an opening turn. The session starts in `"waiting"` status and runs its first turn only when you post a message. Defaults to `false`, which runs an initial turn from `instructions` immediately.
351            input.team: Team ID (`tea_...`) to associate with this session for access-control and attribution purposes. `null` if omitted.
352            input.thread: Thread ID (`thr_...`) to link this session to an existing conversation thread. `null` if omitted.
353            input.user: User ID to associate with this session for attribution purposes. `null` if omitted.
354
355        Returns:
356            The newly created agent session.
357        """
358        return self._http.request(
359            "/api/v1/agent_sessions",
360            method="POST",
361            body=input,
362            response_type=AgentSession,
363        )

Create an agent session Creates a new agent session and enqueues it for execution. The session begins in "pending" status and transitions to "running" once the platform picks it up. Subscribe to the session stream endpoint to receive real-time status updates. You must supply the ID of an agent that the authenticated app owns and a plain-text instructions string describing the task. All other parameters are optional and default to the agent's configured limits when omitted. Set start_idle to true to create the session without running an opening turn it begins in "waiting" status and runs its first turn only once you post a message (see the message endpoint). Use this when you want the first message to drive the session instead of the instructions alone. Requires an app-scoped API key. Returns HTTP 201 on success.

Arguments:
  • input: Request body.
  • input.agent: Agent ID (agi_...) of the agent that will execute the session.
  • input.instructions: Plain-text task description given to the agent as its primary objective for this session.
  • input.max_runs_per_turn: Maximum number of tool invocations allowed within a single agent turn. Defaults to 25.
  • input.max_tokens: Maximum number of tokens the agent may consume across all turns. Defaults to 20,000.
  • input.max_turns: Maximum number of agent turns before the session is automatically terminated. Defaults to 100.
  • input.metadata: Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform.
  • input.name: Human-readable display name for the session. Useful for identifying sessions in the dashboard. null if omitted.
  • input.start_idle: When true, create the session without running an opening turn. The session starts in "waiting" status and runs its first turn only when you post a message. Defaults to false, which runs an initial turn from instructions immediately.
  • input.team: Team ID (tea_...) to associate with this session for access-control and attribution purposes. null if omitted.
  • input.thread: Thread ID (thr_...) to link this session to an existing conversation thread. null if omitted.
  • input.user: User ID to associate with this session for attribution purposes. null if omitted.
Returns:

The newly created agent session.

def delete(self, agent_session: str) -> None:
365    def delete(self, agent_session: str) -> None:
366        """
367        Delete an agent session
368        Permanently deletes an agent session and its associated data. This action is
369        irreversible the session record, its trajectory, and all inbox messages are
370        removed.
371        To stop a running session without deleting it, use the cancel endpoint
372        instead. The session must be in a terminal state (`"completed"`, `"failed"`,
373        or `"cancelled"`) before it can be deleted; attempting to delete an active
374        session returns 422.
375        Requires an app-scoped API key. Returns HTTP 204 with no body on success.
376
377        Args:
378            agent_session: Agent session ID (`ase_...`) of the session to delete.
379
380        Returns:
381            Empty body. HTTP 204 indicates the session was permanently deleted.
382        """
383        self._http.request(f"/api/v1/agent_sessions/{agent_session}", method="DELETE")

Delete an agent session Permanently deletes an agent session and its associated data. This action is irreversible the session record, its trajectory, and all inbox messages are removed. To stop a running session without deleting it, use the cancel endpoint instead. The session must be in a terminal state ("completed", "failed", or "cancelled") before it can be deleted; attempting to delete an active session returns 422. Requires an app-scoped API key. Returns HTTP 204 with no body on success.

Arguments:
  • agent_session: Agent session ID (ase_...) of the session to delete.
Returns:

Empty body. HTTP 204 indicates the session was permanently deleted.

def get(self, agent_session: str) -> archastro.platform.types.common.AgentSession:
385    def get(self, agent_session: str) -> AgentSession:
386        """
387        Retrieve an agent session
388        Returns the agent session identified by `agent_session`. Use this endpoint
389        to poll session status or to inspect the final result after execution
390        completes.
391        For real-time updates without polling, subscribe to the session stream
392        endpoint instead, which delivers server-sent events whenever the session
393        state changes.
394        Requires an app-scoped API key. The session must belong to an agent owned
395        by the authenticated app.
396
397        Args:
398            agent_session: Agent session ID (`ase_...`) of the session to retrieve.
399
400        Returns:
401            The requested agent session.
402        """
403        return self._http.request(
404            f"/api/v1/agent_sessions/{agent_session}",
405            response_type=AgentSession,
406        )

Retrieve an agent session Returns the agent session identified by agent_session. Use this endpoint to poll session status or to inspect the final result after execution completes. For real-time updates without polling, subscribe to the session stream endpoint instead, which delivers server-sent events whenever the session state changes. Requires an app-scoped API key. The session must belong to an agent owned by the authenticated app.

Arguments:
  • agent_session: Agent session ID (ase_...) of the session to retrieve.
Returns:

The requested agent session.

def update( self, agent_session: str, input: AgentSessionUpdateInput) -> archastro.platform.types.common.AgentSession:
408    def update(self, agent_session: str, input: AgentSessionUpdateInput) -> AgentSession:
409        """
410        Update an agent session
411        Updates the mutable fields of an agent session. Currently only `metadata`
412        can be changed; supply any key-value pairs you want to store alongside the
413        session. Omitting `metadata` leaves it unchanged.
414        This endpoint may be called while the session is in any status, including
415        while it is actively running.
416        Requires an app-scoped API key. The session must belong to an agent owned
417        by the authenticated app.
418
419        Args:
420            agent_session: Agent session ID (`ase_...`) of the session to update.
421            input: Request body.
422            input.metadata: Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged.
423
424        Returns:
425            The agent session with the updated fields applied.
426        """
427        return self._http.request(
428            f"/api/v1/agent_sessions/{agent_session}",
429            method="PATCH",
430            body=input,
431            response_type=AgentSession,
432        )

Update an agent session Updates the mutable fields of an agent session. Currently only metadata can be changed; supply any key-value pairs you want to store alongside the session. Omitting metadata leaves it unchanged. This endpoint may be called while the session is in any status, including while it is actively running. Requires an app-scoped API key. The session must belong to an agent owned by the authenticated app.

Arguments:
  • agent_session: Agent session ID (ase_...) of the session to update.
  • input: Request body.
  • input.metadata: Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged.
Returns:

The agent session with the updated fields applied.

def cancel(self, agent_session: str) -> archastro.platform.types.common.AgentSession:
434    def cancel(self, agent_session: str) -> AgentSession:
435        """
436        Cancel an agent session
437        Requests cancellation of an active agent session. The session status is set
438        to `"cancelled"` and any in-progress agent turn is interrupted as soon as the
439        platform can safely stop it.
440        If the session is already in a terminal state (`"completed"`, `"failed"`, or
441        `"cancelled"`), the call succeeds and returns the session unchanged it is
442        safe to call this endpoint more than once.
443        Requires an app-scoped API key. The session must belong to an agent owned by
444        the authenticated app.
445
446        Args:
447            agent_session: Agent session ID (`ase_...`) of the session to cancel.
448
449        Returns:
450            The agent session after the cancellation request is applied.
451        """
452        return self._http.request(
453            f"/api/v1/agent_sessions/{agent_session}/cancel",
454            method="POST",
455            response_type=AgentSession,
456        )

Cancel an agent session Requests cancellation of an active agent session. The session status is set to "cancelled" and any in-progress agent turn is interrupted as soon as the platform can safely stop it. If the session is already in a terminal state ("completed", "failed", or "cancelled"), the call succeeds and returns the session unchanged it is safe to call this endpoint more than once. Requires an app-scoped API key. The session must belong to an agent owned by the authenticated app.

Arguments:
  • agent_session: Agent session ID (ase_...) of the session to cancel.
Returns:

The agent session after the cancellation request is applied.

def message( self, agent_session: str, input: AgentSessionMessageInput) -> archastro.platform.types.common.AgentSession:
458    def message(self, agent_session: str, input: AgentSessionMessageInput) -> AgentSession:
459        """
460        Send a message to an agent session
461        Appends a message to the inbox of the specified agent session. The agent
462        reads inbox messages at the start of each turn; sending a message to a
463        `"waiting"` session signals it to resume execution.
464        Use `role` to identify the sender type. The default role is `"user"`.
465        Arbitrary key-value metadata may be attached to the message for tracking
466        or display purposes.
467        Requires an app-scoped API key. The session must belong to an agent owned
468        by the authenticated app.
469
470        Args:
471            agent_session: Agent session ID (`ase_...`) of the session whose inbox should receive the message.
472            input: Request body.
473            input.content: Plain-text body of the message to deliver to the agent.
474            input.metadata: Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform.
475            input.role: Role of the message sender. Typically `"user"` or `"tool"`. Defaults to `"user"`.
476
477        Returns:
478            The agent session with the new message appended to its `inbox`.
479        """
480        return self._http.request(
481            f"/api/v1/agent_sessions/{agent_session}/message",
482            method="POST",
483            body=input,
484            response_type=AgentSession,
485        )

Send a message to an agent session Appends a message to the inbox of the specified agent session. The agent reads inbox messages at the start of each turn; sending a message to a "waiting" session signals it to resume execution. Use role to identify the sender type. The default role is "user". Arbitrary key-value metadata may be attached to the message for tracking or display purposes. Requires an app-scoped API key. The session must belong to an agent owned by the authenticated app.

Arguments:
  • agent_session: Agent session ID (ase_...) of the session whose inbox should receive the message.
  • input: Request body.
  • input.content: Plain-text body of the message to deliver to the agent.
  • input.metadata: Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform.
  • input.role: Role of the message sender. Typically "user" or "tool". Defaults to "user".
Returns:

The agent session with the new message appended to its inbox.