Skip to content

feat(sdk): express meta-profile routing on Agent Profiles - #5408

Merged
simonrosenberg merged 3 commits into
agent-launch-resolve-finalizefrom
agent-launch-meta-profile-routing
Sep 30, 2026
Merged

simonrosenberg merged 3 commits into
agent-launch-resolve-finalizefrom
agent-launch-meta-profile-routing

Conversation

@simonrosenberg

@simonrosenberg simonrosenberg commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

Meta-profile routing on Agent Profiles, split out of #5406 at my request (part of #5398). The agent verified it end to end in the Docker runtime, paired with #5406. Evidence is in .pr/meta_profile_routing_e2e.md.


AGENT:

Why

The #4287 meta-profile routing fields never reached Agent Profiles. Routing therefore works on an agent_settings launch and silently does not on a profile launch. In the Docker runtime it could not work even if a profile named the meta-profile, because the container's HOME has no meta-profile store.

Summary

  • OpenHandsAgentProfile gains enable_classify_and_switch_llm_tool and meta_profile_ref.
  • resolve copies the meta-profile and every LLM it routes to into the settings (meta_profile, meta_profile_llms). A runtime without the stores can then route. Direct routing (a meta-profile with a prompt_template) may pick any saved LLM profile, so every readable one is copied.
  • A missing meta-profile or routed LLM joins the single UnresolvedProfileReferences 422 (dangling_meta_profile_ref, dangling_meta_profile_llm_refs). materialize reports both.
  • The default seed carries the routing settings from the global settings.
  • The field-ownership test now classifies the four routing settings fields as profile-owned. They were the last NotOnProfile gap besides user_message_suffix and registered_marketplaces.

Issue Number

Part of #5398

How to Test

Stacked on #5406, which adds the launch pipeline this extends.

Unit suites on this branch and on #5406:

uv run pytest tests/sdk -n 8            # 6660 passed (#5406: 6656); 1 failed on both (test_truncate)
uv run pytest tests/agent_server -n 8   # 2327 passed; 7 failed on both (canvas_extensions, macOS)
uv run pytest tests/cross tests/workspace -n 8  # 697 passed; the gateway live test hit the macOS
                                                # tmux socket-path limit and passes serially

End to end: python .pr/launch_docker_e2e.py --sdk <checkout> --image <agent-server image> --container-browser yes|no --mock-llm <canvas>/tests/e2e/mock-llm/scripts/mock-llm-server.py. It runs a host in Docker runtime mode, and each container image is built from the same commit. The container's HOME has no stores. The profile names a meta-profile whose classifier and class use two saved LLM profiles.

  • Branch: 14/14 checks pass with and without chromium in the container. The routing tool in the container carries the meta-profile and both LLMs. A profile naming a missing meta-profile fails on the host with one 422 (dangling_meta_profile_ref), and no container starts.
  • On feat(agent-profiles): launch every agent through resolve and finalize #5406 (12/14), a profile with meta_profile_ref cannot be saved (422), so both routing checks fail. The other 12 checks pass on both.
  • Results: .pr/meta_profile_routing_e2e.md.

Video/Screenshots

API-level change.

Design Doc

#5398 ("The #4287 meta-profile fields can be set on a profile through meta_profile_ref", and routing in a Docker runtime with no meta-profile store).

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

  • meta_profile_ref: null with the tool enabled keeps today's behavior: the tool falls back to the first meta-profile in the runtime's own store.
  • A disabled routing tool ignores meta_profile_ref, so a stale reference on a disabled profile does not fail its launch.
  • clients/typescript is not updated. Its hand-written profile models already lag main, so the two profile fields and three diagnostics fields go with that refresh.

🤖 Generated with Claude Code

simonrosenberg and others added 2 commits September 30, 2026 19:38
`OpenHandsAgentProfile` gains `enable_classify_and_switch_llm_tool` and
`meta_profile_ref`. `resolve` copies the meta-profile and every LLM it routes to
into the settings, so a runtime without the stores (a Docker container) can
still route, and a dangling meta-profile or routed LLM joins the one
`UnresolvedProfileReferences`. The `default` seed carries the routing settings.

Co-authored-by: openhands <openhands@all-hands.dev>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   launch.py96595%107, 110–111, 122, 136
openhands-sdk/openhands/sdk/launch
   preview.py393121%32, 35, 41–44, 46, 52–57, 60–66, 68–78
   resolve.py1211885%94, 106, 146–147, 154, 162–163, 166–169, 199, 204–207, 226–227
openhands-sdk/openhands/sdk/profiles
   agent_profile.py110794%336, 347, 350, 417, 423, 428, 456
   resolver.py133398%162, 216, 462
TOTAL46701825182% 

@simonrosenberg
simonrosenberg marked this pull request as ready for review September 30, 2026 18:12

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was posted by an AI agent (OpenHands).

Scope. SDK / Agent Server change (launch resolution plus two Agent Profile fields) — belongs in this repository per the AGENTS.md cross-repository boundaries. The linked epic #5398 is open with ready-for-dev; this is one of its split-out PRs.

Current state (re-read now). Head aa403a63e5a0ac56fe82dce1f29ddfe5d56295a6 matches the requested SHA; the PR is open with no labels, no prior reviews, and no comments from any other account (only the coverage bot). Every check-run on this head is green (sdk-tests, agent-server-tests, cross-tests, workspace-tests, tools-tests, pre-commit, check-docstrings, endpoint-audit, …).

What I verified.

  • resolve now copies the named meta-profile and every LLM it routes to into the resolved settings (meta_profile, meta_profile_llms), so a store-less runtime can still route. A missing meta-profile or routed LLM joins the single UnresolvedProfileReferences 422 as dangling_meta_profile_ref / dangling_meta_profile_llms, and preview_launch surfaces both. The field-ownership table now classifies the four routing settings fields as profile-owned.
  • Routing is only resolved when enable_classify_and_switch_llm_tool is on; a disabled profile with a stale meta_profile_ref still launches (test_a_disabled_routing_tool_ignores_its_meta_profile_ref).
  • Credentials: routed LLMs loaded from the store carry their api_key into meta_profile_llms. I confirmed that an ordinary model_dump(mode="json") of the built agent redacts every key, and that forward_to_runtime encrypts them (no plaintext in the forwarded payload). The only plaintext copies are the existing trusted-backend expose_secrets paths.
  • uv run pytest tests/sdk/launch tests/sdk/profiles tests/sdk/settings -q → 277 passed. The tests/agent_server/test_launch_parity.py launch/forward cases are not runnable in this sandbox (conversation-dir permission), so for that path I relied on the green agent-server-tests check.
  • No distributable package version changed.

Non-blocking observation. In _load_meta_profile, when stores.meta_profiles is None the function reports the name as a dangling reference (return None, {}, name, []). For a LaunchStores that simply does not wire the meta-profile store, the user then sees a Meta-profile 'X' not found 422 rather than a store-not-wired error. The agent-server path always wires the store, so this is not blocking — but a distinct message would be clearer if a future caller omits it.

Assessment. The change is scoped to the launch pipeline and traced through resolve → preview → seed → forward/validate, with unit coverage plus the author's Docker e2e evidence. No material correctness, security, compatibility, or acceptance-criterion defect on this head.

✅ APPROVED

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was posted by an AI agent (OpenHands).

Scope. SDK / Agent Server change (launch resolution plus two Agent Profile fields) — belongs in this repository per the AGENTS.md cross-repository boundaries. The linked epic #5398 is open with ready-for-dev; this is one of its split-out PRs.

Current state (re-read now). Head is c838c5df8889d4b5191e5a9100036167339cd804; the PR is open with no labels, no review comments, and no comments from any other account (only the coverage bot). Every check-run on this head is green (sdk-tests, agent-server-tests, cross-tests, workspace-tests, tools-tests, windows-tests, pre-commit, check-docstrings, endpoint-audit, …).

Delta since my earlier review of aa403a63. The only change is the automated chore: Remove PR-only artifacts commit, which deletes the four .pr/ evidence files. git diff aa403a63 c838c5df -- ':!.pr' is empty, so the reviewed code is byte-for-byte identical; the earlier findings and verdict carry over unchanged.

What the code does, verified on this head.

  • OpenHandsAgentProfile gains enable_classify_and_switch_llm_tool and meta_profile_ref; resolve copies the named meta-profile and every LLM it routes to into the resolved settings (meta_profile, meta_profile_llms) so a store-less runtime can still route. A missing meta-profile or routed LLM joins the single UnresolvedProfileReferences 422 as dangling_meta_profile_ref / dangling_meta_profile_llm_refs, and preview_launch surfaces both. The field-ownership table now classifies the four routing settings fields as profile-owned.
  • Routing is only resolved when the tool is enabled; a disabled profile with a stale meta_profile_ref still launches.
  • Credentials: routed LLMs loaded from the store carry their api_key into meta_profile_llms; an ordinary model_dump(mode="json") of the built agent redacts every key, and forward_to_runtime encrypts them (no plaintext in the forwarded payload). Only the existing trusted-backend expose_secrets paths carry plaintext.
  • uv run pytest tests/sdk/launch tests/sdk/profiles tests/sdk/settings -q → 277 passed. No distributable package version changed.

Non-blocking observation (unchanged). In _load_meta_profile, when stores.meta_profiles is None the function reports the name as a dangling reference rather than a store-not-wired error; the agent-server path always wires the store, so this is not blocking.

Assessment. Scoped to the launch pipeline and traced through resolve → preview → seed → forward/validate, with unit coverage plus the author's Docker e2e evidence. No material correctness, security, compatibility, or acceptance-criterion defect on this head.

✅ APPROVED

@simonrosenberg
simonrosenberg merged commit beb5cf8 into agent-launch-resolve-finalize Sep 30, 2026
18 checks passed
@simonrosenberg
simonrosenberg deleted the agent-launch-meta-profile-routing branch September 30, 2026 21:12
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.

2 participants