openclaw - ✅(Solved) Fix [Bug]: Regression: Webhook agent runs always start a new session regardless of sessionKey / session config [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#70894Fetched 2026-04-24 10:38:09
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

Original issue was closed without fix

Webhook-triggered agent runs always start a new session and lose conversation history/context, even when providing the same stable sessionKey and allowing it in config.

Root Cause

Original issue was closed without fix

Webhook-triggered agent runs always start a new session and lose conversation history/context, even when providing the same stable sessionKey and allowing it in config.

Fix Action

Fix / Workaround

This appears to be a regression from the originally intended fix for #18027. Configuration allows the request, but current code logic hardcodes session resets for all isolated agent runs, providing no workaround for webhook stateful flows. There is no apparent config setting or payload option to bypass the forced new session; upstream patch is needed.

PR fix notes

PR #70895: fix(cron): allow webhook isolated runs to reuse sessionKey sessions

Description (problem / solution / changelog)

Motivation

  • Isolated cron runs always forced a fresh session which discarded context even for /hooks/agent webhook calls that intentionally provide stable sessionKey values or externalContentSource; this caused unwanted session rollovers and lost history.

Description

  • Compute forceNewSession in src/cron/isolated-agent/run.ts and only force a fresh session when sessionTarget === "isolated" and the run is not hook/webhook-sourced, preserving hook sessions when externalContentSource or hook:* session keys are present.
  • Update src/cron/isolated-agent/run.skill-filter.test.ts to add a regression test that verifies webhook-sourced isolated runs pass forceNew: false to resolveCronSession while keeping the existing isolated-cron behavior.
  • Modified files: src/cron/isolated-agent/run.ts, src/cron/isolated-agent/run.skill-filter.test.ts.

Testing

  • Ran the targeted tests with pnpm test src/cron/isolated-agent/run.skill-filter.test.ts src/cron/isolated-agent/session.test.ts and the suite passed.
  • Test output: 2 test files ran, 27 tests passed (all green).

Fixes #70894

Changed files

  • src/cron/isolated-agent/run.skill-filter.test.ts (modified, +17/-0)
  • src/cron/isolated-agent/run.ts (modified, +3/-1)

Code Example

See src/cron/isolated-agent/run.ts and src/cron/isolated-agent/session.ts:

// In run.ts
forceNew: params.job.sessionTarget === "isolated"
// In session.ts
if (!params.forceNew && entry?.sessionId) {...} else { sessionId = crypto.randomUUID(); }

This means session reuse logic is always bypassed for webhook agent turns, regardless of sessionKey value or freshness.
RAW_BUFFERClick to expand / collapse

Summary

Original issue was closed without fix

Webhook-triggered agent runs always start a new session and lose conversation history/context, even when providing the same stable sessionKey and allowing it in config.

Steps to reproduce

  1. Configure gateway with hooks.allowRequestSessionKey: true and (optionally) hooks.allowedSessionKeyPrefixes for your webhook agent.
  2. POST repeatedly to /hooks/agent with
  • The same sessionKey
  • The same agentId (if needed)
  • allowRequestSessionKey and allowedSessionKeyPrefixes set to permit your sessionKey value.
  1. Observe: every POST triggers a fresh agent session (no preservation of message history or agent context).

Expected behavior

Subsequent webhook invocations with the same sessionKey should preserve conversation context. Agent state/history should persist across webhook calls, matching other channels.

Actual behavior

Every webhook call creates a brand new sessionId no matter what sessionKey is provided, despite config allowing sessionKey reuse. No prior conversation history or state is available to the agent. Reviewing src/cron/isolated-agent/run.ts reveals forceNew: true is always hardcoded for isolated agent runs, bypassing sessionKey-based continuity.

OpenClaw version

2026.2.26 (and recent main branch)

Operating system

Any (tested on Linux, macOS)

Install method

Any (docker, dev, app builds all affected)

Logs, screenshots, and evidence

See src/cron/isolated-agent/run.ts and src/cron/isolated-agent/session.ts:

// In run.ts
forceNew: params.job.sessionTarget === "isolated"
// In session.ts
if (!params.forceNew && entry?.sessionId) {...} else { sessionId = crypto.randomUUID(); }

This means session reuse logic is always bypassed for webhook agent turns, regardless of sessionKey value or freshness.

Impact and severity

Affected: Anyone using webhook agent endpoints who relies on persistent session context Severity: Serious, blocks agent stateful automations on webhooks Frequency: 100% on webhook agent runs Consequence: Webhooks cannot preserve conversation history/context across runs. Only concurrency and metadata are scoped by sessionKey, not agent state.

Additional information

This appears to be a regression from the originally intended fix for #18027. Configuration allows the request, but current code logic hardcodes session resets for all isolated agent runs, providing no workaround for webhook stateful flows. There is no apparent config setting or payload option to bypass the forced new session; upstream patch is needed.

extent analysis

TL;DR

The most likely fix is to update the src/cron/isolated-agent/run.ts file to conditionally set forceNew based on the provided sessionKey and configuration settings.

Guidance

  • Review the src/cron/isolated-agent/run.ts and src/cron/isolated-agent/session.ts files to understand the current session management logic.
  • Consider modifying the forceNew parameter to be conditional, allowing session reuse when a valid sessionKey is provided and configuration settings permit it.
  • Investigate the original fix for #18027 to understand the intended behavior and how it was implemented.
  • Evaluate the feasibility of introducing a new configuration setting or payload option to control session behavior for webhook agent runs.

Example

// In run.ts
const forceNew = params.job.sessionTarget === "isolated" && !params.sessionKey;

This example illustrates a potential modification to the forceNew parameter, but the actual implementation may vary depending on the specific requirements and constraints.

Notes

The provided code snippet and analysis suggest that the issue is due to the hardcoded forceNew value for isolated agent runs. However, without further information about the intended behavior and constraints, it is difficult to provide a definitive solution.

Recommendation

Apply a workaround by modifying the src/cron/isolated-agent/run.ts file to conditionally set forceNew based on the provided sessionKey and configuration settings, as this appears to be the most direct way to address the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Subsequent webhook invocations with the same sessionKey should preserve conversation context. Agent state/history should persist across webhook calls, matching other channels.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: Regression: Webhook agent runs always start a new session regardless of sessionKey / session config [1 pull requests, 1 participants]