Repository navigation
Proposal: admin-configured instructions added to every agent, including Agent Builder agents #18492
Replies: 1 comment
|
I checked the claims against current
One detail that strengthens the case against today's workaround. In Small implementation note: |
Uh oh!
There was an error while loading. Please reload this page.
Problem
Many deployments use a model spec's
promptPrefixto give every chat a baseline of runtime context:This works for chats started from a model spec. When a user builds their own agent in the Agent Builder, the prefix is dropped. The agent no longer knows the current date or who it's talking to. Users see it as the model "forgetting" the date once they build an agent with it.
The cause, as of v0.8.9:
loadEphemeralAgent(packages/api/src/agents/load.ts) maps the spec'spromptPrefixto the ephemeral agent'sinstructions.loadAgentreturns persisted agents unchanged. Their system prompt is their owninstructionsplus feature-driven additions (memory, artifacts, project context).librechat.yamlsetting lets an admin add instructions to persisted agents.Today's workaround is to ask every agent author to paste the date/user line into their instructions. It works, because special variables are resolved in agent instructions, but it doesn't scale. Authors forget, and admins can't change it centrally.
Related issues: #9431 and #17321. #17321 asks for an overridable instance-wide default that applies only where nothing more specific is configured, and explicitly excludes combining the two. This proposal is the complement. Runtime context should be added to every agent's own instructions, because agents with detailed custom instructions are exactly the ones that still need the date and the user's name.
This also overlaps with the prompt-cache work in #17481 / #16369 (
endpoints.agents.promptCache.stableContext), which changes how{{current_datetime}}is resolved. The new setting should go through the same special-variable resolution, so it follows whatever that work settles on (turn time today, conversation start plus a date-change event withstableContext). It shouldn't add a second, independent timestamp to the system prompt.Proposal
An optional key on the agents endpoint config:
(The name is open to discussion:
globalInstructions,additionalInstructions,runtimeContext, ...)Behaviour
replaceSpecialVars(user, turn start time, request timezone). It is then appended throughappendAdditionalInstructions.additional_instructions, notinstructions. This is the pathinitializeAgentalready uses for instructions containing temporal variables, so the stable instruction prefix is unaffected (📌 fix: Stabilize Agent Prompt Cache Prefix #12907). WithstableContexton, it resolves against the conversation start like agent instructions do, so it doesn't break the cache on every turn.Scope and implementation
packages/data-provider/src/config.ts: one optional string field on the agents endpoint schema.packages/api/src/agents/initialize.ts: about ten lines next to the existing instructions block, reusingreplaceSpecialVarsandappendAdditionalInstructions.librechat.example.yaml: a commented example.packages/api/src/agents/__tests__/initialize.test.tscovering: unset (no change); set with a persisted agent that has instructions (both present, own instructions untouched); set with an agent that has no instructions; special variables resolved with the request timezone; the result landing inadditional_instructions.Out of scope
promptPrefixis applied to ephemeral agents. Deployments that set both would get the context twice in model-spec chats, so the docs should suggest moving it frompromptPrefixto the new key.I'm happy to implement this and open a PR against
devif the approach looks right.All reactions