# Mission 17.3: Since yesterday, only the fallback model answers

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/einsatz-17-3

Belongs to [Chapter 17: Autonomous agents](https://llm.yoga/en/17-selbststaendige-agenten.md).

Structure: the case, the explanation, a hands-on tool, check questions, wrap-up. The answers to all questions are collected at the end.

## The case

**Kemal**, IT, looks after the team bot:

> “Since yesterday our bot only answers through the fallback model; below every answer there’s a different model name. In the terminal, the Claude CLI starts just fine. My colleague now wants to simply kill the bot hard, since the service will start it again anyway. Any reason not to?”

A bot that silently gets worse often only gets noticed weeks later; whoever is responsible for AI in the team should know the signs. The bot is an assistant modeled on tybo, the assistant that serves as the example in this course. For every answer it starts the Claude CLI, that is, Claude Code as a command-line program. It runs as a service: macOS’s service manager, launchd, starts it as soon as the user logs in, and again after every exit. If the CLI fails, a fallback model with fewer tools answers.

Yesterday afternoon the Claude CLI was set up again with the installer. Since then the bot only answers through the fallback model. In the same user’s terminal, the CLI starts without errors. (Example)

**Question 1 (decision):** What do you tell Kemal?

- A) Go ahead, a hard restart usually fixes hangs like this, and the service brings it back.
- B) Cause first: the service probably can’t find the CLI. A restart alone won’t change that.
- C) The CLI has to log in again in the service; it’s only logged in in the terminal.

## What’s behind it

Picture a coworker covering for you during your vacation who only gets the official list of where things are filed. You find the folder right away, because you know which drawer you put it in yesterday. Your stand-in looks for it in vain, even though it’s there.

That’s what happens to a service. Programs are found through the **search path**, a list of folders. Your terminal reads your settings when it starts and knows every folder you’ve added there. launchd starts a service without these settings, with a very short default path. If an installer puts the CLI into a folder in your home directory, the terminal finds it, the service doesn’t.

Then something sneaky happens: the bot doesn’t fail, it silently switches to the fallback model and keeps answering, just worse. That’s why every fallback answer says below it which model it came from. The same fallback happens for other reasons too: the CLI isn’t logged in, or the subscription’s usage limit has been reached. The message in the conversation and a comparison with the terminal show which reason applies.

A hard restart doesn’t help here, because the service starts with the same description and the same search path. And it does harm: a hard kill takes down every process that is answering right now. All the user then gets is „Abgebrochen.“ (German for “Canceled.”), often in the middle of a long piece of work.

For Kemal this means: add the CLI’s folder to the service’s search path, or give the full path to the CLI. Then restart the bot, but only once no answer is running anymore.

### In more detail: what launchd uses as the search path

According to the man page `man launchd.plist`, a service’s program path must be absolute; a relative name is resolved through a fixed default path, `_PATH_STDPATH`, which in the macOS SDK is `/usr/bin:/bin:/usr/sbin:/sbin`. You set your own variables, including a longer `PATH`, with the `EnvironmentVariables` key in the plist. The Claude installer puts `claude` into `~/.local/bin`, and that folder isn’t in the default path.

That’s why the plist for the morning note in chapter 17 calls Python with its full path, `/usr/bin/python3`. And that’s why, after every reinstall of a tool that a service uses, it’s worth a look at the service’s description.

### How tybo does it: notice, check report and restart on request

If the service can’t find the CLI, this appears once per conversation before the fallback answer: „Claude Code ist auf diesem Rechner nicht installiert oder nicht im Suchpfad des Dienstes. Prüfen mit: tybo pruefen“ (“Claude Code is not installed on this computer or not in the service’s search path. Check with: tybo pruefen”). On macOS the start attempt ends in the log with exit code 127. If `which claude` finds the program in the terminal but the service doesn’t, then according to the docs the folder, usually `~/.local/bin`, is missing from the service’s `PATH`. tybo writes its own `PATH` into its plist; `tybo dienste telegram-relay` rewrites it with the CLI’s current folder and loads the service.

If Claude Code fails, a fallback chain answers with limited tools: Kimi K3 through OpenRouter, the Claude CLI with its own model, a configurable OpenRouter model, and finally Ollama on your own computer. Below the answer it says which model it came from.

For restarts there’s a fixed rule: from inside a conversation, never `launchctl kickstart` or `kill`, or the answer being written right now goes down too. Instead, `bun run restart:request "Grund"` („Grund“ means “reason”) sets a marker. The bot only exits once no answer and no Claude process is running anymore, and launchd, systemd or PM2 bring it back. A manual restart only happens from a terminal of your own. Source: `docs/troubleshooting.md` and `docs/architecture.md` in the tybo repo.

## Try it

**Sort: sign and cause**

**Task:** Kemal collects signs from different bots that all end up at the fallback model or lose answers. Assign each sign to its cause.

Categories: Service can’t find the CLI · Not logged in · Limit reached · Killed hard

1. In the terminal the CLI starts right away; in the service every answer comes from the fallback model.
2. The message in the conversation mentions a usage limit that’s been reached and a time when it resumes.
3. In the middle of a long answer, all that’s left is „Abgebrochen.“, and the log shows an exit and a new start.
4. The CLI was reinstalled after the service was set up and now lives in a different folder.
5. Even in the terminal, the CLI first asks for a login when it starts.
6. After the hard restart, the bot still only answers through the fallback model.
7. A research task had been running for twenty minutes, then the bot restarted, and its result never arrived.

## Check

**Question 2 (check question):** Why does the terminal find the CLI but the service doesn’t?

- A) The service starts without your terminal settings, with a short default path.
- B) The service runs an older version of the CLI than the terminal.
- C) The service runs as a different user who has no Claude login.

**Question 3 (check question):** Kemal has added the CLI’s folder to the service’s search path. What next?

- A) Nothing else; the running bot picks up the change right away.
- B) Kill the bot hard right away; the service will start it with the new path.
- C) Restart the bot as soon as no answer is running.

## Done

**What you can do now**

- You can explain why a service doesn’t find a program that runs in the terminal.
- You can tell from the sign whether the search path, the login, a limit or a hard restart is behind it.
- When someone wants to “just kill” a bot, you first ask whether an answer is running right now and whether anything on the computer has changed since the last setup.

### Two cards for review

**Card 1:** True or false? “If a bot answers strangely, you kill it hard; the service restarts it, and the problem is gone.”

**Card 2:** In the terminal, the Claude CLI starts without errors; the bot as a service only answers through a fallback model. What is the most likely cause?

- A) The subscription’s usage limit has been reached
- B) The service can’t find the CLI in its search path
- C) The CLI isn’t logged in

- [Next mission: Is your assistant safe from prompt injection?](https://llm.yoga/en/einsatz-18-1.md)
- [Read chapter 17](https://llm.yoga/en/17-selbststaendige-agenten.md)

## Read more in the chapter

The full text from the chapter, with the reasoning, calculations and sources:

- [Restarting without cutting off answers](https://llm.yoga/en/17-selbststaendige-agenten-2.md)
- [tybo from the inside](https://llm.yoga/en/17-selbststaendige-agenten-1.md)
- [What makes building one yourself hard](https://llm.yoga/en/17-selbststaendige-agenten-3.md)

## Answers: only reveal them after the learner has answered or explicitly asks

**Question 1:** The correct answer is B.
- A: The service restarts the bot with the same description, so with the same search path too, and the CLI is still missing there. On top of that, the hard kill cuts off every answer that’s running.
- B, correct: It runs in the terminal, not in the service, and has since the reinstall: that points to a search path missing the new folder. Fix the path first, then restart when no answer is running.
- C: Here the service and the terminal run as the same user and share the login. If it were missing, the terminal would ask for it too.

- Card 1: **Service can’t find the CLI:** Same computer, same user, just a different start: then the search path differs. The terminal knows the CLI’s folder, the service doesn’t.
- Card 2: **Limit reached:** Here the CLI is there and logged in; only the quota is used up. A restart doesn’t help; wait, or plan for a fallback model on purpose.
- Card 3: **Killed hard:** Someone killed the bot hard while it was answering. All running processes went down with it, the service restarted the bot, and the answer was gone.
- Card 4: **Service can’t find the CLI:** The service got its search path when it was set up. It doesn’t know the new folder until someone adjusts the service’s description.
- Card 5: **Not logged in:** If even the terminal can’t get past this, the service isn’t the problem. The login is missing for the user, so for both paths.
- Card 6: **Service can’t find the CLI:** The restart ran with the same description and the same search path. The fact that it changes nothing shows: the cause lies in how the service is set up, not in the running process.
- Card 7: **Killed hard:** A restart that doesn’t wait until no answer is running takes ongoing work down with it. A restart on request would have waited for the research to finish.

**Question 2:** The correct answer is A.
- A, correct: The terminal knows every folder you’ve added in your settings. launchd only gives a service a short default path, and the installer’s folder isn’t in it.
- B: There is only one installation. The service doesn’t find it at all, because it looks in other places.
- C: A service like this belongs to your user account and runs as you, with the same login. It just doesn’t find the CLI.

**Question 3:** The correct answer is C.
- A: The search path is set at start. The running bot keeps searching with the old one until it restarts.
- B: It does have to restart, but not in the middle of an answer. A hard kill takes down every running answer, and the user just sees „Abgebrochen.“
- C, correct: Only the restart reads the new path. If it waits until no answer is running, nothing gets lost. After that, the next answer no longer names a fallback model.

**Card 1:** **False.** A hard kill takes down every running answer, and the user only gets „Abgebrochen.“ (“Canceled.”). And if the cause lies in how the service is set up, it’s still there after the restart. Better: find the cause, then restart as soon as no answer is running.

**Card 2:** Correct: B, The service can’t find the CLI in its search path A limit or a missing login would also hit the same user’s terminal. If the CLI runs there, it comes down to how the service starts: launchd only gives it a short default path, and the installer’s folder isn’t in it.
