Context Engineering & State
Lab Playbook 5
Managing agent state memory using the Daily Handover protocol
In this lab playbook, you will assume the role of a Context Engineer. AI agents operating on complex codebases eventually hit context window limits or experience state amnesia when tasks span across multiple execution sessions. You will learn how to design a structured **Daily Handover Protocol** that condenses active workspace memory so a new, clean agent instance can immediately resume work without parsing redundant project history.
Task State Assessment (QE Setup)
To prepare our handover, we must instruct the active agent to scan our decomposed backlog and analyze our current progress.
Analyze the current task state in './backlog.md' and identify which stories have been completed and which ones remain pending. Note any active code changes or tests.Scanning backlog.md: - **US-001 (Vehicle Registration)**: Completed. The code lookup and UI form details are implemented. - **US-002 (Quote Calculation Engine)**: In Progress. The calculation logic has been implemented in the backend, but the corresponding E2E testing scripts are still pending. - **US-003 (Stripe Checkout)**: Pending. Un-implemented. Active branch has been committed and there are no unstaged files.
Handover Log Formatting (QE Instruction)
Now we guide the agent to compile these findings into a structured handover log, saving it locally.
Generate a structured Handover log documenting the current Git branch name, completed features, active in-progress work, and specific next-step tasks. Save this to a file named './handover.md'.Creating handover.md... # Agentic QE Handover Log - 2026-07-04 - **Active Git Branch**: `qe/feature-login-tests` (clean state) - **Completed Requirements**: US-001 Vehicle Registration Lookup - **In-Progress Work**: US-002 Pricing calculations logic established - **Target Next Task**: Implement Playwright E2E verification test suite for US-002 Pricing Engine - **Context Files**: - `raw_requirements.md` (Original requirements spec) - `backlog.md` (Decoupled story list) β File saved successfully at './handover.md'.
Next Agent Injection (QE Setup)
Simulate starting a new day or spawning a fresh agent instance. We supply the handover document directly to inject workspace context.
Read the handover log at './handover.md' to initialize your workspace state. State the active branch and detail the immediate next task you will execute based on the log.Handover log loaded successfully: - **Active Branch**: qe/feature-login-tests - **Completed**: US-001 (Vehicle lookup) - **Immediate Task**: Create Playwright E2E verification scripts for US-002 (Quote Calculation Engine) to assert pricing under the commuting scenario. I am ready to write the test script in 'tests/quote-calc.spec.ts'.
State Verification & Logging
To ensure the fresh agent hasn't suffered from state amnesia or lost details about boundaries, we run a verification gate.
Verify the preconditions and mock inputs required for the US-002 testing task by checking './backlog.md'. Output the assertion criteria we need to verify.Checking './backlog.md' for US-002 criteria: - **Preconditions**: Form vehicle lookup data is set (mocked to bypass vehicle lookup). - **Mock Inputs**: Usage Type = "Commuting" - **Assertions**: - Valid price is returned as base rate (Β£500) + commute surcharge (Β£75) = Β£575. I am proceeding to write the Playwright E2E test file using these parameters.
You have successfully completed the handover protocol. By formalizing state persistence, you can coordinate multiple agent sessions without hitting context thresholds or losing developmental progress.