feat: include endpoints to interact with specific agent sessions#943
feat: include endpoints to interact with specific agent sessions#943miguelangarano wants to merge 6 commits into
Conversation
jaberjaber23
left a comment
There was a problem hiding this comment.
LGTM. Needed feature — session-targeted messaging enables multiplexing independent conversations. Good refactoring (extracts format_session_messages), proper input validation (64KB size limit, UUID parsing), WebSocket session_id routing, and comprehensive integration test. Please rebase on main.
|
This PR has merge conflicts. Please rebase onto the latest main branch and resolve conflicts so we can merge. |
|
Thanks @miguelangarano — endpoints to interact with specific agent sessions are useful, especially for integrations. Branch is Before re-review:
Good feature; just needs the auth story buttoned up. Happy to re-review once rebased. |
|
Re-reviewing on current head. Code is largely good but needs changes before merge. Blocker: IDOR on session endpoints.
Required fix: gate every session route through an ownership check that the session belongs to the authenticated user (or to the agent's owner under RBAC). Reuse the auth pattern from Other items:
Once IDOR is closed and the diff is trimmed, this is mergeable. |
Summary
This PR introduces the ability to interact with and retrieve specific agent sessions directly, bypassing the agent's default active session. This enables clients to multiplex multiple independent conversations with the same agent simultaneously over HTTP or a single WebSocket connection, while keeping the context and memory of each session strictly isolated.
Changes
GET /api/sessions/{id}to fetch the conversation history of any specific session.POST /api/agents/{id}/sessions/{session_id}/messageto send a synchronous message to a specific session.POST /api/agents/{id}/sessions/{session_id}/message/streamfor SSE streaming to a specific session.send_message_with_handle_and_blocksandsend_message_streamingto accept an optionaltarget_session_id.execute_llm_agentto use the target session if provided, otherwise falling back to the agent's active session.session_idto route messages.session_idas a mandatory field in all outgoing WS events (typing,text_delta,response,error, etc.) to allow clients to reliably filter and route incoming streams. If the client doesn't provide one, it resolves and returns the agent's active session ID.test_specific_session_messaginginapi_integration_test.rsto verify session isolation, message routing, and specific session retrieval.Testing
cargo clippy --workspace --all-targets -- -D warningspassescargo test --workspacepassesSecurity