Using AI Agents Effectively

Pro Only

AI agents are fast and capable, but like all competent engineers they can misunderstand instructions, forget important details, and make other mistakes. They are also limited in how much they can remember at once, by the size of their working memory (called the context window). Your role is to direct the agents, keep them working efficiently, and review their work.

Autonomous Development

With the Tasks Manager turned on, agents carry out a series of tasks on their own, over long periods, while you write tasks, answer questions, and read reports.

What you need. Before letting agents work autonomously, make sure you have:

  • An AI agent and a plan for it that covers the amount of work you expect. For sustained use, a subscription is generally much cheaper than paying for usage on an API key. See Setting Up an AI Agent. Not all AI agents are well suited to run the Manager; see the table in AI Agent Safety.
  • Version control, such as git or Mercurial. You can ask your agent to set this up for you.
  • A virtual machine or other reasonably isolated environment. At the very least, prevent agents from reaching critical resources or pushing code to your main repository. See AI Agent Safety.

How much control to keep. At first you may prefer to review every change at the code level on the Review tab. Once you see that agents write and run tests reliably for your project, you may find yourself reading the task reports and judgement calls, and committing without reading every diff. Your attention moves from individual agents and their output to writing tasks, answering questions, and reading reports. Some people prefer to work with a single agent for a while first; you can turn the Manager off and on at any time.

Committing on a separate branch. The Manager can commit finished work on its own, when its Commits setting is Commit Automatically. The Autonomous Commits checkbox in the Set Up for AI Agent dialog, checked by default, sets this. Committing on its own lets development go on for long periods without waiting for you. If you use it, work on a separate branch, so you stay in control of when and how the work is merged into your main branch. A review task can compare the working branch with your main branch, to help you judge correctness, security, and anything else your development process calls for.

Start from a specification. Tasks can be small, such as a single bug fix, or a high-level specification of a feature or of a whole application. A specification should describe the purpose and key features, and any technical constraints that matter from the start. It does not need to be detailed: add it as a task, ask for it to be researched and broken into tasks, and mark it Ready. The Manager runs the research, asks what it needs to know on the Questions tab, and puts the resulting implementation tasks on the Plan tab, where some may run right away and others wait for you to mark them Ready. This works for an empty project as well as an existing one.

Require tests. Make it a rule that agents write unit tests for new code and use them to check their work. Tests let an agent see for itself whether the code works as specified. Without them, autonomous work stalls often, because workers cannot tell whether their code works. Set the testing regimen on the AI Agent tab of Project Properties; see Testing Regimen.

Write down your development policies. Describe your other policies and requirements, from coding style to workflow rules, in AGENTS.md (outside the block that Wing maintains there; see Setting Up an AI Agent), and tell the Manager about any that concern how work is scheduled or committed. Agents follow these policies and ask when something is unclear.

Use the application. Run and use what is being built yourself, as much as you can, and add tasks for the bugs and improvements you find before real users see it. Where that is not practical, ask agents to write tests that act like a live user, taking the application through all its functionality the way users will.

Schedule review passes. At key points, run separate review tasks: for security flaws, data loss bugs, test coverage, missing functionality, or compatibility problems between versions. Each one can turn up problems that become new tasks. Make at least some of these part of your regular workflow, so that many agents check each other's work.

Writing Requests and Guiding Agents

These tips apply to tasks and to requests typed into an agent session in the AI Agent tool.

Write clear, thorough requests. The quality of an AI agent's work depends heavily on the quality of your instructions. Describe in detail what features you want. If you have preferences for how something should be implemented, point the agent to existing patterns in your code or describe your requirements as concisely as possible. A request does not have to be long: a small bug fix may take one sentence, and a high-level specification of a new feature or application can be a good starting point, as long as it says clearly what you want and any constraints that matter.

Don't micro-manage. There is no need to spell out every detail of every task. If you are asking for a feature that is relatively standard or obvious, ask for it without further detail. For example, it may be enough to say "implement undo for all these features" in a relatively large specification, without getting into the details of what undo does or how it works. Similarly, if the agent writes code that does not work, don't start by telling it the specific error but ask it to "please write unit tests for the new functionality and use them to find any remaining bugs." Only get involved in the details if the agent fails to do that on its own.

Explore before starting work. An exploratory conversation is often useful before implementation. You can discuss ideas, ask the agent to evaluate the feasibility of different approaches, or have it sketch out a design before writing any code.

Use Plan mode to prevent changes on disk. For a substantial refactor, a change that touches many files, or anything where you want to see the approach before any code is written, run the task in Plan mode. The agent investigates the code and proposes a plan without modifying any files. You review the plan, ask for adjustments, and only then approve it for execution. Because a Plan task makes no edits, you can start one that reads code another task is actively changing, without risk of conflicting edits. Not every agent has a read-only mode; Wing warns before starting a Plan task on one that does not. See Run Modes.

Build feedback into your requests. Ask the agent to write, run, and fix unit tests as part of any implementation, so that you are not the one verifying that code works. Think about how to let the agent "see" what you see. That might mean telling it how to run your code with added logging that it can read, asking it to run the code in the debugger so it can see what happens at runtime, or setting up a headless browser or other means by which it can observe a UI it is building. The guides Wing writes for agents tell them to build this ability when a project lacks it, by running the application on an offscreen or virtual display, in a headless browser, or under a pseudo-terminal, and driving it the way users do. You can also ask for it directly as an early task. The least productive sessions are ones where you are stuck in a loop of manually testing, reporting back, and asking for another fix.

Manage context size. As a session works, its conversation context grows, and larger contexts consume more tokens per request. Context is valuable while working on the same or related tasks, since the agent can build on what it has already done. When switching to an unrelated task, start a fresh conversation to save money and keep the agent focused. Use Clear Conversation in the AI Agent tool's options menu (the ⋯ button), or /clear in agents that have it, and Resume Session in the same menu to go back to a conversation you left behind. For the tasks it runs, the Tasks Manager decides when to start a fresh session.

Step in when the agent gets stuck. Particularly when fixing difficult bugs, agents can lose their way, trying one speculative fix after another instead of reasoning more deeply or using a debugger to find out what the code is doing. An agent can also fixate on one solution, ignoring explicit instructions to find a different approach, or dismiss your reports of broken behavior as unimportant. When you notice an agent spinning, step in and tell it how to proceed. If that does not help after once or twice, ask it to remove any unwanted code it wrote and then use Clear Conversation to start over with fresh context. The new session has no knowledge of where uncommitted code came from or whether it is correct.

Agent Quick Start

Most agents print hints for how to use them as you work, so you can learn about them as you go. A few of the most useful details to get started with:

  • Pressing Esc stops the agent and returns to the prompt, where you can give additional instructions, refine your request, or move on to something different (in which case Clear Conversation may be in order).
  • If you do not know how to do something, or want to find out whether something is possible, ask the agent. An agent knows how to use itself, and for anything it does not know already it can search the web far faster than a human, often running many searches at once.