[Bug]: GET /agents/connections/me?agent_session_name=… returns 404 for a deactivated (inactive) connection
Bug Description
GET /api/v1/agents/connections/me?agent_session_name=<name> returns 404 {"detail":"connection not found"} for a connection that exists, as soon as that connection has been deactivated by POST /api/v1/agents/unregister. GET /api/v1/agents/connections?active_only=false still lists it (status inactive).
Cause: get_agent_connection_detail() (cognee/modules/agents/operations.py) calls list_agent_connections() with the default active_only=True, then filters by agent_session_name. Deactivated connections are dropped before the name filter runs, so a lookup by name can never find them. The unnamed /connections/me works only because it returns whichever active connection sorts first — a different session's, on a busy machine.
The Claude Code plugin (cognee-memory 1.4.3) polls this exact URL for its own connection on every hook; once its connection is deactivated it logs runtime_state_connection_lookup_failed: HTTP Error 404 on every hook (~1,700/day here).
Steps to Reproduce
POST /api/v1/agents/registerwith{"agent_session_name": "conn_x", "type": "api"}→ 201.GET /api/v1/agents/connections/me?agent_session_name=conn_x→ 200 (statusactive).POST /api/v1/agents/unregisterwith{"agent_session_name": "conn_x"}→ 200.GET /api/v1/agents/connections/me?agent_session_name=conn_x→ 404.GET /api/v1/agents/connections?active_only=false→conn_xpresent,status: inactive.
Expected Behavior
Step 4 returns the connection with status: inactive. A lookup by name identifies one specific connection; its activity status is part of the answer, not a filter.
Actual Behavior
404 {"detail":"connection not found"}.
Environment
- OS: Unraid 7.3.2 (Docker), client Windows 11
- Python version: 3.12 (image)
- Cognee version: 1.5.3 (
cognee/cogneeimage built 2026-09-01),REQUIRE_AUTHENTICATION=true,ENABLE_BACKEND_ACCESS_CONTROL=false - LLM Provider: OpenAI
Additional Context
Fix + regression test in #4907.
Source: topoteretes/cognee