Skip to content

feat: implement session agent selection#37

Open
yuhp wants to merge 1 commit intoibelick:mainfrom
yuhp:feature/agent-selection
Open

feat: implement session agent selection#37
yuhp wants to merge 1 commit intoibelick:mainfrom
yuhp:feature/agent-selection

Conversation

@yuhp
Copy link
Contributor

@yuhp yuhp commented Feb 24, 2026

Motivation

To support multi-agent interactions within WebClaw. Users need the ability to choose which specialized agent they want to converse with when starting a new session, and to clearly see which agent they are interacting with in historical sessions.

Description

This PR introduces the Session Agent Selection feature, allowing users to select a specific AI Agent for their chat sessions. It dynamically fetches available agents from the backend and displays the selected agent within the chat interface.

Changes Made

  • API Enhancements:
    • Added a new /api/agents endpoint (apps/webclaw/src/routes/api/agents.ts) that fetches the list of available agents via gatewayRpc('agents.list', {}).
    • Updated the /api/sessions.ts endpoint to accept an agentId in the POST body. The agentId is now encoded directly into the session key (agent:<agentId>:<uuid>) instead of being passed as a separate parameter to the Gateway.
  • Frontend Updates:
    • Queries: Added fetchAgents to chat-queries.ts to retrieve the agent list and handle fallback naming (using id if name is empty).
    • State & UI: Updated chat-screen.tsx to manage the selectedAgentId state and apply default agent settings. Added a query to fetch the available agents for new chats.
    • Header Selection: Modified chat-header.tsx to display an agent <select> dropdown for new, empty chats. Once a session is established, the dropdown is replaced with a static label (e.g., "Agent: product_manager") displaying the agent associated with that specific session.
    • Utils: Created a deriveAgentIdFromKey utility function in utils.ts to correctly parse the agentId from the modified session key format.

Testing

  • Verified that the /api/agents endpoint correctly returns the agent list.
  • Confirmed that new chats allow agent selection via the dropdown in the header.
  • Ensured that the selected agentId is correctly sent in the session creation payload and encoded into the session key.
  • Verified that existing sessions correctly parse their key and display the correct static agent name in the header.

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.

1 participant