Skip to content

fix(retrieval): release agent session before episode wait - #400

Merged
suguanYang merged 1 commit into
mainfrom
fix/wangbinqi/retrieval-agent-session-lifetime
Sep 9, 2026
Merged

fix(retrieval): release agent session before episode wait#400
suguanYang merged 1 commit into
mainfrom
fix/wangbinqi/retrieval-agent-session-lifetime

Conversation

@suguanYang

Copy link
Copy Markdown
Contributor

Summary

Closes #399. Prevent agentic retrieval from reusing a request-scoped SQLAlchemy session after a long external agent/LLM episode.

  • Roll back the route session before run_episode.
  • Use one fresh session for finish-reference resolution, hydration, assembly, and trace persistence.
  • Add contract coverage for the long-wait session boundary and isolation parameters.
  • No database timeout change or generic SQL retry.

Verification

  • uv run pytest apps/api/tests/contract/test_retrieval_contract.py -q — 15 passed
  • uv run pytest packages/shared-python/shared/tests/test_agent_explore_harness.py -q — 17 passed
  • Ruff — passed
  • Pyright — passed
  • Full repository suite is currently blocked during collection by pre-existing worker import-path errors.

@suguanYang
suguanYang merged commit 066c1dc into main Sep 9, 2026
6 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.

Fix retrieval 500 caused by idle-in-transaction connection termination

1 participant