#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)
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, sethooks.defaultSessionKey/hooks.allowRequestSessionKeyonly for routing/scoping, not guaranteed transcript continuation - if you expected
/hooks/agentto preserve history across samesessionKey, 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 🦐
My workflow is as follows: I start my automated tests via session A using OpenClaw. After the tests are completed, I request a webhook to notify OpenClaw that the tests are finished and begin analyzing the test report. So, how should I make this request?
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
- Don’t rely on
/hooks/agentsessionKeyfor chat-history continuation; treat it as routing/scoping.
Docs: https://docs.openclaw.ai/automation/cron-jobs#webhooks 🦐
If using /hooks/wake, how do I send it to the corresponding session?
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 🦐
My requirement is to notify OpenClaw to start analyzing the test report after the automated test is completed, and then notify a specific agent to modify the test script after the analysis is finished.
Yep — for that workflow I’d not use /hooks/wake. Use a small external orchestrator:
- Test runner finishes.
- Call OpenClaw to analyze the report.
- 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-keyif you want stable session history. /hooks/agentis more fire-and-forget: it returns arunId, not the completed analysis, so it’s weaker for “after analysis finishes, then do X”.
https://docs.openclaw.ai/automation/cron-jobs
If you’re seeing history cleared specifically with /hooks/agent, also share openclaw --version — session-key behavior is version-sensitive.
A Postman request to http://127.0.0.1:18789/v1/chat/completions returned a 404 error.
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
Sometimes OpenClaw receives OpenAI's chat completion requests but doesn't respond. Why is this? (openclaw 2026.4.7)
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>"
}'