feat(openclaw): add session pattern filtering for ignore and stateless sessions#909
Merged
nicoloboschi merged 3 commits intovectorize-io:mainfrom Apr 9, 2026
Merged
Conversation
…s sessions Adds three new config options to the OpenClaw plugin that allow filtering sessions by key pattern before recall and retain operations fire: - `ignoreSessionPatterns`: glob patterns for sessions to skip entirely (no recall, no retain). Useful for cron/scheduled agent sessions. - `statelessSessionPatterns`: glob patterns for read-only sessions — retain is always skipped; recall is also skipped when `skipStatelessSessions` is true (default). - `skipStatelessSessions`: boolean (default: true). When false, sessions matching statelessSessionPatterns can still recall but never retain. Pattern syntax mirrors lossless-claw: `*` matches non-colon characters, `**` matches anything including colons. Session keys follow the OpenClaw format `agent:<agentId>:<type>:<uuid>`. Example config: ignoreSessionPatterns: ["agent:*:cron:**"] statelessSessionPatterns: ["agent:*:subagent:**", "agent:*:heartbeat:**"] skipStatelessSessions: true Implementation: - New `session-patterns.ts` module with compile/match utilities - Session filter applied in `before_prompt_build` and `agent_end` hooks immediately after the existing `excludeProviders` check - New fields wired through `getPluginConfig` - Schema added to `openclaw.plugin.json` (additionalProperties: false was already set, causing config validation errors without this) - 11 unit tests in `session-patterns.test.ts` - 5 integration tests added to `hooks.integration.test.ts` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pass HINDSIGHT_API_TOKEN env var through to HindsightClient and plugin config in integration tests so tests work against authenticated APIs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
419ba1b to
bdef3d2
Compare
Add ignoreSessionPatterns, statelessSessionPatterns, and skipStatelessSessions to the README config table with glob syntax reference and usage examples. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ignoreSessionPatterns,statelessSessionPatterns, andskipStatelessSessionsconfig options to the OpenClaw plugin, mirroring the same feature in lossless-clawignoreSessionPatternsskip both recall and retain entirely (e.g. cron jobs)statelessSessionPatternsalways skip retain; skip recall too whenskipStatelessSessions: true(default)*matches non-colon chars,**matches anything including colons (e.g.agent:*:cron:**)session-patterns.tsmodule withcompileSessionPattern/matchesSessionPatternhelpersConfig example
{ "ignoreSessionPatterns": ["agent:*:cron:**"], "statelessSessionPatterns": ["agent:*:subagent:**", "agent:*:heartbeat:**"], "skipStatelessSessions": true }Test plan
npm test— 77/77 passnpm run test:integrationagainst live Hindsight API — 40/40 passSkipping recall: session 'agent:main:cron:1022fbf2-...' matches ignoreSessionPatterns🤖 Generated with Claude Code