archastro.platform.v1.resources.agent_sessions

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

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

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:
160    async def delete(self, agent_session: str) -> None:
161        """
162        Delete an agent session
163        Permanently deletes an agent session and its associated data. This action is
164        irreversible the session record, its trajectory, and all inbox messages are
165        removed.
166        To stop a running session without deleting it, use the cancel endpoint
167        instead. The session must be in a terminal state (`"completed"`, `"failed"`,
168        or `"cancelled"`) before it can be deleted; attempting to delete an active
169        session returns 422.
170        Requires an app-scoped API key. Returns HTTP 204 with no body on success.
171
172        Args:
173            agent_session: Agent session ID (`ase_...`) of the session to delete.
174
175        Returns:
176            Empty body. HTTP 204 indicates the session was permanently deleted.
177        """
178        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:
180    async def get(self, agent_session: str) -> AgentSession:
181        """
182        Retrieve an agent session
183        Returns the agent session identified by `agent_session`. Use this endpoint
184        to poll session status or to inspect the final result after execution
185        completes.
186        For real-time updates without polling, subscribe to the session stream
187        endpoint instead, which delivers server-sent events whenever the session
188        state changes.
189        Requires an app-scoped API key. The session must belong to an agent owned
190        by the authenticated app.
191
192        Args:
193            agent_session: Agent session ID (`ase_...`) of the session to retrieve.
194
195        Returns:
196            The requested agent session.
197        """
198        return await self._http.request(
199            f"/api/v1/agent_sessions/{agent_session}",
200            response_type=AgentSession,
201        )

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

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

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

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.

async def stream( self, agent_session: str) -> AsyncIterator[AgentSessionStreamEventSessionUpdate]:
282    async def stream(self, agent_session: str) -> AsyncIterator[AgentSessionStreamEvent]:
283        """
284        Stream agent session status
285        Opens a Server-Sent Events connection that emits a `session_update` event
286        whenever the agent session's status changes, replaying the current status on
287        connect and closing on a terminal status (`completed`, `failed`, `cancelled`).
288
289        Args:
290            agent_session: ID of the agent session to stream.
291
292        Returns:
293            Server-Sent Events stream
294        """
295        async for event in self._http.stream_sse(f"/api/v1/agent_sessions/{agent_session}/stream"):
296            yield event

Stream agent session status Opens a Server-Sent Events connection that emits a session_update event whenever the agent session's status changes, replaying the current status on connect and closing on a terminal status (completed, failed, cancelled).

Arguments:
  • agent_session: ID of the agent session to stream.
Returns:

Server-Sent Events stream

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

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 IDs (agi_...). Omit to return sessions for all agents in the app. Multiple values are OR'd.
  • 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:
350    def create(self, input: AgentSessionCreateInput) -> AgentSession:
351        """
352        Create an agent session
353        Creates a new agent session and enqueues it for execution. The session begins
354        in `"pending"` status and transitions to `"running"` once the platform picks
355        it up. Subscribe to the session stream endpoint to receive real-time status
356        updates.
357        You must supply the ID of an agent that the authenticated app owns and a
358        plain-text `instructions` string describing the task. All other parameters
359        are optional and default to the agent's configured limits when omitted.
360        Set `start_idle` to `true` to create the session without running an opening
361        turn it begins in `"waiting"` status and runs its first turn only once you
362        post a message (see the message endpoint). Use this when you want the first
363        message to drive the session instead of the `instructions` alone.
364        Requires an app-scoped API key. Returns HTTP 201 on success.
365
366        Args:
367            input: Request body.
368            input.agent: Agent ID (`agi_...`) of the agent that will execute the session.
369            input.instructions: Plain-text task description given to the agent as its primary objective for this session.
370            input.max_runs_per_turn: Maximum number of tool invocations allowed within a single agent turn. Defaults to 25.
371            input.max_tokens: Maximum number of tokens the agent may consume across all turns. Defaults to 20,000.
372            input.max_turns: Maximum number of agent turns before the session is automatically terminated. Defaults to 100.
373            input.metadata: Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform.
374            input.name: Human-readable display name for the session. Useful for identifying sessions in the dashboard. `null` if omitted.
375            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.
376            input.team: Team ID (`tea_...`) to associate with this session for access-control and attribution purposes. `null` if omitted.
377            input.thread: Thread ID (`thr_...`) to link this session to an existing conversation thread. `null` if omitted.
378            input.user: User ID to associate with this session for attribution purposes. `null` if omitted.
379
380        Returns:
381            The newly created agent session.
382        """
383        return self._http.request(
384            "/api/v1/agent_sessions",
385            method="POST",
386            body=input,
387            response_type=AgentSession,
388        )

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:
390    def delete(self, agent_session: str) -> None:
391        """
392        Delete an agent session
393        Permanently deletes an agent session and its associated data. This action is
394        irreversible the session record, its trajectory, and all inbox messages are
395        removed.
396        To stop a running session without deleting it, use the cancel endpoint
397        instead. The session must be in a terminal state (`"completed"`, `"failed"`,
398        or `"cancelled"`) before it can be deleted; attempting to delete an active
399        session returns 422.
400        Requires an app-scoped API key. Returns HTTP 204 with no body on success.
401
402        Args:
403            agent_session: Agent session ID (`ase_...`) of the session to delete.
404
405        Returns:
406            Empty body. HTTP 204 indicates the session was permanently deleted.
407        """
408        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:
410    def get(self, agent_session: str) -> AgentSession:
411        """
412        Retrieve an agent session
413        Returns the agent session identified by `agent_session`. Use this endpoint
414        to poll session status or to inspect the final result after execution
415        completes.
416        For real-time updates without polling, subscribe to the session stream
417        endpoint instead, which delivers server-sent events whenever the session
418        state changes.
419        Requires an app-scoped API key. The session must belong to an agent owned
420        by the authenticated app.
421
422        Args:
423            agent_session: Agent session ID (`ase_...`) of the session to retrieve.
424
425        Returns:
426            The requested agent session.
427        """
428        return self._http.request(
429            f"/api/v1/agent_sessions/{agent_session}",
430            response_type=AgentSession,
431        )

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:
433    def update(self, agent_session: str, input: AgentSessionUpdateInput) -> AgentSession:
434        """
435        Update an agent session
436        Updates the mutable fields of an agent session. Currently only `metadata`
437        can be changed; supply any key-value pairs you want to store alongside the
438        session. Omitting `metadata` leaves it unchanged.
439        This endpoint may be called while the session is in any status, including
440        while it is actively running.
441        Requires an app-scoped API key. The session must belong to an agent owned
442        by the authenticated app.
443
444        Args:
445            agent_session: Agent session ID (`ase_...`) of the session to update.
446            input: Request body.
447            input.metadata: Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged.
448
449        Returns:
450            The agent session with the updated fields applied.
451        """
452        return self._http.request(
453            f"/api/v1/agent_sessions/{agent_session}",
454            method="PATCH",
455            body=input,
456            response_type=AgentSession,
457        )

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:
459    def cancel(self, agent_session: str) -> AgentSession:
460        """
461        Cancel an agent session
462        Requests cancellation of an active agent session. The session status is set
463        to `"cancelled"` and any in-progress agent turn is interrupted as soon as the
464        platform can safely stop it.
465        If the session is already in a terminal state (`"completed"`, `"failed"`, or
466        `"cancelled"`), the call succeeds and returns the session unchanged it is
467        safe to call this endpoint more than once.
468        Requires an app-scoped API key. The session must belong to an agent owned by
469        the authenticated app.
470
471        Args:
472            agent_session: Agent session ID (`ase_...`) of the session to cancel.
473
474        Returns:
475            The agent session after the cancellation request is applied.
476        """
477        return self._http.request(
478            f"/api/v1/agent_sessions/{agent_session}/cancel",
479            method="POST",
480            response_type=AgentSession,
481        )

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:
483    def message(self, agent_session: str, input: AgentSessionMessageInput) -> AgentSession:
484        """
485        Send a message to an agent session
486        Appends a message to the inbox of the specified agent session. The agent
487        reads inbox messages at the start of each turn; sending a message to a
488        `"waiting"` session signals it to resume execution.
489        Use `role` to identify the sender type. The default role is `"user"`.
490        Arbitrary key-value metadata may be attached to the message for tracking
491        or display purposes.
492        Requires an app-scoped API key. The session must belong to an agent owned
493        by the authenticated app.
494
495        Args:
496            agent_session: Agent session ID (`ase_...`) of the session whose inbox should receive the message.
497            input: Request body.
498            input.content: Plain-text body of the message to deliver to the agent.
499            input.metadata: Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform.
500            input.role: Role of the message sender. Typically `"user"` or `"tool"`. Defaults to `"user"`.
501
502        Returns:
503            The agent session with the new message appended to its `inbox`.
504        """
505        return self._http.request(
506            f"/api/v1/agent_sessions/{agent_session}/message",
507            method="POST",
508            body=input,
509            response_type=AgentSession,
510        )

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.

def stream( self, agent_session: str) -> Iterator[AgentSessionStreamEventSessionUpdate]:
512    def stream(self, agent_session: str) -> Iterator[AgentSessionStreamEvent]:
513        """
514        Stream agent session status
515        Opens a Server-Sent Events connection that emits a `session_update` event
516        whenever the agent session's status changes, replaying the current status on
517        connect and closing on a terminal status (`completed`, `failed`, `cancelled`).
518
519        Args:
520            agent_session: ID of the agent session to stream.
521
522        Returns:
523            Server-Sent Events stream
524        """
525        yield from self._http.stream_sse_sync(f"/api/v1/agent_sessions/{agent_session}/stream")

Stream agent session status Opens a Server-Sent Events connection that emits a session_update event whenever the agent session's status changes, replaying the current status on connect and closing on a terminal status (completed, failed, cancelled).

Arguments:
  • agent_session: ID of the agent session to stream.
Returns:

Server-Sent Events stream