- a planning artifact in state
- a planner prompt separate from the execution prompt
- a
decide()override that only handles the planning boundary
What changes from lesson 1
| Branch | Lesson 1 | Lesson 2 |
|---|---|---|
| Control | Default LLM path every step | decide() intercepts only the planning boundary |
| Prompting | One ReAct system prompt | One planning prompt plus one execution prompt |
| State | Scratchpad + task fields | Add plan_steps and cursor |
| Parser | ReActTextParser | Still ReActTextParser for execution |
| Tools | Compact coding tools | Same compact coding tools |
| Memory and history | None beyond state | Still no separate memory or compaction |
The two-prompt architecture
This lesson uses two prompt contracts.Planner prompt
PLAN_DRAFT_PROMPT.
Executor prompt
PLAN_EXEC_SYSTEM_PROMPT.
The design lesson is:
- planning and acting can use different prompts
- but they still flow through the same
AgentModule + Engineruntime
The parser story in this lesson
The planner path does not useReActTextParser.
Instead:
_plan()rendersPLAN_DRAFT_PROMPTNumberedPlanBuildercalls the same LLM harness- the builder parses a numbered list into
list[str]
ReActTextParser.
That means lesson 2 already teaches a subtle but important QitOS idea:
different phases of the same agent can use different parsing contracts, as long as the control boundary is explicit.
The model harness stays intentionally boring
Just like lesson 1, the example uses:- so you can isolate the effect of planning
- so prompt and parser changes are easy to interpret
- so the new lesson teaches one new idea instead of five
Extend state with a plan and a cursor
The state adds only what execution needs:This is the first time the course makes a hidden reasoning artifact explicit.Why store the plan in state?
- the trace can show it
prepare()can surface itreduce()can advance it- your own logic can rewrite it later if needed
Use a dedicated plan builder
The planner is initialized once:And called like this:This is the right QitOS move:planning becomes a named artifact with a dedicated parser, not an unstructured paragraph in the main scratchpad.
Use decide only as the planning gate
The control logic is small:That
return None is the whole point.Once a plan exists, the Engine goes back to its default LLM path:prompt -> ReActTextParser -> Decision -> tool executionSo lesson 2 is not about replacing the runtime. It is about adding one explicit control boundary to it.Bind execution prompt and parser clearly
Execution still uses:and:So the planning phase and the execution phase are visibly different:
- numbered plan builder for planning
- ReAct text contract for execution
Make the plan visible in prepare
prepare() now renders both the global task and the current plan step:- one task
- one explicit plan
- one current plan item
Advance plan progress in reduce
Progress becomes ordinary state logic:The important lesson is not the exact condition. It is the placement:
reduce() is where you decide what counts as plan completion.Keep memory and history simple on purpose
Lesson 2 still does not add:
- a memory adapter
HistoryPolicytuningCompactHistory
Why PlanAct is still the same kernel
Researchers often think adding planning requires:- a separate planner service
- a planner-executor loop outside the framework
- a second agent runtime
- a planner is just another controlled model call
- a plan is just another state artifact
- execution is still the normal Engine path
Full example
The full runnable lesson lives at:What lesson 3 adds
Lesson 3 keeps the same kernel again, but now the agent becomes operationally long-running. That means you will finally introduce:- preset toolsets instead of manual wiring
- a workflow-oriented system prompt
- explicit history control
- the point where context compaction and memory become real design questions
Next lesson: Claude Code-style agent
Move from pattern design to a long-running workspace agent with presets, history policy, and qita-driven debugging.
Related guide: memory and history
Review the distinction between state, history, compaction, and memory before the long-running lesson.
