Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 34 additions & 25 deletions libs/acp/deepagents_acp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
PlanEntry,
PromptCapabilities,
ResourceContentBlock,
SessionConfigOption,
SessionConfigOptionSelect,
SessionConfigSelectOption,
SessionModeState,
Expand All @@ -48,6 +47,13 @@
ToolCallUpdate,
ToolKind,
)

try:
from acp.schema import SessionConfigOption
except ImportError:
# agent-client-protocol >=0.9.0 removed the SessionConfigOption wrapper;
# config options are now bare SessionConfigOptionSelect instances.
SessionConfigOption = None # type: ignore[assignment,misc]
from deepagents import create_deep_agent
from deepagents.backends import CompositeBackend, FilesystemBackend, StateBackend
from langgraph.checkpoint.memory import MemorySaver
Expand Down Expand Up @@ -135,14 +141,17 @@ def on_connect(self, conn: Client) -> None:
"""Store the client connection for sending session updates."""
self._conn = conn

def _build_config_options(self, session_id: str) -> list[SessionConfigOption]:
def _build_config_options(
self,
session_id: str,
) -> list[SessionConfigOptionSelect]:
"""Build the list of session configuration options.

Returns a list combining mode and model selectors if available.
Modes are mapped to config options with category='mode'.
Models are exposed as config options with category='model'.
"""
config_options: list[SessionConfigOption] = []
config_options: list[SessionConfigOptionSelect] = []

# Add mode selector if modes are configured
if self._modes is not None:
Expand All @@ -156,18 +165,18 @@ def _build_config_options(self, session_id: str) -> list[SessionConfigOption]:
for mode in self._modes.available_modes
]

mode_config = SessionConfigOption(
root=SessionConfigOptionSelect(
id="mode",
name="Session Mode",
description="Controls how the agent requests permission",
category="mode",
type="select",
current_value=current_mode,
options=mode_options,
)
mode_select = SessionConfigOptionSelect(
id="mode",
name="Session Mode",
description="Controls how the agent requests permission",
category="mode",
type="select",
current_value=current_mode,
options=mode_options,
)
config_options.append(
SessionConfigOption(root=mode_select) if SessionConfigOption else mode_select,
)
config_options.append(mode_config)

# Add model selector if models are configured
if self._models is not None and len(self._models) > 0:
Expand All @@ -181,18 +190,18 @@ def _build_config_options(self, session_id: str) -> list[SessionConfigOption]:
for model in self._models
]

model_config = SessionConfigOption(
root=SessionConfigOptionSelect(
id="model",
name="Model",
description="The LLM model to use for this session",
category="model",
type="select",
current_value=current_model,
options=model_options,
)
model_select = SessionConfigOptionSelect(
id="model",
name="Model",
description="The LLM model to use for this session",
category="model",
type="select",
current_value=current_model,
options=model_options,
)
config_options.append(
SessionConfigOption(root=model_select) if SessionConfigOption else model_select,
)
config_options.append(model_config)

return config_options

Expand Down