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

# 3. Remember the conversation

> Reuse a session so a follow-up has the earlier context.

[Support assistant tutorial](/learn/support-assistant)

This checkpoint keeps the lookup tool and makes two requests with the same `sessionId` and `userId`. Both requests happen before closing the Agent.

## Complete checkpoint

```typescript support.ts theme={null}
import { Agent, defineTool, openai } from "@agentium/core";
import { z } from "zod";

const orders = new Map([
  ["ORD-1042", { status: "shipped", delivery: "Friday", refundable: true }],
]);
const lookupOrder = defineTool({
  name: "lookup_order",
  description: "Look up an order's status and expected delivery by its ID.",
  parameters: z.object({ orderId: z.string() }),
  execute: async ({ orderId }) => JSON.stringify(orders.get(orderId) ?? { error: "Order not found" }),
});
const agent = new Agent({
  name: "support",
  model: openai(process.env.OPENAI_MODEL ?? "gpt-6.1-sol"),
  instructions: "Use lookup_order for order details. If the order is missing, say so.",
  tools: [lookupOrder],
  maxToolRoundtrips: 3,
});

try {
  const conversation = { sessionId: "support-demo-1", userId: "demo-customer" };
  const first = await agent.run("My order is ORD-1042. When will it arrive?", conversation);
  if (first.status !== "completed") throw new Error(`Run ended: ${first.status}`);
  console.log(first.text);

  const result = await agent.run("What was my order ID?", conversation);
  if (result.status !== "completed") throw new Error(`Run ended: ${result.status}`);
  console.log(result.text);
} finally {
  await agent.close();
}
```

## Run it

```bash theme={null}
npx tsx support.ts
```

## Verify the result

The first response should use the order tool. The follow-up should identify ORD-1042 from the conversation.

**Try a new session ID for the second call.** The second conversation should not inherit the first conversation's order. This is a useful isolation check, but it does not replace authorization tests in a hosted application.

Default conversation state is in memory. Restarting this script loses that history. Choose [persistent storage](/storage/overview) when sessions must survive restarts. For hosted requests, derive user identity from verified credentials and authorize the session; never trust a client-supplied ID as proof of ownership.

<Card title="Answer from policies" icon="arrow-right" href="/learn/knowledge">Continue to the next chapter.</Card>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.