Skip to content

LCORE-5824: Add StepPersistenceSettings to enable or disable agent step persistence - #3347

Open
jrobertboos wants to merge 1 commit into
lightspeed-core:mainfrom
jrobertboos:lcore-5824
Open

jrobertboos wants to merge 1 commit into
lightspeed-core:mainfrom
jrobertboos:lcore-5824

Conversation

@jrobertboos

@jrobertboos jrobertboos commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library [pyproject.toml + uv.lock]
  • Bump-up dependent library [requirements.*.txt for Konflux]
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: (e.g., Claude, CodeRabbit, Ollama, etc., N/A if not used)
  • Generated by: (e.g., tool name and version; N/A if not used)

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • New Features
    • Added configurable step persistence for agent history. It is enabled by default and can be disabled through settings.
    • Persistence is available when a history store is configured; otherwise, agents continue without it.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds default-enabled step-persistence settings to agent configuration. Agent creation passes those settings to the capability factory, which skips history-service construction when persistence is disabled.

Changes

Step persistence configuration

Layer / File(s) Summary
Settings contract and query mapping
src/agent/types/settings/step_persistence.py, src/agent/types/settings/agent.py, src/agent/types/settings/__init__.py, tests/unit/agent/types/settings/*
StepPersistenceSettings defaults to enabled. AgentSettings.from_query_request includes these settings, and the settings package exports the new type. Tests check the default settings.
Capability gating and agent wiring
src/agent/capabilities/step_persistence/factory.py, src/agent/factory.py, tests/unit/agent/capabilities/step_persistence/test_factory.py, tests/unit/agent/test_factory.py
AgentFactory passes the settings to StepPersistenceFactory. The capability factory returns None without constructing the history service when persistence is disabled. When enabled, it returns the service capability, which may be None. Tests cover these outcomes and the factory call.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant AgentSettings
  participant StepPersistenceSettings
  participant AgentFactory
  participant StepPersistenceFactory
  participant AgentHistoryService
  AgentSettings->>StepPersistenceSettings: Build default settings from QueryRequest
  AgentSettings->>AgentFactory: Provide settings
  AgentFactory->>StepPersistenceFactory: Pass step_persistence settings
  alt Persistence disabled
    StepPersistenceFactory-->>AgentFactory: Return None without constructing history service
  else Persistence enabled
    StepPersistenceFactory->>AgentHistoryService: Obtain step-persistence capability
    AgentHistoryService-->>StepPersistenceFactory: Return capability or None
    StepPersistenceFactory-->>AgentFactory: Return capability or None
  end
Loading

Possibly related PRs

Suggested reviewers: tisnik, asimurka

Merge Risk: Minimal · up to dc917

This adds a persistence setting that defaults to enabled, so existing behavior is preserved. No merge-blocking risk is identified.

Pre-merge checks: Passed 6

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: adding StepPersistenceSettings to enable or disable agent step persistence. The raw summary confirms a new settings dataclass with an enabled flag, wired into the step…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Performance And Algorithmic Complexity Passed The PR adds a StepPersistenceSettings dataclass (enabled: bool = True), threads it into StepPersistenceFactory.build_capability(settings), and returns None early when disabled. I read the full…
Security And Secret Handling Passed The PR changes nine files, all under src/agent and matching tests. I read the full source diff. It contains no change that matches the custom check's five conditions. 1. **Hardcoded or logged secret…
Full details: Title check

Explanation

The title names the main change: adding StepPersistenceSettings to enable or disable agent step persistence. The raw summary confirms a new settings dataclass with an enabled flag, wired into the step persistence factory and agent factory, with matching tests. The ticket prefix is harmless. The title is specific and accurate, so it passes.

Full details: Performance And Algorithmic Complexity

Explanation

The PR adds a StepPersistenceSettings dataclass (enabled: bool = True), threads it into StepPersistenceFactory.build_capability(settings), and returns None early when disabled. I read the full src/ diff (9 files changed). No new loops, list operations, N+1 query patterns, regex compilation, caches, buffers, or endpoints are introduced. - src/agent/capabilities/step_persistence/factory.py: the only logic change is an early return None when settings.enabled is false. When enabled, the code still calls AgentHistoryService().step_persistence once, as the code did before this PR. The disabled path avoids that call, so it does slightly less work. - src/agent/factory.py: passes settings.step_persistence. This is a single call per agent build, with no iteration added. - src/agent/types/settings/agent.py: adds a field and a constant-time from_query_request that returns cls(). - Exports and tests: no runtime cost. None of the five listed performance criteria applies to this change. The check passes.

Full details: Security And Secret Handling

Explanation

The PR changes nine files, all under src/agent and matching tests. I read the full source diff. It contains no change that matches the custom check's five conditions. 1. Hardcoded or logged secrets: None. The new code adds no literals, credentials, tokens, or log calls. 2. Missing auth on endpoints: None. No API route, handler, or endpoint is added or changed. The only new behavior is a settings flag. StepPersistenceSettings.from_query_request ignores the request and returns cls() with enabled=True. 3. Injection: None. No query, shell, or path construction is added. 4. Sensitive data in responses, WebSocket messages, or logs: None. StepPersistenceFactory.build_capability(settings) returns None when settings.enabled is false. Otherwise it returns the existing AgentHistoryService().step_persistence. The PR does not change what is persisted. It only adds a gate. 5. K8s or RH secrets without OwnerReferences: Not applicable. No Kubernetes or Red Hat secret manifests are in the diff. The check is clean. Verdict: PASSED.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Simplify code

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 48322e9 and dc91794.

Files selected for processing: 9

  • src/agent/capabilities/step_persistence/factory.py
  • src/agent/factory.py
  • src/agent/types/settings/__init__.py
  • src/agent/types/settings/agent.py
  • src/agent/types/settings/step_persistence.py
  • tests/unit/agent/capabilities/step_persistence/test_factory.py
  • tests/unit/agent/test_factory.py
  • tests/unit/agent/types/settings/test_agent.py
  • tests/unit/agent/types/settings/test_step_persistence.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details

Context from checks skipped due to timeout: 20

  • GitHub Check: E2E: ci / rbac
  • GitHub Check: E2E: ci / authorized
  • GitHub Check: E2E: ci / skills
  • GitHub Check: E2E: ci / default
  • GitHub Check: E2E: ci / other
  • GitHub Check: E2E: ci / shields
  • GitHub Check: E2E: ci / mcp
  • GitHub Check: Red Hat Konflux / rag-content-0-8-e2e-tests / lightspeed-stack-0-8
  • GitHub Check: Red Hat Konflux / lightspeed-stack-0-8-e2e-tests / lightspeed-stack-0-8
  • GitHub Check: Red Hat Konflux / lightspeed-core-0-8-enterprise-contract / lightspeed-stack-0-8
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: unit_tests (3.14)
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: integration_tests (3.14)
  • GitHub Check: build-pr
  • GitHub Check: mypy
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: Pylinter
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-8-on-pull-request
Additional context used

Code guidelines: 2

AGENTS.md — auto-discovered
CLAUDE.md — auto-discovered
Path-based instructions: 5

Source excerpt: **Required**: Use pytest for all unit and integration tests Source excerpt: **Forbidden**: Do not use unittest - pytest is the standard for this project Source excerpt: **Coverage**: Unit tests require 60% coverage, integrat...

CodeRabbit inference engine (AGENTS.md)

Files:

  • tests/unit/agent/capabilities/step_persistence/test_factory.py
  • tests/unit/agent/test_factory.py
  • tests/unit/agent/types/settings/test_agent.py
  • tests/unit/agent/types/settings/test_step_persistence.py
Source excerpt: **Required**: Use pytest for all unit and integration tests Source excerpt: **Forbidden**: Do not use unittest - pytest is the standard for this project Source excerpt: **Mocking**: `pytest-mock` for AsyncMock objects

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/unit/agent/capabilities/step_persistence/test_factory.py
  • tests/unit/agent/test_factory.py
  • tests/unit/agent/types/settings/test_agent.py
  • tests/unit/agent/types/settings/test_step_persistence.py
Source excerpt: **Coverage**: Unit tests require 60% coverage, integration 10% Source excerpt: **Async tests**: Use marker `pytest.mark.asyncio`

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/unit/agent/capabilities/step_persistence/test_factory.py
  • tests/unit/agent/test_factory.py
  • tests/unit/agent/types/settings/test_agent.py
  • tests/unit/agent/types/settings/test_step_persistence.py
Source excerpt: **Mocking**: `pytest-mock` for AsyncMock objects Source excerpt: **Async tests**: Use marker `pytest.mark.asyncio`

CodeRabbit inference engine (AGENTS.md)

Files:

  • tests/unit/agent/capabilities/step_persistence/test_factory.py
  • tests/unit/agent/test_factory.py
  • tests/unit/agent/types/settings/test_agent.py
  • tests/unit/agent/types/settings/test_step_persistence.py
Source excerpt: Package `__init__.py` files contain brief package descriptions

CodeRabbit inference engine (CLAUDE.md)

Files:

  • src/agent/types/settings/__init__.py
Learnings: 2

Learning: 2026-06-24T13:45:37.249Z

Learnt from: Jdubrick
Repo: lightspeed-core/lightspeed-stack PR: 1971
File: src/utils/markdown_repair.py:31-36
Timestamp: 2026-06-24T13:45:37.249Z
Learning: In the lightspeed-stack repository, docstrings must use the section header name "Parameters:" (not "Args:") for function arguments, even if the project references Google Python docstring conventions. Ensure docstrings follow the project’s established "Parameters:" header format for any documented function parameters.

Applied to files:

  • src/agent/capabilities/step_persistence/factory.py
  • src/agent/types/settings/agent.py
  • src/agent/types/settings/step_persistence.py
Learning: 2026-07-21T11:10:05.060Z

Learnt from: are-ces
Repo: lightspeed-core/lightspeed-stack PR: 2162
File: src/a2a_client/__init__.py:3-9
Timestamp: 2026-07-21T11:10:05.060Z
Learning: In this repository, it is acceptable for Python package `__init__.py` files to contain functional code (not only docstrings/metadata) and to perform package-level re-exports. Do not flag `__init__.py` solely for containing imports or other logic used to re-export symbols; this is allowed when it’s implemented via imports and `__all__` (or otherwise clearly intended to define the package’s public API).

Applied to files:

  • src/agent/types/settings/__init__.py

@jrobertboos
jrobertboos requested a review from asimurka November 25, 2026 13:18

@asimurka asimurka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@asimurka
asimurka requested a review from tisnik November 25, 2026 15:38

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants