Skip to content

Reflection Loop

The reflection loop runs a test command after each write, edit, or multiedit tool call. On non-zero exit the output is re-injected into the agent context so it can iterate until the tests pass or the iteration budget is exhausted.

This feature name is operational: it means test-after-edit feedback. It is not introspective self-evaluation or hidden memory synthesis.

[options.reflection]
enabled = true
test_command = "go test ./..."
max_iterations = 3
OptionDescription
test_commandShell command to run after each write/edit (e.g. npm test, pytest, cargo test)
max_iterationsMaximum re-inject cycles before giving up (default: 3)
  1. Agent edits a file
  2. BMO runs test_command in the background
  3. If it exits non-zero, the full output is appended to the context and the agent gets another turn
  4. Repeat until tests pass or max_iterations is exhausted

The top-level reflection config is for the global test-after-edit loop described here. Choreography has a separate type: "reflection" hook entry used inside state machine definitions — those are different and coexist without conflict.

Auto-Debug triggers on any tool error. Reflection Loop is more targeted — it always runs the same test_command after writes, regardless of whether the write itself succeeded.