Skip to content

(feat): added common functions/tools for all templates#595

Open
narsimhaReddyJuspay wants to merge 1 commit intojuspay:releasefrom
narsimhaReddyJuspay:add-common-tools-for-all-templates
Open

(feat): added common functions/tools for all templates#595
narsimhaReddyJuspay wants to merge 1 commit intojuspay:releasefrom
narsimhaReddyJuspay:add-common-tools-for-all-templates

Conversation

@narsimhaReddyJuspay
Copy link
Contributor

@narsimhaReddyJuspay narsimhaReddyJuspay commented Feb 24, 2026

Summary by CodeRabbit

  • New Features
    • Added built-in date and time tools for voice agent flows, including current datetime, date, and time retrieval with timezone support (IST).
    • Introduced a common tools framework with category-based organization (BASIC, MATH, STRING, CALL, EXTERNAL) for standardized tool management.
    • Enabled template configuration to specify which common tool categories to include in flows.

@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This change introduces a common tools registry system for the Breeze Buddy voice agent template. New modules define tool registration, management, and IST-based date/time utilities. The flow manager now reads common tool categories from configuration and injects them into global functions at build time.

Changes

Cohort / File(s) Summary
Tool Registry System
app/ai/voice/agents/breeze_buddy/template/common_tools/registry.py
Introduces ToolCategory enum, CommonTool dataclass, and CommonToolRegistry singleton for managing tool metadata, registration, and retrieval by name or category.
Basic Tools Implementation
app/ai/voice/agents/breeze_buddy/template/common_tools/basic_tools.py
Registers three IST-based date/time utility tools (get_current_datetime, get_current_date, get_current_time) with async handlers and auto-invokes registration on import.
Common Tools Package Setup
app/ai/voice/agents/breeze_buddy/template/common_tools/__init__.py
Initializes common_tools package, re-exports registry classes and tool categories, and auto-registers basic tools.
Builder & Function Integration
app/ai/voice/agents/breeze_buddy/template/builder.py, app/ai/voice/agents/breeze_buddy/template/global_function.py
Updates method signatures to accept optional common_tool_categories parameter; GlobalFunctionRegistry now fetches and appends common tools via category-based filtering.
Flow Manager & Configuration
app/ai/voice/agents/breeze_buddy/agent/flow.py, app/ai/voice/agents/breeze_buddy/template/types.py
FlowManager derives common_tool_categories from configuration; ConfigurationModel adds common_tools field to specify included categories.
Public API Exports
app/ai/voice/agents/breeze_buddy/template/__init__.py
Exports CommonTool, CommonToolRegistry, and ToolCategory as part of the public interface.

Sequence Diagram

sequenceDiagram
    participant FM as FlowManager
    participant Cfg as Configuration
    participant TB as TemplateBuilder
    participant GFR as GlobalFunctionRegistry
    participant CTR as CommonToolRegistry

    FM->>Cfg: Read common_tools categories
    FM->>TB: Call build_global_functions(flow, categories)
    TB->>GFR: Call build(flow, handler_map, categories)
    GFR->>GFR: Parse categories to ToolCategory enums
    GFR->>CTR: Fetch tools by categories
    CTR-->>GFR: Return FlowsFunctionSchema objects
    GFR->>GFR: Combine template functions + common tools
    GFR-->>TB: Return merged function schemas
    TB-->>FM: Return complete global functions
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hops through tools with glee,
IST times dance wild and free,
Registry stores treasures bright,
Common tools take flight!
Templates now have helpers true,
Date and time made fresh and new. 🌙⏰

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding common functions/tools available across all templates, which is supported by the introduction of the CommonToolRegistry, basic tools, and integration across the template system.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (4)
app/ai/voice/agents/breeze_buddy/template/common_tools/registry.py (1)

88-89: Make registry state explicit with ClassVar to silence RUF012.

Ruff flags mutable class attributes here. Annotating as ClassVar makes the intent clear and avoids lint noise.

♻️ Suggested change
-from typing import Any, Callable, Dict, List, Optional
+from typing import Any, Callable, ClassVar, Dict, List, Optional
...
-    _tools: Dict[str, CommonTool] = {}
-    _by_category: Dict[ToolCategory, List[str]] = {cat: [] for cat in ToolCategory}
+    _tools: ClassVar[Dict[str, CommonTool]] = {}
+    _by_category: ClassVar[Dict[ToolCategory, List[str]]] = {cat: [] for cat in ToolCategory}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/ai/voice/agents/breeze_buddy/template/common_tools/registry.py` around
lines 88 - 89, The mutable class attributes _tools and _by_category in
registry.py should be annotated as ClassVar to make the registry state explicit
and silence RUF012; update the declarations for _tools (type Dict[str,
CommonTool]) and _by_category (type Dict[ToolCategory, List[str]]) to use
typing.ClassVar and ensure ClassVar is imported, leaving the initialization
logic (the empty dict and the {cat: [] for cat in ToolCategory}) unchanged so
the CommonTool and ToolCategory usages remain the same.
app/ai/voice/agents/breeze_buddy/template/common_tools/basic_tools.py (1)

83-115: Silence unused-arg lint in handlers.

The handlers don’t use args or flow_manager. Prefix with _ to avoid ARG001 warnings while keeping the required signature.

♻️ Suggested change
 async def _get_current_datetime_handler(
-    args: Dict[str, Any], flow_manager: FlowManager
+    _args: Dict[str, Any], _flow_manager: FlowManager
 ) -> tuple:
...
 async def _get_current_date_handler(
-    args: Dict[str, Any], flow_manager: FlowManager
+    _args: Dict[str, Any], _flow_manager: FlowManager
 ) -> tuple:
...
 async def _get_current_time_handler(
-    args: Dict[str, Any], flow_manager: FlowManager
+    _args: Dict[str, Any], _flow_manager: FlowManager
 ) -> tuple:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/ai/voice/agents/breeze_buddy/template/common_tools/basic_tools.py` around
lines 83 - 115, The handlers _get_current_datetime_handler,
_get_current_date_handler, and _get_current_time_handler currently accept args
and flow_manager but don't use them; rename their parameters to _args and
_flow_manager (e.g. def _get_current_datetime_handler(_args: Dict[str, Any],
_flow_manager: FlowManager) -> tuple) so the required signature is preserved but
ARG001 lint warnings are silenced; update each handler's parameter names
consistently in the three function definitions.
app/ai/voice/agents/breeze_buddy/template/global_function.py (1)

265-285: Avoid duplicate function names when merging common tools.

If a template defines a function with the same name as a common tool, the merged list may include duplicates. It’s safer to dedupe (or warn) to avoid ambiguous LLM tool resolution.

♻️ Suggested change
         result: List[FlowsFunctionSchema] = []

         # Build template-defined global functions
         global_functions_config = flow.get("global_functions", [])
         if global_functions_config:
             logger.info(f"Building {len(global_functions_config)} global functions")
             for func_config in global_functions_config:
                 schema = cls._build_one(func_config, handler_map)
                 if schema:
                     result.append(schema)

+        existing_names = {schema.name for schema in result}
+
         # Append common tools based on requested categories
         if common_tool_categories:
             categories = cls._parse_categories(common_tool_categories)
             if categories:
                 common_tools = CommonToolRegistry.get_by_categories(categories)
                 if common_tools:
                     logger.info(
                         f"Appending {len(common_tools)} common tools "
                         f"for categories: {[c.value for c in categories]}"
                     )
-                    result.extend(common_tools)
+                    for tool in common_tools:
+                        if tool.name in existing_names:
+                            logger.warning(
+                                f"Skipping common tool '{tool.name}' due to name collision"
+                            )
+                            continue
+                        result.append(tool)
+                        existing_names.add(tool.name)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/ai/voice/agents/breeze_buddy/template/global_function.py` around lines
265 - 285, When merging template-defined globals and common tools (variables:
global_functions_config, result, cls._build_one and
CommonToolRegistry.get_by_categories called with
common_tool_categories/categories), avoid duplicate function names by collecting
existing function names from result before appending common_tools and filtering
the common_tools list to exclude any whose name matches an existing one;
optionally log a warning that a common tool was skipped due to a name conflict
to make resolution explicit. Ensure the dedupe uses the function identifier/name
property used elsewhere in schemas so tool resolution remains unambiguous.
app/ai/voice/agents/breeze_buddy/template/types.py (1)

250-253: Consider validating common_tools against the tool category enum.

Right now it’s List[str], so typos only surface later via warnings and silently skip tools. Using an enum type (or a validator) will fail fast and normalize values.

♻️ Suggested change
-from typing import Any, Dict, List, Optional
+from typing import Any, Dict, List, Optional
+from app.ai.voice.agents.breeze_buddy.template.common_tools import ToolCategory
...
-    common_tools: Optional[List[str]] = Field(
+    common_tools: Optional[List[ToolCategory]] = Field(
         None,
         description="Common tool categories to include. Currently supported: ['BASIC'] for date/time tools.",
     )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/ai/voice/agents/breeze_buddy/template/types.py` around lines 250 - 253,
Change common_tools from Optional[List[str]] to an enum-backed field and add
validation: define a ToolCategory Enum (e.g., with BASIC) and update
common_tools: Optional[List[ToolCategory]] = Field(...), then add a pydantic
validator (e.g., validate_common_tools) on the model to normalize inputs (accept
strings, upper-case/map to enum) and raise a clear ValueError for unknown values
so typos fail fast; reference the Field named common_tools, the new ToolCategory
Enum, and the validator function validate_common_tools when implementing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/ai/voice/agents/breeze_buddy/template/common_tools/basic_tools.py`:
- Around line 83-115: The handlers _get_current_datetime_handler,
_get_current_date_handler, and _get_current_time_handler currently accept args
and flow_manager but don't use them; rename their parameters to _args and
_flow_manager (e.g. def _get_current_datetime_handler(_args: Dict[str, Any],
_flow_manager: FlowManager) -> tuple) so the required signature is preserved but
ARG001 lint warnings are silenced; update each handler's parameter names
consistently in the three function definitions.

In `@app/ai/voice/agents/breeze_buddy/template/common_tools/registry.py`:
- Around line 88-89: The mutable class attributes _tools and _by_category in
registry.py should be annotated as ClassVar to make the registry state explicit
and silence RUF012; update the declarations for _tools (type Dict[str,
CommonTool]) and _by_category (type Dict[ToolCategory, List[str]]) to use
typing.ClassVar and ensure ClassVar is imported, leaving the initialization
logic (the empty dict and the {cat: [] for cat in ToolCategory}) unchanged so
the CommonTool and ToolCategory usages remain the same.

In `@app/ai/voice/agents/breeze_buddy/template/global_function.py`:
- Around line 265-285: When merging template-defined globals and common tools
(variables: global_functions_config, result, cls._build_one and
CommonToolRegistry.get_by_categories called with
common_tool_categories/categories), avoid duplicate function names by collecting
existing function names from result before appending common_tools and filtering
the common_tools list to exclude any whose name matches an existing one;
optionally log a warning that a common tool was skipped due to a name conflict
to make resolution explicit. Ensure the dedupe uses the function identifier/name
property used elsewhere in schemas so tool resolution remains unambiguous.

In `@app/ai/voice/agents/breeze_buddy/template/types.py`:
- Around line 250-253: Change common_tools from Optional[List[str]] to an
enum-backed field and add validation: define a ToolCategory Enum (e.g., with
BASIC) and update common_tools: Optional[List[ToolCategory]] = Field(...), then
add a pydantic validator (e.g., validate_common_tools) on the model to normalize
inputs (accept strings, upper-case/map to enum) and raise a clear ValueError for
unknown values so typos fail fast; reference the Field named common_tools, the
new ToolCategory Enum, and the validator function validate_common_tools when
implementing.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8f0d21 and d1a3ee7.

📒 Files selected for processing (8)
  • app/ai/voice/agents/breeze_buddy/agent/flow.py
  • app/ai/voice/agents/breeze_buddy/template/__init__.py
  • app/ai/voice/agents/breeze_buddy/template/builder.py
  • app/ai/voice/agents/breeze_buddy/template/common_tools/__init__.py
  • app/ai/voice/agents/breeze_buddy/template/common_tools/basic_tools.py
  • app/ai/voice/agents/breeze_buddy/template/common_tools/registry.py
  • app/ai/voice/agents/breeze_buddy/template/global_function.py
  • app/ai/voice/agents/breeze_buddy/template/types.py

@narsimhaReddyJuspay narsimhaReddyJuspay force-pushed the add-common-tools-for-all-templates branch 4 times, most recently from f571627 to 26b565c Compare February 27, 2026 07:26
@narsimhaReddyJuspay narsimhaReddyJuspay force-pushed the add-common-tools-for-all-templates branch from 26b565c to ccf5e5a Compare February 27, 2026 07:26
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.

1 participant