Repository navigation
[ENG-230] feat: add search_and_execute mode to StackOnePlugin - #3
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new mode="search_and_execute" option to StackOnePlugin to register only the two StackOne “meta tools” (tool_search, tool_execute) for on-demand tool discovery/execution, plus supporting error propagation, docs/examples, and dependency/version bumps.
Changes:
- Introduces
mode,search,execute, andtimeoutparameters and threads config intoStackOneToolSet, with a newsearch_and_executeregistration path. - Improves
StackOneAdkTool.run_asyncerror reporting by preservingStackOneAPIErrorfields and always returningtool_nameon errors. - Updates docs/examples/changelog and bumps package/dependency versions to support the new mode.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
stackone_adk/plugin.py |
Adds search_and_execute mode, config threading, and User-Agent on account discovery. |
stackone_adk/tools.py |
Preserves StackOne API error details and returns tool_name on failures. |
stackone_adk/__init__.py |
Bumps version to 0.2.0 and re-exports StackOne config types. |
pyproject.toml |
Bumps project/dependency versions (stackone-ai[mcp], google-adk). |
tests/test_plugin.py |
Adds coverage for search_and_execute mode and config passthrough. |
tests/test_tools.py |
Adds coverage for preserving StackOneAPIError fields and tool_name. |
README.md |
Documents the new mode and updates examples/wording to Workday. |
examples/workday_agent.py |
New default-mode Workday example. |
examples/search_and_execute_agent.py |
New runnable search_and_execute example. |
examples/calendly_agent.py |
Removes the old Calendly example. |
CHANGELOG.md |
Adds a 0.2.0 changelog entry describing the new feature set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| effective_search: SearchConfig | None = search | ||
| if effective_search is None and mode == "search_and_execute": | ||
| effective_search = {"method": "auto"} | ||
|
|
||
| self._toolset = StackOneToolSet( | ||
| api_key=api_key, | ||
| account_id=account_id, | ||
| base_url=base_url, | ||
| search=effective_search, | ||
| execute=execute, |
There was a problem hiding this comment.
The docstring/README state search (and likely execute) are only used when mode="search_and_execute", but the implementation forwards search/execute into StackOneToolSet unconditionally. If the SDK treats non-None values as enabling search/execute behavior, passing these in default mode could be surprising. Consider validating/ignoring search+execute unless mode=="search_and_execute" (or update the docs to reflect the actual behavior).
| effective_search: SearchConfig | None = search | |
| if effective_search is None and mode == "search_and_execute": | |
| effective_search = {"method": "auto"} | |
| self._toolset = StackOneToolSet( | |
| api_key=api_key, | |
| account_id=account_id, | |
| base_url=base_url, | |
| search=effective_search, | |
| execute=execute, | |
| effective_search: SearchConfig | None = None | |
| effective_execute: ExecuteToolsConfig | None = None | |
| if mode == "search_and_execute": | |
| effective_search = search | |
| if effective_search is None: | |
| effective_search = {"method": "auto"} | |
| effective_execute = execute | |
| elif search is not None or execute is not None: | |
| logger.warning( | |
| "search/execute configuration is ignored unless mode='search_and_execute'" | |
| ) | |
| self._toolset = StackOneToolSet( | |
| api_key=api_key, | |
| account_id=account_id, | |
| base_url=base_url, | |
| search=effective_search, | |
| execute=effective_execute, |
| self._toolset = StackOneToolSet( | ||
| api_key=api_key, | ||
| account_id=account_id, | ||
| base_url=base_url, | ||
| search=effective_search, | ||
| execute=execute, | ||
| timeout=timeout, | ||
| ) |
There was a problem hiding this comment.
StackOneToolSet is being constructed with the raw api_key / base_url parameters, not the resolved values (resolved_api_key, resolved_base_url). If the caller relies on STACKONE_API_KEY / default base URL, this will pass None into the SDK and can break tool discovery/execution (including the new examples that don’t pass api_key). Use the resolved variables when instantiating StackOneToolSet, and add/update a test covering the env-var fallback path.
| @@ -79,6 +102,10 @@ def __init__( | |||
| providers: list[str] | None = None, | |||
| actions: list[str] | None = None, | |||
| account_ids: list[str] | None = None, | |||
| mode: Literal["search_and_execute"] | None = None, | |||
| search: SearchConfig | None = None, | |||
| execute: ExecuteToolsConfig | None = None, | |||
| timeout: float | None = None, | |||
| ) -> None: | |||
There was a problem hiding this comment.
The PR description says mode, search, execute, and timeout are keyword-only, but the __init__ signature doesn’t enforce that (there’s no * before mode). If you intend to guarantee backward-compatible call shapes and prevent accidental positional usage, make these parameters keyword-only by inserting a * before mode.
| # Use SDK's internal builder until a public API is exposed. | ||
| meta_tools = self._toolset._build_tools(account_ids=account_ids) |
There was a problem hiding this comment.
This uses the SDK’s private method _build_tools(...). Since private APIs can change in patch/minor releases, consider guarding this call (e.g., check the attribute exists and raise a clear error instructing users to upgrade/downgrade), or prefer a public SDK entrypoint if one exists in stackone-ai>=2.8.0.
| # Use SDK's internal builder until a public API is exposed. | |
| meta_tools = self._toolset._build_tools(account_ids=account_ids) | |
| # Guard use of the SDK's private builder until a public API is exposed. | |
| build_tools = getattr(self._toolset, "_build_tools", None) | |
| if not callable(build_tools): | |
| raise RuntimeError( | |
| "search_and_execute mode requires a compatible stackone-ai SDK version " | |
| "that provides the private StackOneToolSet._build_tools(...) method. " | |
| "Please install a supported stackone-ai version for this plugin, or " | |
| "upgrade to a release that exposes a public search_and_execute tool " | |
| "builder entrypoint." | |
| ) | |
| meta_tools = build_tools(account_ids=account_ids) |
There was a problem hiding this comment.
This we cant fix for now unless we got ADK native StackOne SDK
| except StackOneAPIError as exc: | ||
| logger.error(f"Tool {self.name} API error: {exc}") | ||
| return { |
There was a problem hiding this comment.
logger.error(f"...") eagerly formats the message and drops the traceback, which makes debugging API failures harder. Prefer logger.exception(...) (or logger.error(..., exc_info=exc)) so the stack trace is preserved and formatting is deferred.
There was a problem hiding this comment.
I think, its addressed now..
There was a problem hiding this comment.
1 issue found across 12 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="stackone_adk/plugin.py">
<violation number="1" location="stackone_adk/plugin.py:150">
P2: `providers` is still applied during account auto-discovery in `search_and_execute` mode, despite warning that providers/actions are ignored.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| _PLUGIN_VERSION = metadata.version("stackone-adk") | ||
| except metadata.PackageNotFoundError: # pragma: no cover | ||
| _PLUGIN_VERSION = "dev" | ||
| _USER_AGENT = f"stackone-adk-plugin/{_PLUGIN_VERSION}" |
glebedel
left a comment
There was a problem hiding this comment.
some nits, just focused on the examples we give
| # StackOne replaces manual tool functions | ||
| # Reads STACKONE_API_KEY from env and uses the specified account_id | ||
| plugin = StackOnePlugin(account_id="YOUR_ACCOUNT_ID") | ||
| plugin = StackOnePlugin(account_id="YOUR_WORKDAY_ACCOUNT_ID") |
There was a problem hiding this comment.
Why workday specifically? I think it's good to keep it generic
There was a problem hiding this comment.
Yes, I agree this specific example is demonstrating the workday but we shouldn't say "YOUR_WORKDAY_ACCOUNT_ID" specifically .. Both agent name and account ID Env car should be generic like we have in SDK examples .. I will change it .. Thanks
| instruction="You are a scheduling assistant with access to Calendly.", | ||
| model="gemini-3.1-pro-preview", | ||
| name="workday_agent", | ||
| instruction="You are an HR assistant with access to Workday.", |
There was a problem hiding this comment.
Keeping it generic here is good to, eg. You are an assistant with access to tools via StackOne
Or something to that effect
| ) | ||
|
|
||
| app = App(name="calendly_app", root_agent=agent, plugins=[plugin]) | ||
| app = App(name="workday_app", root_agent=agent, plugins=[plugin]) |
There was a problem hiding this comment.
stackone_app maybe or assistant_app ?
| except StackOneAPIError as exc: | ||
| logger.error(f"Tool {self.name} API error: {exc}") | ||
| return { |
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="README.md">
<violation number="1" location="README.md:241">
P3: The new example description is inconsistent with the documented default behavior. Default mode registers all discovered tools, not a "small set," which can mislead users configuring agents.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
|
@glebedel I agreed with your points above and have addressed all your comments. |
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Auto-approved: Changes are well-contained, backward-compatible (all new params optional with None defaults), include thorough test coverage, and do not alter existing functionality. Risk of breakage is low.
Summary
Linked: ENG-230
Adds
mode="search_and_execute"toStackOnePlugin— registers two meta tools(
tool_search,tool_execute) instead of the full catalog, so the LLM discovers andinvokes tools on demand. Mirrors
stackone-ai2.8.0'stoolset.openai(mode="search_and_execute").Changes
mode,search,execute,timeout(all defaultNone).SearchConfig,SearchMode,ExecuteToolsConfigfromstackone_ai.StackOneAdkTool.run_asyncpreservesStackOneAPIError.status_code/response_body/
tool_name.User-Agent: stackone-adk-plugin/{version}.calendly_agent.py→workday_agent.py, newsearch_and_execute_agent.py,model
gemini-3.1-pro-preview.stackone-ai[mcp]>=2.8.0,google-adk>=1.31.1. Version0.1.0→0.2.0.Backwards compatibility
All new params are keyword-only with
Nonedefaults — every pre-0.2 call shape worksunchanged.