# Inspect sessions and usage (/en/docs/developers/agent/monitor)



Use sessions, users and spending to assess your embed, then inspect an individual conversation. This page is for service agents already receiving traffic from a host application.



## Prepare the records [#prepare]

With an authorized organization account, open **Service agents → Select agent → Operations** in the Dashboard. Labels below describe the current Chinese Dashboard. Have the time, end-user ID and integration type ready.

Send a recognizable test message from your host website and receive a reply before checking operations data. Dashboard Playground records are excluded from customer operations statistics. They cannot prove customer traffic or spending was recorded.

## Inspect the overview [#overview]

Open &#x2A;*Overview (概览)** and choose 24 hours, 7 days or 30 days. Aggregate overview statistics are currently Dashboard-only; there is no corresponding public API.

| Information                                        | Question it answers                                                                       |
| -------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| Sessions, active end users, cost, cost per session | Has traffic or the cost of serving a conversation changed?                                |
| Positive feedback rate                             | What proportion of rated responses received positive feedback?                            |
| P50 first-token latency, error rate                | Has the initial response slowed, or have runs failed?                                     |
| Source and version distribution                    | Does traffic come from Kit, iframe, Hosted, API or automation? Is the new version in use? |
| Attention counters and top 5 tools                 | Are origins blocked, budgets reached or tool calls unusual?                               |

**Expected:** Session trends and version distribution cover the selected period. A metric without samples displays “—”, not zero. The 24-hour trend uses hourly buckets; other periods use daily buckets. Run errors, origin blocks and tool counts aggregate the intersecting UTC calendar days, including whole boundary days.

## Find and replay sessions [#sessions]

<Tabs items="['Dashboard', 'API']">
  <Tab value="Dashboard">
    1. Open &#x2A;*Sessions (会话)**, enter the full end-user ID, and click &#x2A;*Filter (筛选)**. Choose a &#x2A;*Source (来源)** if needed.
    2. Open the session and check its user, source, version and creation time in the replay header.
    3. Inspect messages and tool calls, locate your test message and reply, then use &#x2A;*Close replay (关闭回放)**.

    **Expected:** Replay is read-only; you cannot send messages. To prevent further messages, click &#x2A;*Archive (归档)** and confirm. Records remain readable after archiving, but the session cannot receive more messages.
  </Tab>

  <Tab value="API">
    On your server, set `PRAXIS_API_BASE` (API origin), `PRAXIS_API_KEY` (organization API Key), and `PRAXIS_AGENT` (public `agent_…` ID). Use Node.js with native `fetch`. Save this as `inspect-sessions.mjs`. Run `node inspect-sessions.mjs customer_42`, replacing the test user ID.

    ```js
    import assert from 'node:assert/strict';

    const { PRAXIS_API_BASE, PRAXIS_API_KEY, PRAXIS_AGENT } = process.env;
    const [user, sessionId] = process.argv.slice(2);
    assert(PRAXIS_API_BASE && PRAXIS_API_KEY && PRAXIS_AGENT && user, 'Set environment variables and a user ID');
    assert(PRAXIS_AGENT.startsWith('agent_'), 'Use the public agent ID');
    const base = `${PRAXIS_API_BASE.replace(/\/$/, '')}/agent/v1`;
    async function readPages(path, filters) {
      const rows = [];
      let page;
      do {
        const query = new URLSearchParams(filters);
        if (page) query.set('page', page);
        const response = await fetch(`${base}${path}?${query}`, {
          headers: { Authorization: `Bearer ${PRAXIS_API_KEY}` },
        });
        if (!response.ok) throw new Error(`Read failed: HTTP ${response.status}`);
        const result = await response.json();
        rows.push(...result.data);
        page = result.next_page;
      } while (page);
      return rows;
    }
    const sessions = await readPages('/sessions', { agent_id: PRAXIS_AGENT, external_user_id: user });
    console.log(sessions.map(({ id, title, source, status }) => ({ id, title, source, status })));
    if (sessionId) {
      assert(sessions.some(row => row.id === sessionId), 'Choose a session from this user listing');
      const events = await readPages(`/sessions/${encodeURIComponent(sessionId)}/events`, { order: 'asc' });
      console.log(events);
    }
    ```

    The first run lists sessions. Copy the target session's `id` and run again with it as the second argument to read all events. The script uses `GET /agent/v1/sessions` and `GET /agent/v1/sessions/{session_id}/events`. Both requests are read-only; the API Key stays out of the browser.

    **Expected:** The listing includes your user's test session. Events include the test message and reply in chronological order. Following `next_page` prevents an incomplete replay. Output can contain conversation content; handle it under your data-access rules.
  </Tab>
</Tabs>

## Inspect spending and budgets [#usage]

Open &#x2A;*Usage and budgets (用量与预算)** to see monthly spending, the monthly cap and its action. Choose 7, 30 or 90 days for daily spending. Below are budget and rate settings, monthly source breakdown and the top 20 end users by spending. Monthly totals use the UTC calendar month; displayed amounts are US dollars.

These aggregate reports and budget settings are currently Dashboard-only. &#x2A;*Change cap (修改上限)** opens **Configuration → Security**. Save and return to verify. **Stop new sessions** rejects session creation when the cap is reached; **Alert only** does not block it. &#x2A;*Cost composition (花费构成)** is not available yet; its placeholder is not a breakdown.

## Verify and act [#verify]

Match the host message, replay and source using the same user, session and period. For an unexpected version, check the version used at token issuance. Pinning or rolling back does not alter existing tokens. For missing data, check the environment, organization and period before creating more test sessions.

For origin or budget failures, record the response's `X-Request-Id`, time, HTTP status and error code. Exclude API Keys and tokens. See [Manage end users](/en/docs/developers/agent/end-users) for user-level actions.

Next: [Embed limits and errors](/en/docs/developers/agent/embed/limits-and-errors) · [Agent API](/en/docs/api/native/agent) · [Cookbook](/en/docs/cookbook)
