[Bug]: Saved agent_context.system_message_suffix is dropped when runtime services are advertised
Operating System
Linux
Installation Method
Docker (ghcr.io/openhands/agent-canvas)
Agent Canvas Version
ghcr.io/openhands/agent-canvas:1.23.0 (build b0906809b3e8777491519c386d55ce32d7f4daa4); the code is unchanged on main
Bug Description
A global system-prompt suffix saved in the agent settings (agent_settings.agent_context.system_message_suffix) never reaches conversations started from the Canvas UI. buildAgentContext in src/api/agent-server-adapter.ts spreads the existing agent context and then replaces system_message_suffix with the <RUNTIME_SERVICES> block whenever runtime services are advertised:
return {
...existingContext,
// ...
...(runtimeServicesSuffix
? { system_message_suffix: runtimeServicesSuffix }
: {}),
};The Docker image and npx always advertise runtime services, so every inline-launched conversation loses the saved suffix. The plan-agent path in the same file already preserves an existing suffix and prepends its own instruction; the normal agent path does not. user_message_suffix from the same settings is kept, which makes the loss easy to miss.
This is separate from #17279, which carries the runtime-services block onto the agent-profile launch path through agent_launch_additions; the inline path's overwrite stays.
Steps to Reproduce
Run method: Docker image ghcr.io/openhands/agent-canvas:1.23.0 (observed there; the same code path exists on main, not yet run via npm run dev)
- Save a global suffix:
PATCH /api/settingswith{"agent_settings_diff": {"agent_context": {"system_message_suffix": "MARKER-GLOBAL-RULES"}}}. - Confirm it is stored:
GET /api/settings→agent_settings.agent_context.system_message_suffixisMARKER-GLOBAL-RULES. - Start a new conversation from the Canvas home screen (no agent profile selected).
GET /api/conversations/{id}and readagent.agent_context.system_message_suffix, or open the conversation'sSystemPromptEvent.
Actual Behavior
The conversation's agent.agent_context.system_message_suffix contains only the <RUNTIME_SERVICES> … </RUNTIME_SERVICES> block (1022 characters on our deployment). MARKER-GLOBAL-RULES appears nowhere in the SystemPromptEvent. The same conversation's user_message_suffix from settings is present and applied to every user message.
Expected Behavior
The saved suffix and the runtime-services block both reach the agent, joined with a blank line, the way the plan-agent path already combines its instruction with an existing suffix. With no saved suffix the result is unchanged (runtime-services block only); with no runtime services the saved suffix passes through as today.
Relevant Logs
# settings
agent_settings.agent_context.system_message_suffix -> "# Rules for every conversation ..." (2652 chars)
# conversation started from the UI afterwards
agent.agent_context.system_message_suffix -> "<RUNTIME_SERVICES>\nYou are running inside an agent-canvas dev stack started in 'docker' mode. ..." (1022 chars)
agent.agent_context.user_message_suffix -> "Reminder: ..." (from settings, kept)Acceptance Criteria
- A conversation launched inline (no agent profile) receives
system_message_suffix= saved suffix +\n\n+<RUNTIME_SERVICES>block when both exist. - With only one of the two present, exactly that one is sent; with neither, the field is omitted as today.
- The plan-agent path still puts its instruction first and keeps everything after it.
- Unit tests in
__tests__/api/agent-server-adapter.test.tscover the three cases.
Screenshots
No response
Additional Context
Self-hosted single-tenant Canvas on Kubernetes. Global instructions are applied through PATCH /api/settings; users see only the per-turn user_message_suffix taking effect. I have a patch with tests ready and will open a PR referencing this issue.
Source: OpenHands/OpenHands