← All topics
Knowledge

Exploration & discovery: search an open space

Exploration lets an agent attack open-ended problems by generating, testing, and pruning candidate paths, always balancing exploiting the best lead against trying something new.

What it is

Exploration is what an agent does when there is no fixed plan to follow. Instead of executing known steps, it searches an open space of possibilities — generating candidate moves, trying them, and keeping what works.

  • It generates several possible next steps instead of committing to one.
  • It tests them against the goal or a cheap signal.
  • It prunes dead ends and pushes deeper on the promising branches.

The core tension: exploit what already looks good, or explore something new that might be better.

When to use it

Reach for exploration when the path is genuinely unknown:

  • Open-ended problems where you can't write the steps in advance — research questions, optimization, game-like decisions.
  • Many candidate solutions exist and you need to find a good one, not the obvious one.
  • The environment gives feedback you can act on — a test passes, a metric moves, a check returns.
  • Discovery work: probing an API, mapping unfamiliar data, finding edge cases.

When NOT to use it: if the task has a known, reliable sequence, use planning or prompt chaining instead — exploration just burns tokens on a solved problem.

How it works

The agent runs a generate-test-prune loop over candidate paths.

  • Generate: propose N next moves. Example: candidates = expand(state, n=3) produces three different code fixes for a failing test.
  • Test: score each against a signal — score = run_tests(candidate) or a reflection step that judges quality.
  • Select: keep the best branches, drop the rest. A frontier (queue) holds live candidates ranked by score.
  • Balance: mostly follow the top branch (exploit), but spend some budget on weaker or untried ones (explore) so you don't miss a better route.
  • Repeat until the goal is met or budget runs out.

This is the shape behind tree search, beam search, and self-improving agent loops.

Watch out for

  • Pure exploitation gets stuck. Always taking the top candidate locks you into a local best and misses better paths. Keep a slice of budget for exploring.
  • Pure exploration never finishes. Without pruning and a stop condition, the frontier explodes. Cap depth, breadth, and total spend — see cost control.
  • A weak test signal poisons everything. If your scoring is noisy, you prune good branches and keep bad ones. Invest in the eval — pair this with evals.
  • No reproducibility. Branching is stochastic; log the search tree and decisions via observability so a run can be understood and replayed.

Related patterns

Ask the swarm