Add config option type for boolean on/off toggles#576
Open
fscarponi wants to merge 1 commit intoagentclientprotocol:mainfrom
Open
Add config option type for boolean on/off toggles#576fscarponi wants to merge 1 commit intoagentclientprotocol:mainfrom
fscarponi wants to merge 1 commit intoagentclientprotocol:mainfrom
Conversation
3741fdd to
ecf3967
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#541 implementation
This PR adds a new
booleantype to session configuration options, enabling agents to expose simple ON/OFF toggles (e.g., "Brave Mode", "Read Only", "Produce Report") as first-class config options alongside the existingselecttype.All new types are gated behind the
unstable_boolean_configfeature flag, so they can be iterated on without breaking the stable API.Motivation
The current
selectconfig option type works well for choosing between multiple values (models, modes, reasoning levels), but it doesn't naturally cover the use case of a simple on/off toggle. Without a dedicated boolean type, clients would need custom, non-agnostic logic to distinguish boolean toggles from regular selectors — defeating the purpose of a standardized protocol.A dedicated
booleantype allows clients to natively render toggle switches or checkboxes without guessing.Changes
Rust schema (
src/agent.rs) — gated behind#[cfg(feature = "unstable_boolean_config")]:SessionConfigBooleanstruct with acurrent_value: boolfieldBoolean(SessionConfigBoolean)variant toSessionConfigKind(discriminated via"type": "boolean")boolean()convenience constructor onSessionConfigOptionAlways available (backward compatible, no-op when no boolean options exist):
SessionConfigOptionValueenum (#[serde(untagged)]:String|Bool) to support both string and boolean values inSetSessionConfigOptionRequestFromimpls (SessionConfigValueId,bool,&str) for ergonomic constructionSetSessionConfigOptionRequest.valuefield type changed fromSessionConfigValueIdtoSessionConfigOptionValue— source-compatible for existing callers thanks toFromimplsFeature flag (
Cargo.toml):unstable_boolean_configfeature, included in theunstablemeta-featureDocumentation (
docs/protocol/session-config-options.mdx):brave_modeboolean example to the Initial State JSONsession/set_config_optionparameter docs to reflectstring | booleanvalue typeRFD (
docs/rfds/flag-config-option.mdx):Generated schemas:
schema.json— stable, does not include boolean typeschema.unstable.json— includes boolean typenpm run generateWire compatibility
SessionConfigOptionValueuses#[serde(untagged)], so existing JSON payloads with string values continue to deserialize correctly. The new boolean variant is additive and only available when the unstable feature is enabled.Verification
cargo clippy(no features) — no warningscargo clippy --all-features— no warningscargo test— 26 tests + 2 doctests pass (stable)cargo test --all-features— 27 tests + 2 doctests pass (with boolean)npm run generate— schemas regenerated successfullyprettier --check ./cargo fmt -- --check— formatting clean