Skip to content

fix: remove deprecated empty-session-on-missing behavior from GET working-memory#169

Merged
bsbodden merged 3 commits intomainfrom
fix/remove-deprecated-empty-session-on-missing
Feb 26, 2026
Merged

fix: remove deprecated empty-session-on-missing behavior from GET working-memory#169
bsbodden merged 3 commits intomainfrom
fix/remove-deprecated-empty-session-on-missing

Conversation

@bsbodden
Copy link
Copy Markdown
Collaborator

@bsbodden bsbodden commented Feb 25, 2026

Summary

  • Removes the deprecated backward-compatibility path where GET /v1/working-memory/{session_id} returned an empty WorkingMemory with unsaved=True for missing sessions (old clients without X-Client-Version header or version < 0.12.0)
  • All clients now consistently receive 404 for missing sessions, preventing bugs from mismatched PUT/GET parameters
  • Removes parse_client_version(), is_old_client(), the X-Client-Version header parameter, and the new_session/unsaved fields from WorkingMemoryResponse
  • Updates docs/api.md to remove the deprecated fields from the schema table

Test plan

  • uv run ruff check && uv run ruff format — passes
  • uv run pytest tests/test_api.py -v — all tests pass
  • uv run pytest — full suite passes (704 passed, 102 skipped)
  • Verify client library still works — integration test confirms server omits new_session/unsaved and client model (fields default to None) parses the response without errors

Closes #136


Note

Medium Risk
Behavior change in GET /v1/working-memory/{session_id} (and its response schema) can break older clients that relied on implicit empty sessions or on new_session/unsaved fields; otherwise the change is localized to a single endpoint and its model/docs/tests.

Overview
GET /v1/working-memory/{session_id} now always returns 404 when a session is missing, removing the deprecated compatibility path that returned an empty, non-persisted session for older clients.

The API drops the X-Client-Version handling and removes deprecated WorkingMemoryResponse fields (new_session, unsaved); docs and tests are updated accordingly, including a test ensuring the client model still deserializes responses when those fields are absent.

Written by Cursor Bugbot for commit 7ee093d. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings February 25, 2026 23:14
@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented Feb 25, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes deprecated backward-compatibility behavior from the GET /v1/working-memory/{session_id} endpoint that previously returned an empty session with unsaved=True for missing sessions to support old clients. After this change, all clients consistently receive a 404 error for missing sessions, which aligns with proper REST semantics and prevents bugs caused by parameter mismatches between PUT and GET operations.

Changes:

  • Removed version-checking functions (parse_client_version(), is_old_client()) and the X-Client-Version header parameter from the GET endpoint
  • Updated get_working_memory() to always return 404 for missing sessions instead of conditionally creating empty unsaved sessions
  • Removed deprecated new_session and unsaved fields from WorkingMemoryResponse model
  • Updated tests to expect 404 responses and removed old client version test case
  • Applied code formatting improvements to assert statements following Black/Ruff conventions

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
agent_memory_server/api.py Removed version checking functions, X-Client-Version header parameter, and deprecated empty-session-on-missing behavior; simplified get_working_memory to always return 404 for missing sessions
agent_memory_server/models.py Removed deprecated new_session and unsaved fields from WorkingMemoryResponse
tests/test_api.py Updated test expectations to check for 404 on missing sessions, removed old client version test, and applied Black/Ruff formatting to assert statements

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

The code changes correctly remove the deprecated backward-compatibility behavior. However, there's a documentation inconsistency that should be addressed.

Documentation Issue:
The file docs/api.md still documents the new_session and unsaved fields in the WorkingMemoryResponse model (lines 533-534), but these fields have been removed from the server implementation. This documentation should be updated to reflect the current API schema.

Client Library Consideration:
The client libraries (Python, JavaScript, and Java) still have the new_session and unsaved fields in their WorkingMemoryResponse models. While this won't cause immediate breakage (clients will receive null values), consider documenting the plan for deprecating these fields in the client libraries in a future release.


🤖 Automated review complete. Please react with 👍 or 👎 on the individual review comments to provide feedback on their usefulness.

…king-memory

All clients now receive 404 for missing sessions instead of the old
backward-compat path that returned an empty WorkingMemory with
unsaved=True. Removes parse_client_version/is_old_client helpers,
the X-Client-Version header parameter, and the new_session/unsaved
response fields.

Closes #136
@bsbodden bsbodden force-pushed the fix/remove-deprecated-empty-session-on-missing branch from c494726 to 47ad29d Compare February 26, 2026 14:06
Add integration test that confirms the server response no longer includes
new_session/unsaved fields, and that the client library's
WorkingMemoryResponse model (which still declares them with default=None)
can deserialize the response without errors.
@bsbodden bsbodden requested a review from abrookins February 26, 2026 15:17
@bsbodden bsbodden self-assigned this Feb 26, 2026
@bsbodden
Copy link
Copy Markdown
Collaborator Author

Addressed both points from the automated review:

  1. docs/api.md — Removed new_session and unsaved from the WorkingMemoryResponse schema table (7ee093d).

  2. Client library fields — The client models (new_session, unsaved) default to None so they won't break. Added an integration test (test_response_omits_deprecated_fields_and_client_model_still_parses) that verifies the server no longer emits these fields and the client model still parses correctly (cb26c99). Removing the fields from the client libraries is a separate concern for a future client release.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

until_summarization_percentage
)
working_mem_data["new_session"] = new_session
working_mem_data["unsaved"] = unsaved
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment references removed new_session field

Low Severity

The comment on this line still references new_session ("no new_session for PUT") even though this PR removes the new_session field entirely from WorkingMemoryResponse. The parenthetical is now meaningless and could confuse future readers into thinking new_session is still a concept in the codebase.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Contributor

@vishal-bala vishal-bala left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@bsbodden bsbodden merged commit a1a021e into main Feb 26, 2026
26 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.

Remove deprecated empty-session-on-missing behavior from GET working-memory

3 participants