Agentic loop

The reusable orchestration pattern

The most important thing open-source adopters need is not a shell app. It is a clear mental model for the loop itself so they can re-host it inside their own product, transport, UI, and runtime constraints.

The loop in one sentence

An agentic loop repeatedly combines model reasoning with structured tool execution, state updates, and policy checks until it has enough information to produce a useful, safe response or next action.

Core phases

1

Capture user intent from text, voice, gestures, or background events.

2

Resolve context: session state, permissions, memory, environment, and task goals.

3

Call the model with the right tool affordances and system constraints.

4

Inspect requested tool calls, enforce policy, and execute approved actions.

5

Append tool results and continue iterating until the system can answer or stop safely.

6

Stream state outward so the host application can remain transparent and responsive.

Reference architecture

while loop_is_active:
  input = collect_user_or_system_signal()
  context = resolve_context(input, session, permissions, memory)
  plan = call_model(input, context, available_tools)
  results = execute_approved_tools(plan.tool_calls)
  update_state(results)
  if can_answer(plan, results):
    return final_response(plan, results)

Design rule

Treat the loop as product infrastructure. Voice, text, gestures, and UI are inputs to the loop, not replacements for it.

Adoption checklist for everyday apps

  • • Make iteration boundaries observable in logs or UI.
  • • Separate tool policy and confirmation from model output parsing.
  • • Keep session state explicit so flows can resume or replay.
  • • Normalize gestures and haptics into the same event pipeline as other inputs.
  • • Use examples and simulator flows to prove interaction patterns early.
Next: gesture libraries Explore MCP integration