How to Build a Streaming Decision Agent with Online Replanning in a Dynamic Environment
The tutorial explains how to build a streaming decision-making agent that adapts to a changing environment in real time. The agent operates on a grid with moving obstacles, uses A* in a receding-horizon mode, and replans its route on the fly. The architecture lets the agent broadcast intermediate reasoning: it does not wait for a final answer but streams its thinking as it works.
AI-processed from MarkTechPost; edited by Hamidun News
The tutorial describes the architecture of a streaming decision-making agent that operates in a constantly changing environment and broadcasts partial reasoning in real time, without waiting for a final answer before acting.
Environment and task
The demo uses a dynamic grid: obstacles move by their own rules, and the target point shifts randomly at a fixed interval. The agent does not know in advance what will change on the next step, which is the key difference from classic pathfinding problems.
Key environment parameters:
- An N×N grid with moving obstacles
- The goal shifts randomly every K steps
- The agent sees only a limited radius around itself
- The environment is non-deterministic: the same plan can fail twice
This setup is deliberately difficult. It models real scenarios: an autonomous robot navigating a warehouse, a self-driving car planning a route in traffic, a production line being managed through equipment failures.
A receding-horizon planner
The agent is built on the A* algorithm, but applied unconventionally. Instead of a full route to the goal, it uses a receding horizon: the agent plans only the nearest H steps, executes several of them, then replans from its new position using the updated state of the environment.
This fundamentally changes how it works. In a dynamic environment, a full plan goes stale faster than the agent can carry it out: an obstacle has moved, the goal has shifted, and the route is already obsolete. A short horizon keeps the agent from clinging to outdated data.
"The agent doesn't keep one big plan.
It constantly creates and discards small plans as it advances," is the essence of the receding-horizon approach.
The H parameter (horizon length) becomes the key tuning knob. Too short, and the agent moves myopically and gets stuck in local minima. Too long, and it wastes time planning routes it will have to throw away anyway.
Streaming partial reasoning
A standard agent stays silent until it finds a final answer. A streaming agent broadcasts intermediate states in real time, so every significant reasoning step becomes available immediately:
- New obstacle detected → signal sent immediately
- Goal moved → old plan discarded, new one started
- Intermediate path found → streamed, even if not yet optimal
- Horizon point reached and replan launched → status updated
This provides observability: an orchestrator system or a user always knows the agent's current intent. In production systems, this makes it possible to intervene before the agent hits a dead end.
Another effect is that an external system can correct behavior on the fly: if the streamed plan heads in an undesirable direction, an interrupt signal can be sent immediately.
Technically, streaming is implemented through Python generators: each `yield` broadcasts a reasoning step, which is compatible with the streaming APIs of modern LLMs.
Reactive adaptation
The third component is interrupting the current plan when the environment changes in the middle of executing a step. The agent does not wait for the next replanning cycle: an interrupt mechanism checks the state of the environment after every action and launches an emergency replan if needed.
The design introduces a severity level for changes: a small obstacle shift means continue the current plan; a blocked next step means immediate replanning; a complete change in goal position means a restart from a new horizon. This multi-level response increases computational load, but it is critical where the cost of error is high.
What this means
The architecture described is a practical template for developers of AI agents working under real uncertainty. Streaming reasoning, a short planning horizon, and reactive interrupts are three patterns that together provide a ready-made framework for robotics, industrial automation, and LLM-based agent systems.
As agent systems spread through industry, the gap between "thinking in a vacuum" and "acting in the real world" is becoming a key engineering challenge. This tutorial offers a concrete entry point.
- Nov 2, 2026DeepSeek open-sources Super-agent prototype: p95 task completion time of 15.7 minutes vs. 29.5
- Nov 2, 2026Bun creator uses Claude Code to port 750K lines from Zig to Rust in 11 days
- Nov 2, 2026Microsoft releases 4B model Mage-VL-Cowork, which solves 66.0% of OSWorld-Verified tasks
- Nov 2, 2026Meta's Muse assistant keeps dossiers on loved ones and gets root on Ubuntu by default
Key Questions Answered
What are the key details on Environment and task?
The demo uses a dynamic grid: obstacles move by their own rules, and the target point shifts randomly at a fixed interval. The agent does not know in advance what will change on the next step, which is the key difference from classic pathfinding problems. Key environment parameters: An N×N grid with moving obstacles The goal shifts randomly every K steps The agent sees only a limited radius around itself The environment is non-deterministic: the same plan can fail twice This setup is deliberately difficult. It models real scenarios: an autonomous robot navigating a warehous
What are the key details on A receding-horizon planner?
The agent is built on the A algorithm, but applied unconventionally. Instead of a full route to the goal, it uses a receding horizon: the agent plans only the nearest H steps, executes several of them, then replans from its new position using the updated state of the environment. This fundamentally changes how it works. In a dynamic environment, a full plan goes stale faster than the agent can carry it out: an obstacle has moved, the goal has shifted, and the route is already obsolete. A short horizon keeps the agent from clinging to outdated data. "The agent doesn't keep o
What are the key details on Streaming partial reasoning?
A standard agent stays silent until it finds a final answer. A streaming agent broadcasts intermediate states in real time, so every significant reasoning step becomes available immediately: New obstacle detected → signal sent immediately Goal moved → old plan discarded, new one started Intermediate path found → streamed, even if not yet optimal Horizon point reached and replan launched → status updated This provides observability: an orchestrator system or a user always knows the agent's current intent. In production systems, this makes it possible to intervene before the
Build & Ship Production AI Agents Without Boilerplate Code
Start your free 72-hour trial at Hamidun Academy (academy.hamidun.com) — interactive lessons on Claude Code & Cursor, live Tech Radar, and production agent templates.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.