Repository navigation
Description
Environment
- Astra
mainat844473c68 - Astra CLI
0.1.0 - Memoria enabled and healthy
- Authenticated request path:
POST /chat/turn - macOS ARM64 host
Actual behavior
The in-process /chat/turn bridge fails to retrieve the current session-memory snapshot from Memoria.
A fresh one-shot session completed successfully, but the server immediately emitted:
session_memory typed retrieval failed
session_id=58939d9a-8e58-47c1-bfe5-ac684d58d671
error="typed Memoria retrieve requires an authenticated owner binding"
The failure occurs before an HTTP retrieval request is sent to Memoria. As a result, an existing same-session snapshot cannot be loaded or injected into the context pipeline.
This is not an expired access token or an empty retrieval result: /chat/turn authenticates successfully, the model turn completes, and the bridge receives the authenticated user ID through x-mo-user-id.
Expected behavior
InProcessChatTurnBridge should bind a request-scoped clone of the Memoria client to the authenticated user_id before any strict session-scoped operation.
- An existing snapshot for the authenticated user and session is loaded and injected.
- A missing snapshot returns an empty result without an owner-binding warning.
- User isolation remains fail-closed.
- The shared bridge client is not permanently bound to any single user.
Steps to reproduce
-
Configure Astra with a healthy Memoria endpoint and master key.
-
Start
astra-server. -
Authenticate with the Astra CLI.
-
Send a fresh one-shot request through
/chat/turn, for example:astra --api-url http://127.0.0.1:17001 chat \ --message 'Reply with exactly OK.' \ --no-resume \ --model <model-id> \ --auto-approve \ --json
-
Confirm that the turn completes successfully.
-
Inspect
api_server.logfor the new session.
Observed on 2026-07-29:
POST /chat/turn status=200
session_memory typed retrieval failed
error="typed Memoria retrieve requires an authenticated owner binding"
Suspected root cause
InProcessChatTurnBridge::new creates an unbound client:
memoria_client: HttpMemoriaPort::from_env(),forward() later receives the trusted authenticated owner:
let user_id = required_bridge_header(headers, "x-mo-user-id")?;However, resolve_bridge_memory_provider() returns either the server-configured client or a request-binding client without binding it to that owner. The bridge then calls:
load_current_session_memory_preferring_local_with_freshness(
memoria,
&session_id,
)This reaches HttpMemoriaPort::retrieve_scoped_typed(), which correctly fails closed because owner_user_id is absent:
let user_id = self.owner_user_id.as_deref().ok_or_else(|| {
"typed Memoria retrieve requires an authenticated owner binding".to_string()
})?;The lifecycle-based ServerAgenticLoopHostBuilder already calls with_owner_user_id(...), so behavior is inconsistent between the lifecycle host and the in-process /chat/turn bridge.
Suggested fix
Bind a cloned client after resolving the provider, or make resolve_bridge_memory_provider() accept the authenticated owner and return an owner-bound client:
let memoria_client_for_turn = memoria_client_for_turn
.map(|client| client.with_owner_user_id(user_id.clone()));The binding must be request-scoped because the bridge instance is shared across users. The same rule should cover both server-configured and request-binding clients.
Acceptance criteria
- Same-session snapshot retrieval sends the authenticated
user_idand trustedsession_idto Memoria. - A missing snapshot returns cleanly without the owner-binding warning.
- Server-configured and request-binding clients are both scoped.
- Concurrent users cannot cross memory ownership boundaries.
- Existing fail-closed behavior for genuinely unbound strict retrieval remains intact.
Scope note
Cross-session prompt recall is a separate path that explicitly passes user_id to retrieve_for_prompt(). This issue concerns strict same-session snapshot retrieval and other owner-bound session operations on the in-process bridge.
Activity
XuPeng-SH commentedon Oct 20, 2026
The legacy in-process
/chat/turnbridge described here is no longer a supported route in the current runtime, so this exact reproduction path has been removed. The current Memoria owner-binding checks remain fail-closed; no compatibility bridge should be kept for the retired route. Please reopen with the exact current supported endpoint if the same owner-binding failure occurs there.