Skip to content

Fix/43: agent tool session now cleared - #1008

Open
ec6862 wants to merge 8 commits into
ascherj:mainfrom
AI201-Applications-of-AI-Engineering:fix/43-agent-state-not-cleared
Open

Fix/43: agent tool session now cleared#1008
ec6862 wants to merge 8 commits into
ascherj:mainfrom
AI201-Applications-of-AI-Engineering:fix/43-agent-state-not-cleared

Conversation

@ec6862

@ec6862 ec6862 commented Aug 9, 2026

Copy link
Copy Markdown

Summary

Fixes a session-state leak in the agent orchestrator. When the same user
requested a second review, Orchestrator.run() loaded the previous review's
stored state and merged the new results onto it with dict.update(). Any tool
that ran in an earlier review but not the current one (e.g. skill_extractor
when a résumé was removed) left stale output behind in the stored session, so
the user's re-review reflected a portfolio version that no longer existed. This
PR makes each review persist only its own results, so re-reviews start clean.

Issue

Closes #43

Changes

  • agent/orchestrator.py: Removed the load-and-merge of prior session state
    (session_store.get(...) + session_state.update(results)). The current
    review's results are now written directly with
    session_store.set(profile_id, results), which overwrites the stored session
    instead of accumulating stale tools.
  • tests/unit/test_orchestrator_session_reset.py: Added a regression test
    that runs two reviews for one user against a shared store and asserts the
    second review's stored session contains only its own tools.

Testing

  • Unit tests pass (make test-unit)
  • Integration tests pass (make test-integration)
  • Linter passes (make lint)
  • Type checker passes (make typecheck)
  • New/updated tests cover the changes

The boxes above are left unchecked deliberately — see Notes for Reviewers. The
new regression test (test_session_state_cleared_between_reviews) fails on
main and passes with this change. My changed files (orchestrator.py and the
test) pass ruff, black, and mypy individually

Screenshots / Demo

N/A — backend logic change, covered by the unit test above.

Notes for Reviewers

  • The fix is a small, contained change to how the orchestrator persists state;
    session_store.py needed no changes (its set() already overwrites the key).
  • On the checkboxes: make check and make test-unit do not currently pass
    on a clean checkout of this branch's base — there are ~175 pre-existing ruff
    errors, ~5 mypy errors, and 53 failing unit tests across unrelated
    subsystems (e.g. pii_scrubber, review_service, bias_detector). I
    confirmed my change introduces zero new failures: same pre-existing set
    before and after, plus one new passing test. Happy to scope broader cleanup
    into a separate PR if desired.
  • Out of scope: concurrent reviews on the same profile_id (last-write-wins).
    This PR targets the sequential re-review case described in the issue.

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.

Agent session state is not cleared between reviews for the same user

1 participant