> ## 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.

# 2. Look up an order

> Give the model a validated function that returns application data.

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

Replace `support.ts` with this checkpoint. `lookup_order` reads a tiny in-memory catalog. In your application, its implementation would call your order service after checking the authenticated customer's access.

## 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 result = await agent.run("When will ORD-1042 arrive?");
  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 answer should report Friday for ORD-1042. The model chooses the tool; your function supplies the fact.

The schema validates the shape of arguments. It does not establish ownership or eligibility. Keep those checks inside application code. Return a string or the SDK's `ToolResult` shape; serialize structured data when returning text.

**Try a missing order:** change the ID to ORD-9999. The assistant should report that the order was not found, rather than inventing a delivery date. A model can still produce an incorrect answer; this is a prompt to include in your evaluation set.

<Card title="Remember the conversation" icon="arrow-right" href="/learn/memory">Continue to the next chapter.</Card>


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