Skip to content

fix: finalize saved sessions without forcing extraction - #189

Merged
guangyu-reflexio merged 3 commits into
mainfrom
team/short-session-finalization
Oct 14, 2026
Merged

guangyu-reflexio merged 3 commits into
mainfrom
team/short-session-finalization

Conversation

@guangyu-reflexio

@guangyu-reflexio guangyu-reflexio commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

SessionEnd previously forced extraction only when unpublished messages remained. Publish without bypassing the usefulness judge, then send a completion hint even when Stop already saved everything. Failed publication and read-only/internal invocations do not finalize. Older backends retain saved messages and receive an actionable diagnostic, without forced extraction or duplicate publishing.

The bundled Reflexio pin includes optional completion and the configurable six-hour inactivity fallback for publish-only agents, including Codex and OpenCode. Managed mode requires the companion backend deployment. This PR does not publish npm or deploy cloud services.

Validation: 1,127 local plugin tests passed against the updated backend; Ruff/Pyright and vendor integrity checks passed. The previous head passed full CI. The final SDK cache-invalidation fix is included in the updated vendor pin; all current-head CI checks passed after the final backend pin update. GitHub Codex reviewed the current head with no major issues and no P0/P1 findings.

Related PRs:

Summary by CodeRabbit

  • New Features
    • Session completion now publishes any unsaved messages and sends a completion signal, even when all messages were already saved. Normal usefulness checks still apply; completion does not guarantee that learning occurs.
    • With an updated backend, short sessions can be evaluated after six hours without a new publication. This fallback can be disabled in settings.
  • Documentation
    • Added guidance on session finalization, delayed evaluation, and using /learn for manual forced learning.

The final bundle includes resilient post-commit completion wakeup. GitHub Codex review completed on the final head with no major issues and no P0/P1 findings.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: fbcae7aa-56d5-4b50-a9f6-82be36e925bc
📥 Commits

Reviewing files that changed from the base of the PR and between 7962fac and a2dad63.

📒 Files selected for processing: 1
  • reflexio.lock.json

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

📝 Walkthrough

SessionEnd publishes unsaved turns without forcing extraction. After a non-failed publish result, it sends a session-completion hint through the adapter. Documentation and tests describe the updated behavior.

Changes: Session completion

Layer / File(s) Summary
Add adapter session finalization
plugin/src/claude_smart/reflexio_adapter.py, reflexio.lock.json, tests/test_adapter.py
Adapter.finalize_session sends a completion request using the project ID as user_id. It returns True only for a dictionary response with success exactly True. Tests cover response handling and errors.
Integrate finalization with SessionEnd
plugin/src/claude_smart/events/session_end.py, plugin/src/claude_smart/publish.py, tests/test_events.py, README.md, ARCHITECTURE.md, EXPERIMENT.md, plugin/src/README.md
SessionEnd publishes with force_extraction=False and finalizes after results other than "failed". Tests cover finalization conditions and read-only mode. Documentation describes extraction gating, completion behavior, and backend support.

Priority: ⬇️ Low

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant SessionEnd
  participant publish_unpublished
  participant Adapter
  participant ReflexioBackend
  SessionEnd->>publish_unpublished: Publish unsaved turns with force_extraction=False
  publish_unpublished-->>SessionEnd: Return publish result
  SessionEnd->>Adapter: Call finalize_session for a non-failed result
  Adapter->>ReflexioBackend: Send session-completion request
  ReflexioBackend-->>Adapter: Return response
Loading
Merge Risk: ⚪ Minimal · up to a2dad

No merge-blocking issue is established for the updated dependency pin; the pinned endpoint matches the session-finalization call.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 53.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 5 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: finalizing saved sessions without forcing extraction.
Full details: Docstring Coverage

Explanation

Docstring coverage is 53.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 5 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T22:22:34.403780Z a2dad63 Manual request
🔒 Security Review ✅ Completed 2026-10-14T20:39:21.905439Z 1a33c70 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@guangyu-reflexio

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: a2dad6363e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

guangyu-reflexio added a commit to ReflexioAI/reflexio that referenced this pull request Oct 14, 2026
Short sessions can be saved without reaching the first extraction window
or stride. Add optional `session_finished` publishing and
`finalize_session` operations, plus a default six-hour session
inactivity fallback. Both reuse the existing judge → extractor →
consolidation → conditional aggregation pipeline. Normal window/stride
and explicit manual-force behavior stay intact.

Boundaries survive late messages, respect project/user scope, ignore
covered or erased prefixes, and retain durable wakeups across restart.
Existing pinned work remains immutable. Timeout configuration is
captured prospectively; zero disables fallback for new publications.
Legacy admissions support explicit completion without inferred idle
backfill.

Validation: 443 backend/SDK tests passed after rebasing onto current
main, covering real HTTP/provider seams, positive/negative judges,
retries, rollback, late arrivals, erasure, index use and scheduler
restart. Ruff/Pyright passed. Follow-up review fix invalidates learning
caches on successful sync/async completion; 90 SDK/cache tests passed.
All four current-head installed-wheel CI jobs passed. GitHub Codex
reviewed the current head with no major issues and no P0/P1 findings.

Related PRs:
- PostgreSQL integration and public documentation:
ReflexioAI/reflexio-enterprise#1765
- Plugin: ReflexioAI/claude-smart#189


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Partial extraction windows can now be evaluated after a
session-completion hint or a configurable inactivity period, while
retaining the usefulness check.
* Added session-finalization methods for standard and session-scoped
clients.
* Short messages can now reach the usefulness check instead of being
rejected by a length filter.
* **Documentation**
* Updated guidance on completion hints, idle timeouts, partial windows,
and manual forced extraction.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Completion acceptance also survives post-commit scheduler failures. Five
HTTP/library short-session regression cases passed; Ruff and Pyright
passed. GitHub Codex review completed on the final head with no major
issues and no P0/P1 findings.
@guangyu-reflexio
guangyu-reflexio merged commit 370a93b into main Oct 14, 2026
9 checks passed
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.

1 participant