> ## Documentation Index
> Fetch the complete documentation index at: https://docs.niadra.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Ler a memória de trabalho

> O estado de um escopo e agente: versão 0 e corpo vazio antes da primeira escrita. Quem escreveu lê a própria versão ou uma mais nova.



## OpenAPI

````yaml openapi/pt/cell.json POST /v1/agent-state/read
openapi: 3.1.0
info:
  title: API de dados da Niadra
  version: '1'
  description: >-
    Escrita, contexto, histórico, objetos, identidade, privacidade e governança
    de um espaço. Cada espaço tem um endereço estável, com o espaço e a região
    no nome.
servers:
  - url: https://{space}.{region}.api.niadra.com
    variables:
      space:
        default: acme-prod
        description: O espaço, que vem na chave de fonte.
      region:
        default: us-east-2
        description: A região do espaço, que também vem na chave.
security: []
paths:
  /v1/agent-state/read:
    post:
      tags:
        - state
      summary: Ler a memória de trabalho
      description: >-
        O estado de trabalho de um escopo e agente: versão 0 e corpo vazio
        quando nunca foi escrito.


        **Autenticação.** Chave de fonte: `Authorization: Bearer nia_sk_...`.
        Escopo exigido: `agent_state`. Só responde num espaço com a
        funcionalidade `agent_state` ligada (o documento `features`); num espaço
        sem ela, 404.
      operationId: read_agent_state_v1_agent_state_read_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentStateReadRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentState'
          description: Resposta de sucesso.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: O pedido não bate com o contrato.
      security:
        - sourceKey: []
      x-codeSamples:
        - lang: python
          label: Python
          source: >-
            state = conversation.agent_state.get()  # version 0 and an empty
            body before the first write

            step = state.body.get("step")
        - lang: typescript
          label: TypeScript
          source: >-
            const state = await convo.agentState.get(); // version 0 and an
            empty body before the first write

            const step = state.body.step;
components:
  schemas:
    AgentStateReadRequest:
      additionalProperties: false
      properties:
        agent:
          maxLength: 256
          minLength: 1
          title: Agent
          type: string
        scope:
          $ref: '#/components/schemas/AgentStateScope'
      required:
        - scope
        - agent
      title: AgentStateReadRequest
      type: object
    AgentState:
      additionalProperties: false
      properties:
        body:
          additionalProperties: true
          title: Body
          type: object
        updated_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Updated At
        version:
          title: Version
          type: integer
      required:
        - version
      title: AgentState
      type: object
    Problem:
      additionalProperties: false
      description: >-
        Detalhes do problema no formato da RFC 9457; `code` vem do catálogo de
        erros versionado.
      properties:
        code:
          title: Code
          type: string
        detail:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Detail
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Request Id
        status:
          title: Status
          type: integer
        title:
          title: Title
          type: string
        type:
          default: about:blank
          title: Type
          type: string
      required:
        - title
        - status
        - code
      title: Problem
      type: object
    AgentStateScope:
      additionalProperties: false
      description: >-
        A que um estado de trabalho pertence. O id viaja no corpo, nunca numa
        URL: um id de conversa pode parecer um telefone.
      properties:
        id:
          maxLength: 512
          minLength: 1
          title: Id
          type: string
        kind:
          enum:
            - conversation
            - task
            - object
            - subject
          title: Kind
          type: string
      required:
        - kind
        - id
      title: AgentStateScope
      type: object
  securitySchemes:
    sourceKey:
      type: http
      scheme: bearer
      description: nia_sk_...

````