-
Notifications
You must be signed in to change notification settings - Fork 3
auto_unlock_loop_orchestration
- Workflow steps (particularly
orchestrationandtodo_tasksub-agents) keep resetting their learnings. - Steps appear "Unlocked" in the UI even after being manually or automatically locked.
- Logs show frequent:
🔄 Step definition changed for ... (Hash mismatch) - Triggering learning reset. - UI occasionally shows steps as "Locked (Auto)" even when they have been reset backend-side.
The Step Hash Guard calculates a SHA256 hash of a step's Title, Description, and Success Criteria to detect plan modifications. If the hash changes, it resets learnings to ensure safety.
For Orchestration and Todo Task steps, the controller was modifying the sub-agent step object in-place (via pointers) to inject dynamic runtime instructions and success criteria. Because these instructions vary slightly between runs (LLM-generated), the hash always changed. The Hash Guard perceived this as a plan modification, triggering a reset and unlock on every execution.
Because the modification was in-place on the PlanStepInterface pointers, the "original" plan in memory was being corrupted. Even if the Hash Guard tried to look at the original plan, it would see the mutated version.
The ResetLearningMetadata function was updating the AutoUnlockedAt timestamp but not clearing the AutoLockedAt fields. The UI uses the presence of AutoLockedAt to display the "Locked" badge, leading to a state where the backend had unlocked the step but the frontend still showed it as locked.
In TodoTaskPlanStep, instructions were being passed to executeSingleStep via the previousExecutionResults parameter. However, that parameter is designed to be indexed by step number. Sub-agents do not align with global step indices, causing the instructions to be ignored or causing index-out-of-bounds logic in the prompt builder.
Modified both controller_orchestration.go and controller_todo_task.go to stop in-place modifications.
- The controller now creates a shallow copy of the
RegularPlanStepstruct. - Dynamic instructions are appended to the copy.
- The copy is passed for execution, keeping the original plan pointer pristine.
Updated CheckAndResetStepHash in controller_learning_helpers.go to:
- Recursively search the
approvedPlan(the static source of truth) for the original step definition. - Use the original static definition for hash calculation, ignoring runtime overrides.
Updated ResetLearningMetadata to explicitly clear AutoLockedAt, AutoLockReason, and AutoLockIteration whenever a step is unlocked.
In TodoTaskPlanStep, instructions are now embedded directly into the cloned step's Description (matching the Orchestration pattern) instead of relying on the fragile previousExecutionResults array.
- Verified with
go build ./...inagent_go. - Manual verification of hash stability across iterations for orchestrated steps.
Auto-synced from docs/ on main. Edit there, not here.