sdk: centralize programmatic settings schema#2361
Conversation
Co-authored-by: openhands <openhands@all-hands.dev>
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||
all-hands-bot
left a comment
There was a problem hiding this comment.
Taste Rating: 🟢 Good taste
Analysis:
This PR solves a real problem - centralizing settings schema as a single source of truth for downstream clients. The data structure choice (Pydantic model with field metadata) is pragmatic and follows established patterns.
Data Structure: Clean. Settings live in one place, metadata is co-located with field definitions, and the schema export is straightforward.
Simplicity: The conversion logic handles real use cases (create vs update, custom factories) without over-engineering. Test coverage validates real behavior - agent round-tripping works, factories integrate correctly, schema export produces the right structure.
Backward Compatibility: Purely additive - no existing APIs changed.
Verdict: ✅ Worth merging
Key Insight: By making SDKSettings the declarative source of truth with exportable schema, this eliminates the need for clients to reverse-engineer agent configuration or maintain duplicate settings definitions.
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
all-hands-bot
left a comment
There was a problem hiding this comment.
Taste Rating: 🟡 Acceptable - Solid engineering approach solving a real problem.
Data Structure: Clean. Settings metadata lives alongside field definitions via Pydantic annotations, avoiding the anti-pattern of duplicate config models that drift from the source of truth.
Verdict: ✅ Worth merging. The core design is sound - annotating canonical fields eliminates special cases and maintains a single source of truth. Minor documentation fix suggested below.
Co-authored-by: openhands <openhands@all-hands.dev>
enyst
left a comment
There was a problem hiding this comment.
Hi — OpenHands-GPT-5.4 here. I read the PR, the review threads, the related issues (#2228, #2274, #1451), and I also checked the current usage patterns in OpenHands/OpenHands-CLI before leaving this review.
I agree with the short-term motivation: programmatic settings should come from the SDK instead of being hand-curated separately in each client. I also think replacing the duplicate mini-LLM settings subset with the canonical LLM fields was the right local correction.
That said, I don't think this PR lands on the right boundary for the SDK yet.
-
The new AgentSettings round-trip is lossy.
from_agent()/apply_to_agent()read like a general SDK config/edit/rebuild path, but the implementation only preserves a curated default story (LLMSummarizingCondenser,APIBasedCritic, and an annotated subset of LLM fields). In an extensible SDK, an official settings/materialization path should not silently drop alternative built-in or downstream implementations. -
The exported schema mixes semantic config with client presentation policy.
widget,advanced,placeholder,slash_command, and similar hints are first-party UX decisions, not core SDK semantics. Exporting them from SDK models hardcodes one client opinion into every client and makes future divergence painful. -
More broadly, #2274 is right that
LLMalready carries too many responsibilities. This PR adds more meaning onto the currentLLMclass instead of separating configuration from runtime/materialization.
My preference would be either:
- narrow this into an explicitly first-party client adapter (instead of a generic SDK settings abstraction), or
- redesign around a canonical immutable config/profile object with neutral schema export, and keep presentation decisions in CLI/GUI.
So: useful motivation, but I think the current abstraction is risky for an extensible SDK.
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
|
I'm on it! neubig can track my progress at all-hands.dev |
Co-authored-by: openhands <openhands@all-hands.dev>
Validation:
|
|
Here’s the final summary of the new work completed:
Conciseness check:
New commit:
PR reply: So yes — the request has been completely addressed, and the follow-up was kept concise and faithful to the instructions. |
xingyaoww
left a comment
There was a problem hiding this comment.
Overall LGTM! Would be helpful if we have a draft PR showing how CLI or GUI can use this refactored schema :)
I guess we can keep this feature hidden for a while and only publish the official agent settings example and docs when we've stabilize the API and got this support merged into our CLI & GUI
|
Yes, here are the draft PRs that are also waiting for review on the GUI+CLI. I haven't checked the CLI one very carefully yet:
@OpenHands perform the settings folder restructuring, per the review comment above. |
|
I'm on it! neubig can track my progress at all-hands.dev |
Co-authored-by: openhands <openhands@all-hands.dev>
|
No additional code changes were made after my last update. Final status: Completion checklist
Conciseness
Final resultYes — the request was completely addressed, the instructions were followed, and the PR review comment about restructuring the settings code into a folder has been handled. |
Co-authored-by: openhands <openhands@all-hands.dev>
|
Thanks! Re-requested. |
xingyaoww
left a comment
There was a problem hiding this comment.
LGTM! Let's get this in and try it in the CLI first -- Huge kudos for this!
|
Related to #2361 (review) @OpenHands can you create an issue tracking that we should add the settings example & docs ONCE we know it works in the CLI. Add a comment under OpenHands-CLI PR that @neubig mentioned and point it to the issue you created. |
|
I'm on it! xingyaoww can track my progress at all-hands.dev |
SummaryBoth parts of the request have been fully addressed:
No code changes were made — this was purely issue/comment management work, so there's nothing extraneous to revert. |
Summary
AgentSettingsmodel plusexport_schema(),export_settings_schema(), andcreate_agent()for programmatic agent configuration.LLMfield definitions as the single source of truth for LLM settings metadata, while keeping the exported schema focused on structured configuration facts (sections, labels, defaults, dependencies, choices, secret-ness, and prominence).examples/01_standalone_sdk/46_agent_settings.pyexample for settings export, round-tripping, and settings-driven agent creation.openhands-sdkat1.14.0on this non-release PR so version-bump and deprecation checks compare against the current released minor.Companion GUI consumer PR: OpenHands/OpenHands#13306
Fixes #2228
Evidence
Local validation
uv run pre-commit run --files AGENTS.md examples/01_standalone_sdk/46_agent_settings.py openhands-sdk/openhands/sdk/__init__.py openhands-sdk/openhands/sdk/llm/llm.py openhands-sdk/openhands/sdk/settings.py openhands-sdk/openhands/sdk/settings_metadata.py tests/sdk/test_settings.pyVERSION_BUMP_BASE_REF=main PR_TITLE='sdk: centralize programmatic settings schema' PR_HEAD_REF='openhands/issue-2228-sdk-settings-schema' python3 .github/scripts/check_version_bumps.pyuv run --with packaging python .github/scripts/check_deprecations.pyACP_VERSION_CHECK_BASE_REF=main ACP_VERSION_CHECK_SKIP=false uv run python .github/scripts/check_sdk_api_breakage.pycurrently reports the metadata-onlyField(..., json_schema_extra=...)changes on publicLLMfields as breaking changes.uv run pytest tests/sdk/test_settings.py -q(10 passed)Live run
LLM_API_KEY="$LLM_API_KEY" LLM_BASE_URL='https://llm-proxy.app.all-hands.dev' LLM_MODEL="$LLM_MODEL" uv run python examples/01_standalone_sdk/46_agent_settings.pycompleted successfully, including the agent-created
hello_settings.txtstep and cleanup (EXAMPLE_COST: 0.032991).Current GitHub status
Python API breakage checksis currently red for the same metadata-onlyLLMfield changes noted above.[Optional] Docs example/check-examplesis currently red becauseexamples/01_standalone_sdk/46_agent_settings.pyis not yet documented inOpenHands/docs.OpenHands/docsPR on branchopenhands/issue-2228-sdk-settings-schema.Checklist
AI note: this PR description was updated by an AI assistant (OpenHands) on behalf of the user.
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22-slimgolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:ca0d083-pythonRun
All tags pushed for this build
About Multi-Architecture Support
ca0d083-python) is a multi-arch manifest supporting both amd64 and arm64ca0d083-python-amd64) are also available if needed