---
title: "agent_cannot_buy"
url: https://services.dev/docs/reference/check/agent_cannot_buy
---
# agent_cannot_buy

URL: https://services.dev/docs/reference/check/agent_cannot_buy

> An agent couldn't order, wait for and accept a job.

| Fix | Fails in | Exit |
|---|---|---|
| Run npx services.dev dev and read its job. | `services/translation.ts` | 1 |

**Owned by** [Build with your coding agent](https://services.dev/docs/start/agents.md): the page that explains what this gate holds.

## What check says

```txt title="npx services.dev check"
  ✗ An agent couldn't order, wait for and accept a job. Run npx services.dev dev and read its job. It stopped at: draft: Cannot read properties of undefined (reading 'map').
    https://services.dev/docs/reference/check/agent_cannot_buy
✗ 1 to fix
```

## The failing file

```ts title="services/translation.ts"
import { Service } from 'services.dev'

export default Service({
  name: 'Translation',
  input: { document: 'file', to: 'language: a BCP 47 tag, such as fr-CA' },
  output: { document: 'file' },
  deliver: async ({ document, to }) => {
    const pages = document.pages.map(page => page.text)
    return { document: { name: `${document.name}.${to}`, text: pages.join('\n') } }
  },
  price: 49,
})
```

## The fix

```diff title="git add -A && git diff --staged"
diff --git a/services/translation.ts b/services/translation.ts
index 820ccb4..e7fd1f6 100644
--- a/services/translation.ts
+++ b/services/translation.ts
@@ -5,7 +5,7 @@ export default Service({
   input: { document: 'file', to: 'language: a BCP 47 tag, such as fr-CA' },
   output: { document: 'file' },
   deliver: async ({ document, to }) => {
-    const pages = document.pages.map(page => page.text)
+    const pages = (await document.text()).split('\f')
     return { document: { name: `${document.name}.${to}`, text: pages.join('\n') } }
   },
   price: 49,
```

```txt title="npx services.dev check"
✓ ready to sell · 1 Service · AI delivers it alone · it keeps at least 80% of every job
```

## Explained in

- [Build with your coding agent](https://services.dev/docs/start/agents.md)
- [Service()](https://services.dev/docs/service.md)

## What an agent reads

```json title="npx services.dev check --json · the agent_cannot_buy failure"
{
  "code": "agent_cannot_buy",
  "reason": "An agent couldn't order, wait for and accept a job.",
  "next": "Run npx services.dev dev and read its job. It stopped at: draft: Cannot read properties of undefined (reading 'map').",
  "doc_url": "https://services.dev/docs/reference/check/agent_cannot_buy"
}
```

<details>
<summary>The whole document check --json prints</summary>

```json title="npx services.dev check --json"
{
  "ai": {
    "cents_per_call": 42,
    "simulated": true
  },
  "mcp": {
    "tools": 13,
    "tokens": 4486,
    "sandbox": 9,
    "budget": 8000
  },
  "services": [
    {
      "path": "services/translation.ts",
      "lines": 8,
      "steps": "draft · code → review · ai · adversarial",
      "ok": false,
      "price": "$49 per job, within 48 hours, charged on delivery.",
      "who": "AI delivers every job.",
      "agent": {
        "tool": "order_translation",
        "words": 24,
        "job": "job_7Hq2",
        "status": "canceled",
        "on": null,
        "charged": null,
        "person": false,
        "why": "draft: Cannot read properties of undefined (reading 'map')"
      },
      "ledger": "+$49.00 · AI $0.42 (example) · you $48.58",
      "approved_ledger": null,
      "outcome": null,
      "margin": {
        "floor": {
          "cents": 3920,
          "pct": 80
        },
        "own": 3920,
        "stop": 980,
        "nested": []
      },
      "apps": [
        "customer portal",
        "owner console"
      ],
      "failures": [
        {
          "code": "agent_cannot_buy",
          "reason": "An agent couldn't order, wait for and accept a job.",
          "next": "Run npx services.dev dev and read its job. It stopped at: draft: Cannot read properties of undefined (reading 'map').",
          "doc_url": "https://services.dev/docs/reference/check/agent_cannot_buy"
        }
      ]
    }
  ]
}
```

</details>

---

- Up: [check’s gates](https://services.dev/docs/reference/check.md)
- Previous: [price_unstated](https://services.dev/docs/reference/check/price_unstated.md)
- Next: [toolset_too_large](https://services.dev/docs/reference/check/toolset_too_large.md)
