The Deska blog
Constraints Beat Instructions for Agents
Learn why constraints beat instructions for agents when building reliable AI workflows and how to implement them in your developer workspace.
9 min read
Reliability in autonomous software development is rarely the result of longer prompts. As developers move from simple chat interfaces to complex multi-turn systems, they often discover that constraints beat instructions for agents. While instructions attempt to guide an LLM toward a desired behavior, constraints define the boundaries of the search space, effectively preventing the model from entering hallucination loops or destructive states. By narrowing what an agent can do, you paradoxically increase its ability to successfully complete specific tasks without manual intervention.
The Problem with Verbose Instructions
When we provide instructions, we are essentially giving the model a list of suggestions. In a long context window, these suggestions compete for attention. An agent given twenty separate instructions on how to format code and handle errors might follow eighteen of them but fail on the two most critical ones. This is often called instruction fatigue. The model understands the words, but the probabilistic nature of the output means that every additional instruction introduces a new point of failure.
Instructions are also prone to semantic drift. As a conversation grows longer, the agent might prioritize recent feedback over the initial system prompt. If you tell an agent to be concise, but then ask a series of complex questions that require detail, the instruction to be concise eventually loses its weight. Constraints operate differently. Instead of asking the agent to be something, you provide a structure that makes it impossible or highly difficult to be anything else.
Why Constraints Lead to Better Outcomes
Constraints function as a safety harness for the latent space of the model. When you apply strict boundaries, you reduce the number of choices the agent has to make at any given step. This reduction in choice leads to several technical advantages.
- Deterministic Formatting: By using schema enforcement or strict output masks, you ensure that the agent provides data in a way your parser can handle.
- State Management: Limiting the number of files an agent can see or the number of commands it can run prevents the agent from getting lost in a massive codebase.
- Error Mitigation: If an agent is constrained to only run
npm testrather than arbitrary shell scripts, the risk of a destructive action is eliminated.
In many ways, the shift from instructions to constraints is a shift from natural language programming to systems engineering. You are not just talking to a model; you are building a runtime environment for it.
Implementing Constraints in the Developer Workspace
A productive developer environment must balance freedom with these necessary guardrails. Tools like Deska provide an infinite canvas where you can visualize how these agents interact with your system. In this environment, you can run multiple tools side by side, allowing you to observe the impact of different constraint strategies in real time.
When using coding agents like Claude Code or OpenCode, the workspace itself acts as a physical constraint. In Deska, you can open specific terminals and browser widgets to isolate the agent task. Instead of giving the agent access to your entire OS, you provide it with a specific set of panels. This local-first approach ensures that the agent operates within the context you have visually defined on the canvas.
Sandbox Environments and Execution Limits
One of the most effective constraints is the execution limit. If an agent is allowed to run an infinite loop of "think, act, observe," it may eventually burn through your API credits without solving the problem. By setting a hard limit on the number of iterations or the amount of tokens consumed per session, you force the agent to find a solution within a fixed budget.
Context Filtering
Providing too much context is a common mistake. If an agent has access to every file in a large repository, it might use outdated patterns from a legacy folder. By constraining the context to only the relevant code and git files, you remove the noise. This is a primary example of how constraints beat instructions for agents. Instead of telling the agent "do not look at the legacy folder," you simply do not include the legacy folder in its workspace.
Comparing Agent Orchestration Approaches
Different tools take various approaches to managing agent behavior. Some focus heavily on the system prompt, refining it over thousands of iterations to cover every edge case. Others focus on the architecture, using a supervisor agent to watch over a worker agent.
A tool like AutoGPT often suffers from a lack of constraints, as it attempts to be fully autonomous with a very broad scope. In contrast, specialized coding agents usually perform better because their toolset is restricted to git, file editing, and terminal commands. Deska allows you to run these specialized agents side by side, which provides a unique way to compare how different constraint sets affect the quality of the code generated.
| Approach | Reliance on Instructions | Reliance on Constraints | Predictability |
|---|---|---|---|
| General Chat | High | Low | Low |
| Autonomous Loops | Medium | Medium | Medium |
| Integrated Workspaces | Low | High | High |
| Scripted Pipelines | Very Low | Very High | Very High |
The Role of Local Context in Reliability
A local-first strategy is inherently a constraint. When your code and files stay on your machine, the agent is constrained to the reality of your local environment. It cannot hallucinate a cloud state that does not exist because it is directly interacting with your file system.
Using the Ask Deska assistant within a local workspace means the AI can drive the workspace based on what it sees in your current panels. If you have a specific code editor panel and a terminal open, the agent is naturally guided to work within those boundaries. You can even monitor these sessions through the mobile app using a secure relay, ensuring that the constraints you have set are being followed even when you are away from your desk.
FAQ
How to use constraints beat instructions for agents?
To apply this principle, stop adding "don't do X" to your prompts. Instead, remove the ability for the agent to do X. This involves using tools that limit file access, enforcing JSON schemas for outputs, and setting strict iteration limits on agentic loops.
Are coding agents safe for large repositories?
They are safest when used with a workspace that provides visibility and boundaries. By using a canvas to organize panels, you can see exactly what the agent is doing. Local-first tools also ensure your proprietary code is not stored on external servers during the process.
Can I run multiple AI agents at once?
Yes, in modern developer workspaces you can run agents like Claude Code and Codex CLI side by side. This allows you to compare outputs and use one agent to verify the work of another, effectively using the second agent as a constraint on the first.
Enhance Your Workflow with Deska
Building a reliable AI workflow requires the right environment to test and implement these constraints. Deska provides a free, infinite canvas workspace that supports Mac, Windows, and Linux. By running your tools as panels in a unified view, you can better manage how your agents interact with your code.
You can start by configuring your own API keys in our pricing model for a lifetime tier or use managed inference if you prefer a subscription. The workspace itself remains free for all users. Take control of your agentic workflows and see why constraints are the key to moving past simple chat prompts.