#When making a POST request to /hooks/agent, the chat history for the same session will be cleared.

1 messages · Page 1 of 1 (latest)

wispy perch
#

curl -X POST https://your-gateway/hooks/agent
-H "Authorization: Bearer your-secret-token"
-H "Content-Type: application/json"
-d '{
"agentId": "my-agentId",
"message": "",
"sessionKey": "optional-custom-session"
}'

wispy flowerBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

limpid thicketBOT
#

Please share openclaw --version first — behavior here has changed over time.

On current docs/source: /hooks/agent is an isolated hook run, not a normal continuing chat session. A stable sessionKey scopes/routs the hook, but the run is currently forced fresh internally, so previous transcript/history won’t be reused like a regular chat thread.

Also: your example has "message": "", which should be rejected with message required; it needs a non-empty message.

If you want stable context:

  • for main-session wakeups, use POST /hooks/wake
  • for /hooks/agent, set hooks.defaultSessionKey / hooks.allowRequestSessionKey only for routing/scoping, not guaranteed transcript continuation
  • if you expected /hooks/agent to preserve history across same sessionKey, that’s worth filing as a GitHub issue with your version + repro: https://github.com/openclaw/openclaw/issues

Docs: https://docs.openclaw.ai/gateway/configuration-reference#hooks 🦐

wispy perch
limpid thicketBOT
#

For your workflow, I’d use /hooks/wake, not /hooks/agent, if you want OpenClaw to continue from the main/session-A conversation context.

Example:

curl -X POST https://your-gateway/hooks/wake \
  -H "Authorization: Bearer your-hooks-token" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: test-run-123-finished" \
  -d '{
    "mode": "now",
    "text": "The automated test run I started is finished. Please analyze the test report at /path/to/report.xml and summarize failures, likely causes, and next actions."
  }'

Use /hooks/agent only if you’re okay with a fresh isolated analysis run. In that case, make the message fully self-contained:

#
curl -X POST https://your-gateway/hooks/agent \
  -H "Authorization: Bearer your-hooks-token" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "my-agentId",
    "name": "Test report analysis",
    "message": "Analyze this completed test report: /path/to/report.xml. Summarize failures and suggested fixes.",
    "deliver": true,
    "wakeMode": "now"
  }'

So the short version:

  • Continue the existing OpenClaw conversation / session A: use /hooks/wake
  • Run a separate webhook-triggered agent job: use /hooks/agent
wispy perch
limpid thicketBOT
#

Short answer: you can’t target a specific session with /hooks/wake right now. It only enqueues a system event for the main session.

If you need “send this completion event back into session A”, use a session-routed Gateway call instead, e.g. OpenAI-compatible HTTP:

curl -sS https://your-gateway/v1/chat/completions \
  -H "Authorization: Bearer $OPENCLAW_GATEWAY_TOKEN" \
  -H "Content-Type: application/json" \
  -H "x-openclaw-session-key: agent:main:discord:..." \
  -d '{
    "model": "openclaw/default",
    "messages": [{
      "role": "user",
      "content": "The test run is finished. Analyze the report at /path/to/report.xml and summarize failures."
    }]
  }'
#

Important differences:

  • /hooks/wake = main session only.
  • /hooks/agent = isolated run, not session-A history.
  • /v1/chat/completions + x-openclaw-session-key = explicit session routing.
  • This uses the Gateway token, not the hooks token, so keep it on loopback/tailnet/private ingress only.

Docs: https://docs.openclaw.ai/gateway/openai-http-api
Session keys: openclaw sessions --json 🦐

wispy perch
limpid thicketBOT
#

Yep — for that workflow I’d not use /hooks/wake. Use a small external orchestrator:

  1. Test runner finishes.
  2. Call OpenClaw to analyze the report.
  3. When that HTTP call returns, call the specific “modifier” agent with the analysis.

Best fit is the Gateway OpenAI-compatible endpoint because it’s request/response:

# 1) analyze
ANALYSIS=$(
  curl -sS "$GATEWAY/v1/chat/completions" \
    -H "Authorization: Bearer $OPENCLAW_GATEWAY_TOKEN" \
    -H "Content-Type: application/json" \
    -H "x-openclaw-session-key: agent:test-analyzer:ci-$BUILD_ID" \
    -d '{
#
      "model": "openclaw/test-analyzer",
      "messages": [{
        "role": "user",
        "content": "Tests completed. Analyze the report at /path/to/report.xml. Return root cause and recommended script changes."
      }]
    }' | jq -r '.choices[0].message.content'
)

# 2) ask modifier agent to change the script
jq -n --arg analysis "$ANALYSIS" '{
  model: "openclaw/test-modifier",
  messages: [{
    role: "user",
    content: ("Use this analysis to modify the test script:\n\n" + $analysis)
  }]
#
}' | curl -sS "$GATEWAY/v1/chat/completions" \
  -H "Authorization: Bearer $OPENCLAW_GATEWAY_TOKEN" \
  -H "Content-Type: application/json" \
  -H "x-openclaw-session-key: agent:test-modifier:ci-'$BUILD_ID'" \
  -d @-

Important bits:

  • Enable gateway.http.endpoints.chatCompletions.enabled.
  • Use model: "openclaw/<agentId>" to target a specific agent.
  • Use x-openclaw-session-key if you want stable session history.
  • /hooks/agent is more fire-and-forget: it returns a runId, not the completed analysis, so it’s weaker for “after analysis finishes, then do X”.

Docs:
https://docs.openclaw.ai/gateway/openai-http-api

limpid thicketBOT
#

A 404 there usually means the OpenAI-compatible HTTP endpoint is not enabled yet, or you’re hitting a Gateway version that doesn’t have it.

First, please check:

openclaw --version

Then enable this in your OpenClaw config:

{
  gateway: {
    http: {
      endpoints: {
        chatCompletions: { enabled: true },
#
      },
    },
  },
}

Restart the gateway:

openclaw gateway restart

Smoke test:

#
curl -sS http://127.0.0.1:18789/v1/models \
  -H "Authorization: Bearer $OPENCLAW_GATEWAY_TOKEN"

Then retry POST /v1/chat/completions.

Also make sure Postman is using POST, with:

Authorization: Bearer <gateway token>
Content-Type: application/json

Docs: https://docs.openclaw.ai/gateway/openai-http-api

wispy perch
limpid thicketBOT
#

On 2026.4.7, the most likely reason is: non-streaming /v1/chat/completions only responds after the whole OpenClaw agent turn finishes.

So if the selected agent is waiting on:

  • a slow/hung model call
  • a tool call
  • memory/compaction
  • a locked/busy session from the same x-openclaw-session-key
  • provider timeout/fallback behavior

…the HTTP request just stays open and looks like “no response”.

I’d strongly recommend updating first — 2026.4.7 is pretty old now and a bunch of timeout/stuck-session fixes landed after that:

openclaw update
#
openclaw gateway restart

Then test with streaming so you can tell whether the run starts:

curl -N http://127.0.0.1:18789/v1/chat/completions \
  -H "Authorization: Bearer $OPENCLAW_GATEWAY_TOKEN" \
  -H "Content-Type: application/json" \
  -H "x-openclaw-session-key: agent:test-analyzer:debug-1" \
  -d '{
    "model": "openclaw/default",
    "stream": true,
    "messages": [{"role":"user","content":"Say hello briefly"}]
  }'
#

Also avoid reusing the same session key for concurrent CI requests. If request B uses the same session while request A is still running, it can queue behind A and appear stuck.

If it still hangs after updating, run:

openclaw status --all
openclaw logs --follow

and look for the run’s model/tool step near the time of the Postman request. Docs: https://docs.openclaw.ai/gateway/openai-http-api

#

Use /hooks/agent with an explicit Discord delivery target.

curl -X POST http://127.0.0.1:18789/hooks/agent \
  -H "Authorization: Bearer $OPENCLAW_HOOK_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "my-agentId",
    "name": "CI test report",
    "message": "Analyze the test report and summarize the result.",
    "sessionKey": "hook:ci:build-123",
    "deliver": true,
    "channel": "discord",
    "to": "channel:<discord-channel-or-thread-id>"
  }'