Skip to content

[Agent Profile] The default profile and named profiles build different agents — collapse launch into one pipeline #5141

Closed as not planned

Description

@simonrosenberg

Is there an existing feature request for this?

  • I have searched existing issues and feature requests, and this is not a duplicate.

This is the root cause behind a series of already-fixed issues, each of which fixed one field on one path: #3967, #4014, #4016, #4542. It is also the root cause of open issues #4533, OpenHands/OpenHands#16205 and OpenHands/OpenHands#16951. #4958 (tool catalog and resolved tools) depends on it.

Problem or Use Case

Launching the default Agent Profile and launching a named Agent Profile build different agents from the same stored settings. The launch has several code paths, and each one sets agent fields in its own way. Every profile field has to be implemented, and kept correct, once per path.

Live evidence

Setup: agent-server 1.49.1 built from main (365ceb3), Agent Canvas main (07590fd), and the e2e mock LLM, which records every completion request.

I saved two profiles with identical contents, one named default and one named default-copy, and launched each from the canvas home page:

  • Canvas sends default through the agent_settings path.
  • Canvas sends default-copy through the agent_profile_id path.
Field set on the profile default (agent_settings path) default-copy (agent_profile_id path)
tools: [terminal, glob] ignored: terminal, file_editor, task_tracker, browser_tool_set applied
system_message_suffix ignored applied
mcp_server_refs: [] ignored: the fetch MCP server is still attached applied
disabled_skills, enable_switch_llm_tool: false, tool_concurrency_limit: 3, condenser disabled all ignored all applied
Skills in the system prompt, with nothing customised 16 (canvas's bundled set) 68 (server discovery)
"The current date and time is" 11:54:29, when settings were last saved, for a launch at 12:10 12:10
Setting secret_refs moves default onto the agent_profile_id path applied

The model sees a different agent depending on the profile's name. Profile edits made to default do nothing on the most common launch, the home page.

Why

1. Two definitions of the default agent.

  • Global agent_settings is written by the settings pages and by LLM-profile activation.
  • The default Agent Profile is copied from it once (build_seed_profile). After that it is written by the profile editor, and onboarding overwrites it with {agent_kind, llm_profile_ref}.
  • Agent-profile activation only moves the active-profile pointer (agent_settings_applied is always False).
  • Nothing keeps the two in sync.

2. Three request inputs that do different amounts of work. StartConversationRequest accepts agent, agent_settings or agent_profile_id.

3. A second copy of the server pipeline. The Docker runtime's prepare_start repeats the profile branch (resolution, secret filtering, the load_memory stamp) and can drift from conversation_service.

4. Clients pick the path, and rebuild the agent themselves on the agent_settings path.

Agent Canvas chooses the path in use-create-conversation.ts with these rules:

  • The profile is named default.
  • The profile's LLM reference is missing, or the LLM list fails to load.
  • The active LLM differs from the profile's pinned LLM.
  • A veto when secret_refs is set.

The same rule is copied in use-llm-configured.ts, and the copies already disagree (OpenHands/OpenHands#16951).

Launches that ignore the profile entirely:

  • /new
  • locally launched child conversations
  • the local planner, which sends a hand-built agent

On the agent_settings path, canvas assembles the agent itself: buildConfiguredOpenHandsAgentSettings, getAgentTools, buildBundledSkills/buildAgentContext. It uses:

  • the account-wide active LLM instead of llm_profile_ref;
  • a bundled skill catalog filtered by a global allow-list, instead of server discovery minus disabled_skills;
  • a <RUNTIME_SERVICES> block that replaces the stored suffix;
  • its own tool list, gated by a Vite flag;
  • global condenser, verification (including critic_api_key), sub-agents, switch-LLM and concurrency settings;
  • the whole MCP config, unfiltered;
  • secrets with no scoping;
  • no acp_startup_timeout for ACP.

Canvas never sends agent_launch_additions, the field that was added to carry <RUNTIME_SERVICES> on the profile path (#4029).

5. Cloud has its own version of the problem. The cloud app server resolves the profile itself and sends a fully built agent, so the agent-server's profile path never runs there. It then:

  • overwrites several fields the profile carries (tools, system_message_suffix, the switch-LLM off-switch);
  • always adds its platform MCP server;
  • launches without the profile when resolution fails, with nothing surfaced to the user;
  • launches sub-conversations without the parent's profile.

Cost

Every new profile field (tools, secret_refs, prompt templates in #4956, tool metadata in #4958) has to be implemented once per path, and each path is a new place for a silent mismatch. The issues listed at the top are that cost already paid. For a scoped agent it is also a correctness problem: a restriction on the profile only holds on the launch paths that honour it.

Desired Behavior

One launch pipeline. Every conversation start goes through the same resolution: default or named profile, home page or /new, child conversation, automation, local or Docker runtime, cloud. The only inputs that vary are which profile and an explicit, additive set of launch-time additions.

  1. The Agent Profile is the only definition of an agent.
    • default is an ordinary profile: no name-based rules anywhere.
    • Global settings keep only the shared pieces profiles refer to: LLM profiles, the MCP server list, secrets, the skill catalog and marketplaces.
    • Behaviour settings (condenser, verification, memory, sub-agents, switch-LLM, concurrency, tools, instructions, skill enablement) live on the profile. Settings pages that edit them edit the active profile.
  2. One SDK function builds the launch. Something like prepare_agent_launch(profile, *, stores, mcp_catalog, skill_catalog, runtime, additions) -> LaunchPlan(agent, launched_profile, allowed_secrets, resolved_view).
    • It owns every field:
      • LLM and streaming
      • MCP filtering
      • skill catalog minus disabled_skills
      • project-skill loading
      • suffix plus additions
      • current_datetime (always computed at launch)
      • load_memory
      • tool defaults and runtime-dependent injections
      • sub-agents, switch-LLM, concurrency, condenser, verification
      • secret scope
      • ACP fields and ACP skill sourcing
    • Callers:
      • conversation_service
      • Docker mediation (its duplicate branch is deleted)
      • materialize, as a side-effect-free call of the same function, so diagnostics can never disagree with the launch
      • the cloud app server
    • Runtime-dependent decisions (e.g. whether browser is available) come in as an explicit runtime input, so a caller that is not the runtime can pass the runtime's answer.
  3. One request shape for product clients.
    • agent_profile_id (a stored profile), or agent_profile (an inline draft of the same model, resolved by the same function; this also covers draft materialize for [Agent Profile] Clients can't ask what tools an agent will get, or which tools are pickable #4958).
    • agent_settings is deprecated. During the deprecation window the server converts it into an inline profile, so it takes the same pipeline instead of a validator shortcut.
    • Raw agent stays as the explicit low-level option for SDK users building agents in code.
  4. Launch-time variation is explicit and additive, and applied the same way on every path. agent_launch_additions carries:
    • the runtime-services suffix append (already exists);
    • a per-launch llm_profile_ref override for the chat LLM picker, recorded in LaunchedAgentProfile.
    • client_tools stays as it is.
    • Additions can never widen a profile's scope.
  5. Failures are explicit. A dangling LLM or MCP reference fails the launch with a structured error that clients can turn into a fix-it prompt (materialize reports it first). No client or server silently switches to a different path or to an unscoped agent.
  6. Derived launches keep their profile. Child conversations, /new and sub-conversations launch with the parent's launched profile unless a different one is chosen explicitly.

Status (2026-09-28)

The SDK steps (1-3 below) are implemented in PR #5154, pending review. Delivered
there: one prepare_agent_launch behind conversation_service, the Docker runtime and
materialize; the materialize-equals-launch test; current_datetime computed at launch
on every path; agent_settings deprecated (1.50.0 -> 1.55.0) and converted into an
inline profile so it takes the same pipeline; inline agent_profile; a per-launch
llm_profile_ref recorded in LaunchedAgentProfile; and one structured 422 for a
dangling LLM, MCP or meta-profile reference. The Docker runtime now resolves with the
container's answers (browser availability, managed skills) rather than the host's.

Still open: the cross-repo e2e (the table above is currently reproduced by a same-repo
script against a live agent-server, not by a canvas test), the canvas follow-up, the
cloud follow-up, and the one-time default-profile refresh - deliberately deferred to
the canvas step, because refreshing it before the settings pages edit the active profile
just lets it drift again.

The cost is still being paid. #4287 (merged 2026-09-24) added
enable_classify_and_switch_llm_tool, active_meta_profile, meta_profile and
meta_profile_llms to OpenHandsAgentSettings and not to OpenHandsAgentProfile, so
route_task_to_model reached an agent_settings launch and silently did not reach a
profile launch - the same divergence as the table above, three weeks later. #5154 wires
it through the profile (enable_classify_and_switch_llm_tool + meta_profile_ref) and
hydrates the meta-profile and its LLMs at launch, so a runtime with no meta-profile
store on disk (a conversation container, a cloud sandbox) can still route.

Acceptance Criteria

  • A single SDK function builds the agent for every launch. conversation_service, Docker mediation and materialize all call it, and no other code in the agent-server builds a launch agent from a profile.
  • materialize and a real launch produce the same resolved agent for the same profile. A test compares them field by field: tools, MCP keys, skills, suffix, LLM, condenser, verification, sub-agents, switch-LLM, concurrency, secret scope.
  • Two profiles with identical contents and different names (one of them default) produce identical agents, apart from launch timestamps and ids, on every product launch path. A cross-repo e2e test reproduces the table above and asserts every row matches.
  • current_datetime in the system prompt is computed at launch on every path.
  • agent_settings on StartConversationRequest is deprecated (via the deprecation helper). While it is still accepted, it goes through the same pipeline via inline-profile conversion.
  • StartConversationRequest accepts an inline agent_profile draft, resolved by the same function.
  • AgentLaunchAdditions supports a per-launch llm_profile_ref override, recorded in LaunchedAgentProfile; additions cannot widen scope.
  • A dangling LLM or MCP reference returns a structured error from the start endpoint, with no silent fallback.
  • Follow-up in OpenHands/OpenHands: canvas always launches with a profile (active, explicit, or the parent's for children and /new). It deletes the default name rule, the LLM-mismatch and dangling-ref fallbacks, the use-llm-configured copy, and client-side agent assembly (buildConfigured*AgentSettings, getAgentTools, bundled-skill launch injection). It sends <RUNTIME_SERVICES> via agent_launch_additions.
  • Follow-up for cloud: resolve through the same SDK function, stop overwriting fields the profile carries, and surface resolution failures instead of launching without the profile.
  • One-time migration: the default profile is refreshed from current global agent_settings (what default launches actually ran), and the settings pages edit the active profile from then on.

Alternatives Considered

Priority / Severity

High - Significant impact on productivity

Estimated Scope

Large - Significant feature requiring architecture changes

Feature Area

  • Agent API / Core functionality
  • Tools / Tool system
  • Skills / Plugins
  • Agent Server
  • Workspace management
  • Configuration / Settings
  • Examples / Templates
  • Documentation
  • Testing / Development tools
  • Performance / Optimization
  • Integrations (GitHub, APIs, etc.)
  • Other

Technical Implementation Ideas (Optional)

Suggested order, each step shippable on its own:

  1. SDK: extract the pipeline.
    • Move everything in _resolve_agent_from_profile and the profile branch of _start_conversation, plus the Docker mediation copy, into one SDK function that takes explicit stores, catalogs and runtime inputs.
    • Make resolve_agent_profile_dry_run call it with side effects off.
    • Keep the current request shapes.
  2. SDK: inline profiles and deprecation.
    • Add agent_profile to StartConversationRequest.
    • Convert agent_settings into an inline profile and deprecate it.
    • Move the agent_settings → agent conversion out of the Pydantic validator and into the server pipeline.
  3. SDK: launch additions. Add the llm_profile_ref override. Return structured errors for dangling references.
  4. Canvas. Send a profile on every launch path, delete the routing rules and client-side agent assembly, move the behaviour settings pages onto the active profile, and migrate the global skill toggles into the profile's disabled_skills.
  5. Cloud. Adopt the SDK function and remove the field overwrites.

Decisions to settle before step 4:

  • Skill model. Canvas has a global allow-list (enabled_skills); the SDK profile has a deny-list (disabled_skills). Proposal: keep the per-profile deny-list and migrate the global toggles into it.
  • Chat LLM picker. Per-launch override (proposed) or an edit to the profile.
  • Tools that ignore profile scope. The cloud platform MCP server and plugin-provided MCP servers are currently added outside mcp_server_refs. They need an explicit policy inside the function: exempt from profile scoping, or subject to it.
  • Cloud fallback policy. Cloud currently launches without the profile when resolution fails so that no launch is ever blocked. Keep that with a visible warning, or fail the launch.

Additional Context

Related:

Activity

  1. added
    enhancement
    architecture
    on Sep 17, 2026
  2. added
    ready-for-dev
    on Sep 17, 2026
  3. github-actions commented on Sep 17, 2026

    @github-actions
    Contributor

    ✅ ready-for-dev label applied

    This issue meets the readiness criteria and is ready for contribution.
    A contributor can now open a PR that links this issue (Fixes #<number>).

    This is an automated check — no AI was used to generate this comment.

  4. gregnetau commented on Sep 21, 2026

    @gregnetau

    Another launch path with the same shape, with measurements — the automation preset runner, which the proposed one-pipeline fix lists ("home page or /new, child conversation, automation, …") but which isn't in the evidence table yet.

    Setup: agent-canvas v1.20.0, openhands-sdk 1.49.1, openhands-automation 1.13.1, self-hosted, local model behind LiteLLM.

    The path is profile-blind, not just partly wrong. Both presets build the agent client-side and never read the profile at all:

    $ grep -c AUTOMATION_AGENT_PROFILE_ID presets/prompt/sdk_main.py   → 0
    $ grep -c AUTOMATION_AGENT_PROFILE_ID presets/plugin/sdk_main.py   → 0
    $ grep -c AUTOMATION_AGENT_PROFILE_ID <github-pr-reviewer template> → 3
    

    The preset runners call get_default_agent(llm, cli_mode=True, finish_tool_response_schema=...) and then model_copy only mcp_config and agent_context. The template automations instead create the conversation server-side with agent_profile_id, so they get the profile path and its "condenser": profile.condenser.

    Worth flagging separately: the automation API accepts and stores agent_profile_id on a preset automation, and the runner never reads it. PATCH /v1/automations/{id} with an agent_profile_id returns 200 with the field set, and it has no effect. That's harder to spot than an ignored field — the config looks applied.

    Resulting condenser divergence, same settings, same machine:

    conversation path condenser
    UI / template automation agent_profile_id max_size=240, keep_first=2 ✓
    prompt-preset automation client-side get_default_agent max_size=80, keep_first=4 ✗

    240/2 is the LLMSummarizingCondenser field default and what settings.json holds; 80/4 comes from _DEFAULT_MAX_SIZE / _DEFAULT_KEEP_FIRST in default_condenser().

    Measured cost on a self-hosted model, from base_state.json usage buckets:

    conversation events condensations condenser LLM time share of all LLM time
    A 589 13 17.9 min 20.2 %
    B 368 3 5.8 min 8.3 %
    short runs (~20 events) 17–26 0 0 0 %

    The firing rate is correct for the size given — it triggers at len(view) > max_size and rewinds to max_size // 2, so at 80 it re-fires every ~40 events; 589/40 ≈ 14 vs 13 observed. At 240 the same run would condense ~5 times.

    Each condensation generates a ~3,900-token summary, which costs ~82s at ~50 tok/s locally, and rewrites the history prefix — discarding a prefix cache that otherwise runs at a 93.5 % hit rate. The 80/4 default is reasonable where a summarisation round-trip is a couple of seconds; on self-hosted hardware the cost assumption behind it doesn't hold, which is why this surfaces as a fifth of runtime here and would be near-invisible on a hosted setup.

    There's no configuration route out on this path: get_default_agent() takes no condenser argument, the SDK reads no env var for condenser sizing, and the automation create/update schema exposes only name/prompt/model/trigger/timeout/template/enabled (plus the inert agent_profile_id).

    I have had claude patch this locally for me until it's fixed here.

  5. added a commit that references this issue on Sep 28, 2026
    06c9de5
  6. simonrosenberg commented on Sep 30, 2026

    @simonrosenberg
    MemberAuthor

    Superseded by #5398.

    The problem, the live evidence table and the product goals in this issue still hold, and #5398 carries them over. #5398 replaces the design.

    This issue asked for one SDK function that builds every launch, with agent_settings converted into an inline profile. PR #5154 built that, and review showed the approach can't hold:

    • Converting agent_settings loses data. It is already a fully resolved settings object, so turning it into a profile drops fields. They then have to be patched back in.
    • One function can't serve Docker or cloud. It has to run in a single process. For those runtimes it either resolves with the host's runtime facts or has to query the container for them.
    • Nothing stops the next bypass. Nothing fails when a new path or field goes around the function. The OpenAI gateway already does, and so did the Add Pareto prompt meta-profile routing #4287 meta-profile fields, three weeks after this issue was filed.

    #5398 splits the launch into two stages:

    • resolve runs where the stores live and returns settings with no references left.
    • finalize runs in the process that runs the agent.

    Three checks enforce the split: a typed value into _start_event_service, an architecture test, and a field-ownership test. Details are in #5398 and in the closing comment on #5154.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureenhancementready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions