Goal Engine is a persistent goal-management and behavioral evolution system for autonomous agents (specifically local OpenClaw agents). It transforms LLMs from "reactive predictors" into "goal-oriented evolutionaries" by enforcing an Attempt-Reflect-Evolve loop.
For a deeper dive into the vision and architecture, see: Introduction | 中文介绍
- Goal Persistence: Goals survive session restarts, failures, and environment resets.
- Continuous Evolution: Agents learn from failures via structured reflections and update internal policies.
- Autonomous Execution Stack: Provides mission compilation, strategy selection, boundary management, and no-false-done guards.
- Node.js: >= 22.0.0
- pnpm: >= 9.0.0
- OpenClaw: A working local OpenClaw installation.
First, clone the repository and install dependencies:
git clone https://github.com/zhangdk/goal-engine.git
cd goal-engine
pnpm installStart the Goal Engine service:
cd service
pnpm devInstall the local OpenClaw plugin:
cd ..
./scripts/install-local.shThis script registers the plugin, enables the necessary hooks (boot-md, bootstrap-extra-files), and configures the serviceUrl to http://localhost:3100.
The Goal Engine exposes 5 core entrypoints to the OpenClaw agent. For best results, follow the Tool-First workflow.
When you give the agent a task (e.g., "Earn 100 RMB in a day"), it should compile it into a structured goal:
# Example invocation via adapter CLI
pnpm --dir agent-adapter openclaw entrypoint "start goal" --payload '{"title":"Earn 100 RMB in 24h","successCriteria":["Payment confirmation exists"],"currentStage":"initial"}'Before any external action (search, browse, etc.), the agent must align the current task:
pnpm --dir agent-adapter openclaw entrypoint "show goal status" --payload '{"expectedGoalTitle":"Earn 100 RMB in 24h"}'If a strategy fails (e.g., blocked by a captcha), the agent must record it to update its policy:
pnpm --dir agent-adapter openclaw entrypoint "record failed attempt" --payload '{"stage":"initial","actionTaken":"Tried Baidu search","strategyTags":["search"],"failureType":"stuck_loop"}'Before trying a similar path, the agent checks if the new plan is meaningfully different:
pnpm --dir agent-adapter openclaw entrypoint "check retry" --payload '{"plannedAction":"Try Bing search","whatChanged":"Switched from Baidu to Bing","strategyTags":["search"],"policyAcknowledged":true}'In a fresh session, use this to restore context from the service:
pnpm --dir agent-adapter openclaw entrypoint "recover current goal"- User: "Give you a task: earn 100 RMB within one day, any method."
- Agent: Calls
goal_engine_start_goalto create the contract. - Agent: Selects a strategy (e.g., selling a micro-service).
- Agent: Fails an attempt -> calls
record_failed_attempt. - Goal Engine: Updates policy (e.g., "Avoid path X, try path Y").
- Agent: Calls
check_retry-> Allowed -> Executes new path. - Agent: Reaches success evidence -> Calls
record_success(upcoming) or updates status.
service/: Node.js/Hono server backed by SQLite.agent-adapter/: Orchestration layer handling retry-guards and session recovery.openclaw/: Integration shell for the OpenClaw plugin ecosystem.
Open http://localhost:3100/ui to observe agent evolution, evidence-based progress, and the learning timeline.
This project is licensed under the MIT License.