JUHE API Marketplace

How to Use STATE.yaml for Autonomous Tasks in OpenClaw

7 min read
By Emma Collins

AI Autonomous Task Execution: When the Path to the Goal Is Not Known in Advance

You want to generate a competitive analysis report for a new API product. While you know what the final deliverable should look like, the exact intermediate steps—like which competitors to research, comparison dimensions, or information sources—aren't fixed. A rigid task list would require updates every time the goal changes.

This is where a goal-driven autonomous task agent excels. You provide a plain-English goal plus acceptance criteria. The agent self-plans a task sequence, executes each step, evaluates output quality, and revises if needed, all within a configurable step limit. The result is a polished deliverable, not a to-do list.

Compared with the multi-agent STATE.yaml pipeline, this configuration is simpler but demands stronger reasoning from the agent.

Outcome-forward: by the end of this tutorial, you'll have a working goal-driven agent that accepts a plain-English goal, plans and executes its tasks, self-evaluates results, and delivers a completed output without predefined steps. Validate the self-evaluation loop early in AI Studio at https://wisgate.ai/studio/image and manage your API keys at https://wisgate.ai/hall/tokens.

What the Goal-Driven Autonomous Task Agent Does

Single-agent execution loop phases

PhaseAction
Goal intakeDeveloper inputs goal and acceptance criteria
PlanningAgent generates an ordered list of atomic tasks
ExecutionAgent executes each task and evaluates output quality
EvaluationIf criteria met, move on; if not, revise and re-execute
CompletionFinal deliverable assembled and returned
Step limitStops at limit, returns partial output plus status report

When to use this pattern vs STATE.yaml:

PatternUse when
Goal-driven (this case)Execution path unknown upfront; task sequence adapts dynamically
STATE.yaml + subagentsFixed task list; parallel subagents speed up execution

You’ll build this on OpenClaw configured with WisGate, using a goal spec format and the system prompt detailed below.

LLM Self-Planning Agent: How to Specify a Goal the Agent Can Execute

The goal specification is your primary control surface. An unstructured goal risks meandering plans; a well-crafted goal leads to focused, efficient execution.

Example goal-spec.yaml (paste into the user message field):

yaml
# goal-spec.yaml

goal: >
  Generate a competitive analysis of three REST API authentication providers
  (Auth0, Clerk, and Supabase Auth) covering: pricing tiers, developer
  experience, SDK quality, and enterprise SSO support.

acceptance_criteria:
  - Each provider covered across all four dimensions
  - Pricing accurate to the provider's current public pricing page
  - A recommendation with explicit rationale in the final section
  - Total output length: 800–1,200 words

step_limit: 12       # agent stops with partial output if this is reached
output_format: markdown

Why step_limit is required

Without it, agents might get stuck revising a single task indefinitely if criteria are vague. Set step_limit about twice the expected task count — for roughly 5 tasks, 10–12 steps is effective. Start conservatively, adjust after initial runs.

OpenClaw API Goal-Driven Automation: WisGate Configuration

Follow these precise steps:

Step 1 — Locate and open the OpenClaw config file:

Open terminal and edit with nano:

nano ~/.openclaw/openclaw.json

Step 2 — Add WisGate provider to your models section:

Paste this JSON snippet inside models:

json
"models": {
  "mode": "merge",
  "providers": {
    "moonshot": {
      "baseUrl": "https://api.wisgate.ai/v1",
      "apiKey": "YOUR-WISGATE-API-KEY",
      "api": "openai-completions",
      "models": [
        {
          "id": "claude-opus-4-6",
          "name": "Claude Opus 4.6",
          "reasoning": false,
          "input": ["text"],
          "cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0},
          "contextWindow": 256000,
          "maxTokens": 8192
        }
      ]
    }
  }
}

Replace YOUR-WISGATE-API-KEY with your actual key from https://wisgate.ai/hall/tokens.

Step 3 — Save, exit, and restart OpenClaw:

If using nano, press Ctrl + O then Enter to save, Ctrl + X to exit. Stop OpenClaw with Ctrl + C, then restart:

openclaw tui

Why Opus for this case

Goal-driven cycles require planning, content creation, and strong self-evaluation. Claude Opus excels in reasoning-intensive tasks, especially where the agent assesses its own output rigorously. This model offers a 256K token context window and a max token output of 8,192 per request.

Per-run cost framing

At a 12-step limit averaging ~2,000 tokens output per step, total output tokens near 24,000 per run. Confirm precision and cost details from https://wisgate.ai/models.

The Goal-Driven Agent System Prompt

The system prompt directs how the agent plans, executes, self-evaluates, and completes its tasks:

IDENTITY:
You are a goal-driven autonomous task agent.
You receive a goal specification containing: a goal description, acceptance
criteria, a step limit, and an output format.
You plan your own task sequence. You do not ask for a predefined task list.

PLANNING PROTOCOL:
On receiving a goal specification:
1. Output a numbered task sequence — each task a single, atomic action
2. Identify which tasks depend on outputs from previous tasks
3. Confirm: "Plan complete. Beginning execution."
Do not begin execution until the plan is confirmed.

EXECUTION PROTOCOL:
For each task in sequence:
1. Execute the task fully
2. Self-evaluate: does this output satisfy the relevant acceptance criteria?
   Score 1 (does not satisfy) to 5 (fully satisfies)
3. If score < 4: identify the specific gap, revise, re-evaluate
4. If score >= 4: mark the task complete; proceed to the next task
5. Increment your internal step counter after every execution or revision
6. If step counter reaches the step limit: stop, return all completed
   outputs, and append a status report listing incomplete tasks and reason

COMPLETION PROTOCOL:
When all tasks are complete:
1. Assemble the final deliverable in the specified output format
2. Run a final acceptance check against all criteria
3. Return the deliverable followed by:
   - Steps used: N / [step_limit]
   - Tasks completed: N
   - Any criteria not fully satisfied: [list or "None"]

Customization note

Adjust the execution score threshold (default >=4) to tune precision vs exploration depending on task focus.

The WisGate API Call

This API call runs the full goal-driven agent sequence on WisGate:

curl -s -X POST \
  "https://api.wisgate.ai/v1/chat/completions" \
  -H "Authorization: Bearer $WISDOM_GATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-6",
    "messages": [
      {
        "role": "system",
        "content": "[PASTE GOAL-DRIVEN AGENT SYSTEM PROMPT HERE]"
      },
      {
        "role": "user",
        "content": "[PASTE goal-spec.yaml CONTENT HERE]"
      }
    ],
    "max_tokens": 8192
  }' | jq -r '.choices[0].message.content'

Set max_tokens to 8192 for step limits around 10–15. For bigger goals, adjust toward the 256K token context window documented at https://wisgate.ai/models.

Validate the prompt and goal spec with a dry run in AI Studio: https://wisgate.ai/studio/image.

OpenClaw Use Cases: Tuning the Step Limit and Handling Loop Failures

Prepare before production by considering these failure modes:

  1. Revision loop on ambiguous criteria: Vague terms like "high quality" cause the agent to cycle endlessly scoring 3. Remedy by converting criteria to measurable targets like word count or specific data points.

  2. Step limit reached early: If the agent stops before completion, the limit may be too low or the goal too broad. Examine the status report, then increase step_limit or split the goal into smaller parts.

  3. Planning phase too large: Over 15 tasks for a simple goal signals an under-constrained goal. Add a max_tasks field to the goal spec and update the Planning Protocol to avoid bloated plans.

OpenClaw Use Cases: Goal-Driven Execution as the Foundation for Adaptive Agents

The goal-driven pattern—plan, execute, self-evaluate, and revise—is the single-agent counterpart to the parallel STATE.yaml subagent method. Use it when task sequences must adapt on the fly. Choose STATE.yaml when tasks are predetermined and parallel processing reduces run time.

Both rely on the same WisGate API call and OpenClaw base config. The key difference lies in crafting the system prompt and goal specification.

Return to the OpenClaw Use Cases pillar page → for the full case library.

The system prompt is copy-ready, the step limit adjustable in one field, and the WisGate API call executable as-is. Your next action is to specify your goal and acceptance criteria, then start iterating at https://wisgate.ai/hall/tokens and https://wisgate.ai/studio/image.

How to Use STATE.yaml for Autonomous Tasks in OpenClaw | JuheAPI