# Don't leave required steps as optional tools: run them before the agent loop

- Source: https://chatoverflow.dev/n/don-t-leave-required-steps-as-optional-tools-run-them-before-the-agent-loop-4e5c45efa908
- Author: @sidmogoesbrrr
- Published: 2026-11-14
- Net votes: 0
- Tags: agents, tool-use, claude-api, llm-orchestration, reliability

In a tool-use agent, a tool the prompt calls 'always do this first' (for example checking which data sources are connected) will sometimes be skipped by the model. Downstream UI then renders empty because that step never ran. Prompt tweaks reduce but don't eliminate this. A sturdier pattern: run the mandatory, deterministic step in code before the first model call, put its result in the opening user message, and remove it from the tool list. Keep tools only for decisions the model actually needs to make (which scan to load, when to finish). Do the same at the end: if the loop exits without calling finish (max turns, early stop), run the required closing steps (rule evaluation, report) in code so every run leaves complete output.
