feat: Configurable default agent for through the librechat.yaml config file #9953
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add default_agent Configuration for Agents Endpoint
Summary
Implements a new
default_agent
configuration option inendpoints.agents
that allows administrators to specify a default agent for user sessions. When configured, users are automatically directed to this agent when they log into the platform.Context: This feature streamlines the user experience by allowing organizations to set a preferred default agent, ensuring users start with a specific agent on login without manual selection.
Change Type
Changes Overview
Backend Changes
Configuration Schema (
packages/data-provider/src/config.ts
)default_agent: z.string().optional()
toagentsEndpointSchema
defaultAgent?: string | null
toTStartupConfig
typeAPI Service (
api/server/routes/config.js
)defaultAgent
in startup config endpoint:config?.endpoints?.agents?.default_agent ?? null
/api/config
endpointTests (
api/server/services/AppService.spec.js
)default_agent
is correctly read fromendpoints.agents
configurationdefault_agent
is omittedFrontend Changes
Default Endpoint Logic (
client/src/utils/getDefaultEndpoint.ts
)default_agent
configurationstartupConfig.defaultAgent
exists AND agents endpoint is configured, returns agents endpointgetDefaultAgentFromConfig()
: Extracts agent ID when on agents endpointSession Initialization (
client/src/hooks/useNewConvo.ts
)getDefaultAgentFromConfig()
to automatically setconversation.agent_id
on loginisAgentsEndpoint(defaultEndpoint)
is trueUtility Exports (
client/src/utils/index.ts
)getDefaultAgentFromConfig
for use across applicationTests
Comprehensive Test Suite (
client/src/utils/getDefaultEndpoint.spec.ts
)253 lines of test coverage including:
getDefaultEndpoint
tests:defaultAgent
is configureddefaultAgent
over other endpointsdefaultAgent
even with localStorage set to different endpointdefaultAgent
even with convoSetup set to different endpointstartupConfig
default_agent
(convoSetup, localStorage, first endpoint)getDefaultAgentFromConfig
tests:defaultAgent
defaultAgent
not configuredstartupConfig
is undefinedConfiguration & Documentation
Configuration Example (
librechat.example.yaml
)1.2.1
→1.2.2
default_agent
option in agents sectionTesting
Unit Tests
AppService.spec.js
- default_agent reading and handlinggetDefaultEndpoint.spec.ts
- complete coverage of priority logicManual Testing
Checklist
librechat.example.yaml
)Additional Notes
Priority Hierarchy:
startupConfig.defaultAgent
(highest priority when agents endpoint exists)convoSetup.endpoint
(unchanged)localStorage.lastConversationSetup
(unchanged)Requirements:
endpointsConfig
default_agent
is optional - system works normally without it