fix: workspace-aware default session identity (#3154)#3157
fix: workspace-aware default session identity (#3154)#3157praisonai-triage-agent[bot] wants to merge 2 commits into
Conversation
Same-named agents in different projects no longer share conversation
history by default. The auto-derived session id now folds in a stable
workspace/project component (git root-commit, else resolved cwd, else
global) instead of being a function of the agent name alone.
- Add praisonaiagents/session/workspace.py with workspace_id() resolver
- Derive auto id as history_<sha256("{workspace}:{name}")[:8]>
- Keep name-only sha256 + md5 fallbacks so prior sessions still resolve
- Add PRAISONAI_GLOBAL_SESSIONS=true opt-out for name-only continuity
Co-authored-by: MervinPraison <MervinPraison@users.noreply.github.com>
|
@coderabbitai review |
|
/review |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more β On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
β Action performedReview finished.
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the βοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
π WalkthroughWalkthroughThe change adds cached workspace identity resolution, exposes it through the session package, and incorporates it into automatic history session IDs. Global opt-out behavior and fallback lookup for legacy SHA-256 and MD5 session files are retained. ChangesWorkspace-scoped session identity
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Agent
participant workspace_id
participant SessionJSONFiles
Agent->>workspace_id: resolve workspace identity
workspace_id-->>Agent: return scoped or global identity
Agent->>SessionJSONFiles: check derived history session ID
SessionJSONFiles-->>Agent: load new or legacy session JSON
Suggested labels: Suggested reviewers: π₯ Pre-merge checks | β 5β Passed checks (5 passed)
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
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. Comment |
Greptile SummaryThis PR makes automatically generated history sessions workspace-aware. The main changes are:
Confidence Score: 5/5The latest fixes look safe to merge.
Important Files Changed
Reviews (2): Last reviewed commit: "fix: harden workspace session isolation ..." | Re-trigger Greptile |
|
@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding. Phase 1: Review per AGENTS.md
Phase 2: FIX Valid Issues Phase 3: Final Verdict |
|
Claude finished @MervinPraison's task ββ View job Final Architecture Review β PR #3157 β
Phase 1 β Architecture review (per AGENTS.md)
Phase 2 β Fixes implementedGreptile raised 3 P1s. Assessment + action:
Files modified
Skipped: No changes to Phase 3 β Verdictβ
Approve. All three P1 reviewer concerns are resolved with minimal, backward-compatible, hot-path-safe changes. Tests:
|
- Honor PRAISONAI_HOME in legacy-session migration lookup via get_sessions_dir() instead of a hardcoded ~/.praisonai/sessions path. - Gate legacy name-only fallback to global scope only, so a workspace-scoped run never silently adopts another project's history (isolation, #3154). - Resolve workspace identity per-directory (cache keyed by cwd) so a long-lived process that changes directory gets the correct identity while still avoiding repeated git calls per directory. - Add tests for directory-change identity and global-scoped legacy fallback. Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
Fixes #3154
Problem
When history/memory is enabled but no explicit
session_idis given, the coreAgentderived its default session id from the agent name only (history_<sha256(name)[:8]>). Two agents sharing a name across different projects resolved to the same session file and silently cross-contaminated conversation history (a correctness and privacy issue).Fix (core, minimal)
praisonaiagents/session/workspace.pywithworkspace_id(): prefers a stable git root-commit identity, falls back to the resolved cwd, thenglobal. Cached for the process lifetime.history_<sha256("{workspace}:{name}")[:8]>, so identical agent names in different projects no longer collide.history_*.jsonsessions still load.PRAISONAI_GLOBAL_SESSIONS=truerestores name-only global continuity.workspace_idlazy-exported fromsession/__init__.py.Scope
Core-only, no new Agent params, no new dependencies, no new exported knobs beyond the internal resolver. Explicit
session_idcontinues to win and remains fully global.Tests
TestWorkspaceScopedSessionId(3 tests) totests/unit/test_history_parameter.py: stableworkspace_id(), workspace-folded auto id differs from name-only, and the global opt-out.tests/unit/test_history_parameter.py: 16/16 pass. Remaining session-suite failures are pre-existing and unrelated (verified against a clean tree).Generated with Claude Code
Summary by CodeRabbit
New Features
PRAISONAI_GLOBAL_SESSIONS.Bug Fixes