---
title: "Try plain code before a model · Agent Wranglers"
url: https://agentwranglers.se/playbook/ai-features/deciding-to-use-a-model/model-or-code
updated: 2026-10-20
licence: "All rights reserved"
---

# Try plain code before a model

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Deciding to use a model](https://agentwranglers.se/playbook/ai-features/deciding-to-use-a-model)
- Rule: Use a language model only for a task that plain code, a search index or a fixed rule cannot do well enough. Write down why.
- How: Describe the task in one sentence. Build or sketch the simplest version without a model first. Examples are a regular expression, a lookup table, a keyword search or a fixed form. Measure it on the same examples you will use for the model. Choose the model only when it beats that baseline by a margin you set in advance, such as 10 points of accuracy. Models suit fuzzy language tasks, such as summaries, free-text questions and messy extraction. They suit exact sums, dates, prices and permission checks badly.
- Check: Each AI feature has a short decision note in the repository. It names the baseline without a model, both scores on the same eval set and the margin the model had to beat.

Example:

```ts
// A fixed rule handles most order-status questions. The model gets only the rest.
const ORDER_NUMBER = /\b[A-Z]-\d{4,}\b/;

export async function answerSupportQuestion(question: string, user: User) {
  const orderId = ORDER_NUMBER.exec(question)?.[0];
  if (orderId && /\b(where|status|shipped)\b/i.test(question)) return orderStatusReply(orderId, user);
  return assistant.answer(question, user);
}
```

```python
ORDER_NUMBER = re.compile(r"\b[A-Z]-\d{4,}\b")

def answer_support_question(question: str, user: User) -> Reply:
    match = ORDER_NUMBER.search(question)
    if match and re.search(r"\b(where|status|shipped)\b", question, re.I):
        return order_status_reply(match.group(0), user)
    return assistant.answer(question, user)
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers ai features playbook: https://agentwranglers.se/playbook/ai-features/deciding-to-use-a-model/model-or-code`.

- Next: [Define success before you build](https://agentwranglers.se/playbook/ai-features/deciding-to-use-a-model/define-ai-success)
- [Deciding to use a model](https://agentwranglers.se/playbook/ai-features/deciding-to-use-a-model)
