Skip to content

Commit a691457

Browse files
committed
custom features agent
1 parent 2c5f9f5 commit a691457

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

  • 37-vanilla-agent-custom-features/vanilla_agent_custom_features

37-vanilla-agent-custom-features/vanilla_agent_custom_features/main.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,18 @@ def get_copilot_description():
8787
async def query(request: QueryRequest) -> EventSourceResponse:
8888
"""Stream a simple greeting with feature status."""
8989

90-
# Check workspace_options from request payload
91-
# workspace_options is a list like ["web-search"] or ["deep-research", "web-search"]
92-
# Text/select features are sent as "key=value" entries
93-
workspace_options = getattr(request, "workspace_options", [])
94-
95-
# Helper to extract a value from "key=value" entries
96-
def get_option_value(key: str, default: str = "") -> str:
97-
for opt in workspace_options:
98-
if opt.startswith(f"{key}="):
99-
return opt.split("=", 1)[1]
100-
return default
90+
# Check workspace_options from request payload.
91+
# workspace_options is a dictionary like:
92+
# {"deep-research": true, "web-search": false, "model": "gpt-4o"}
93+
workspace_options = getattr(request, "workspace_options", {}) or {}
10194

10295
# Check which features are enabled
103-
deep_research_enabled = "deep-research" in workspace_options
104-
web_search_enabled = "web-search" in workspace_options
96+
deep_research_enabled = bool(workspace_options.get("deep-research", False))
97+
web_search_enabled = bool(workspace_options.get("web-search", True))
10598

10699
# Read text/select feature values
107-
model = get_option_value("model", "claude-sonnet-4-20250514")
108-
agent_name = get_option_value("agent-name", "Example Agent")
100+
model = workspace_options.get("model", "claude-sonnet-4-20250514")
101+
agent_name = workspace_options.get("agent-name", "Example Agent")
109102

110103
# Build the feature status message
111104
features_msg = (

0 commit comments

Comments
 (0)