Skip to content

[ENG-230] feat: add search_and_execute mode to StackOnePlugin - #3

Merged
shashi-stackone merged 7 commits into
mainfrom
tool-search
May 5, 2026
Merged

shashi-stackone merged 7 commits into
mainfrom
tool-search

Conversation

@shashi-stackone

@shashi-stackone shashi-stackone commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Linked: ENG-230

Adds mode="search_and_execute" to StackOnePlugin — registers two meta tools
(tool_search, tool_execute) instead of the full catalog, so the LLM discovers and
invokes tools on demand. Mirrors stackone-ai 2.8.0's
toolset.openai(mode="search_and_execute").

Changes

  • New keyword-only params: mode, search, execute, timeout (all default None).
  • Re-exports SearchConfig, SearchMode, ExecuteToolsConfig from stackone_ai.
  • StackOneAdkTool.run_async preserves StackOneAPIError.status_code / response_body
    / tool_name.
  • Account-discovery sends User-Agent: stackone-adk-plugin/{version}.
  • Examples: calendly_agent.py → workday_agent.py, new search_and_execute_agent.py,
    model gemini-3.1-pro-preview.
  • Deps: stackone-ai[mcp]>=2.8.0, google-adk>=1.31.1. Version 0.1.0 → 0.2.0.

Backwards compatibility

All new params are keyword-only with None defaults — every pre-0.2 call shape works
unchanged.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and timeout parameters and threads config into StackOneToolSet, with a new search_and_execute registration path.
  • Improves StackOneAdkTool.run_async error reporting by preserving StackOneAPIError fields and always returning tool_name on 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.

Comment thread stackone_adk/plugin.py
Comment on lines +134 to +143
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,

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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,

Copilot uses AI. Check for mistakes.
Comment thread stackone_adk/plugin.py
Comment on lines 138 to 145
self._toolset = StackOneToolSet(
api_key=api_key,
account_id=account_id,
base_url=base_url,
search=effective_search,
execute=execute,
timeout=timeout,
)

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread stackone_adk/plugin.py
Comment on lines 96 to 109
@@ -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:

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread stackone_adk/plugin.py Resolved
Comment thread stackone_adk/plugin.py
Comment on lines +153 to +154
# Use SDK's internal builder until a public API is exposed.
meta_tools = self._toolset._build_tools(account_ids=account_ids)

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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)

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This we cant fix for now unless we got ADK native StackOne SDK

Comment thread stackone_adk/tools.py
Comment on lines +80 to +82
except StackOneAPIError as exc:
logger.error(f"Tool {self.name} API error: {exc}")
return {

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shashi-stackone did you check this comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, its addressed now..

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread stackone_adk/plugin.py Resolved
Comment thread stackone_adk/plugin.py
_PLUGIN_VERSION = metadata.version("stackone-adk")
except metadata.PackageNotFoundError: # pragma: no cover
_PLUGIN_VERSION = "dev"
_USER_AGENT = f"stackone-adk-plugin/{_PLUGIN_VERSION}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good addition 👏

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 5 files (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Requires human review: This PR introduces a significant new feature (search_and_execute mode), updates core production dependencies, and modifies error handling in the tool execution path.

@glebedel glebedel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some nits, just focused on the examples we give

Comment thread README.md Outdated
# 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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why workday specifically? I think it's good to keep it generic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread README.md Outdated
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.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it generic here is good to, eg. You are an assistant with access to tools via StackOne

Or something to that effect

Comment thread README.md Outdated
)

app = App(name="calendly_app", root_agent=agent, plugins=[plugin])
app = App(name="workday_app", root_agent=agent, plugins=[plugin])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stackone_app maybe or assistant_app ?

Comment thread stackone_adk/tools.py
Comment on lines +80 to +82
except StackOneAPIError as exc:
logger.error(f"Tool {self.name} API error: {exc}")
return {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shashi-stackone did you check this comment?

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread README.md Resolved
@shashi-stackone

Copy link
Copy Markdown
Contributor Author

@glebedel I agreed with your points above and have addressed all your comments.

@shashi-stackone shashi-stackone changed the title feat: add search_and_execute mode to StackOnePlugin [ENG-230] feat: add search_and_execute mode to StackOnePlugin May 5, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@shashi-stackone
shashi-stackone merged commit 7be7f60 into main May 5, 2026
2 checks passed
@shashi-stackone
shashi-stackone deleted the tool-search branch May 5, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants