Skip to content

filler phrase while starting tool call#232

Open
rootflo-hardik wants to merge 5 commits intodevelopfrom
CU-86d243yj6-voice-agent-filler-phrases
Open

filler phrase while starting tool call#232
rootflo-hardik wants to merge 5 commits intodevelopfrom
CU-86d243yj6-voice-agent-filler-phrases

Conversation

@rootflo-hardik
Copy link
Contributor

@rootflo-hardik rootflo-hardik commented Feb 27, 2026

Summary by CodeRabbit

  • New Features
    • Multilingual filler phrases now play while requests are processed to keep users engaged.
    • Supports English, Hindi, Tamil, Telugu, Malayalam, and Kannada, with multiple polite variants per language.
    • Filler messages are selected dynamically at processing start and respect the active language so users hear prompts in their current language.
@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

Adds a new multilingual constant FILLER_PHRASES and registers an LLM event handler in the Pipecat service to emit a language-aware random filler phrase (as a TTSSpeakFrame) when function calls start, skipping when language switching is detected.

Changes

Cohort / File(s) Summary
Filler Phrases Data
wavefront/server/apps/call_processing/call_processing/constants/filler_phrases.py
Adds new constant FILLER_PHRASES: a dict mapping language codes (en, hi, ta, te, ml, kn) to lists of four polite filler phrases each.
Pipecat Service Integration
wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py
Adds imports (os, random, FILLER_PHRASES) and registers on_function_calls_started on the LLM event stream; handler reads language_state, avoids running during detect_and_switch_language, selects a random phrase for the current language, and enqueues a TTSSpeakFrame when function calls begin.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Pipecat as PipecatService
    participant LLM
    participant LangState as LanguageState
    participant Phrases as FILLER_PHRASES
    participant TTSQueue as TTSQueue

    Client->>Pipecat: request triggering function calls
    Pipecat->>LLM: send prompt / await function calls
    LLM-->>Pipecat: event stream (function calls started)
    Pipecat->>Pipecat: on_function_calls_started handler
    Pipecat->>LangState: read current_language
    LangState-->>Pipecat: language code
    Pipecat->>Phrases: fetch phrases[language]
    Phrases-->>Pipecat: list of phrases
    Pipecat->>Pipecat: select random phrase
    Pipecat->>TTSQueue: enqueue TTSSpeakFrame(phrase)
    TTSQueue-->>Client: play spoken filler phrase
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

"I nibble bytes and hop through trees,
I whisper words in six soft keys,
When function calls begin to wait,
A gentle phrase will bridge the state,
Hopping on, I send your cue. 🐇"

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: adding filler phrases that play when a tool call starts, which matches the new event handler and phrase selection logic.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch CU-86d243yj6-voice-agent-filler-phrases

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py (1)

527-530: Harden phrase fallback when a language key exists but has an empty list.

Current logic falls back only for missing keys; if a configured list is empty, Line 530 can raise on random.choice.

Suggested fix
-            phrases = FILLER_PHRASES.get(
-                current_lang, FILLER_PHRASES.get('en', ['Please wait a moment'])
-            )
+            phrases = (
+                FILLER_PHRASES.get(current_lang)
+                or FILLER_PHRASES.get('en')
+                or ('Please wait a moment.',)
+            )
             phrase = random.choice(phrases)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`
around lines 527 - 530, The code uses FILLER_PHRASES.get(current_lang, ...) then
does random.choice(phrases) which will raise if the key exists but maps to an
empty list; update the logic around FILLER_PHRASES/current_lang/phrases/phrase
so you explicitly ensure phrases is a non-empty list before calling
random.choice by checking if not phrases and then assigning
FILLER_PHRASES.get('en') or a hardcoded default like ['Please wait a moment'];
apply this fix in the block that sets phrases and phrase so it safely falls back
when the language key exists but the list is empty.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`:
- Line 525: The on_function_calls_started callback defines unused parameters
`service` and `function_calls` causing ARG001; fix it by renaming the parameters
to indicate intentional unused (e.g., `_service` and `_function_calls`) or
prefixing them with underscores so the linter ignores them while keeping the
function signature (update the async def on_function_calls_started definition
accordingly).

---

Nitpick comments:
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`:
- Around line 527-530: The code uses FILLER_PHRASES.get(current_lang, ...) then
does random.choice(phrases) which will raise if the key exists but maps to an
empty list; update the logic around FILLER_PHRASES/current_lang/phrases/phrase
so you explicitly ensure phrases is a non-empty list before calling
random.choice by checking if not phrases and then assigning
FILLER_PHRASES.get('en') or a hardcoded default like ['Please wait a moment'];
apply this fix in the block that sets phrases and phrase so it safely falls back
when the language key exists but the list is empty.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6532504 and 7881485.

📒 Files selected for processing (2)
  • wavefront/server/apps/call_processing/call_processing/constants/filler_phrases.py
  • wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py

# Register event handlers
@llm.event_handler('on_function_calls_started')
async def on_function_calls_started(service, function_calls):
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Resolve unused callback parameters to keep lint clean.

Line 525 introduces service and function_calls but does not use them (Ruff ARG001).

Suggested fix
-        async def on_function_calls_started(service, function_calls):
+        async def on_function_calls_started(_service, _function_calls):
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async def on_function_calls_started(service, function_calls):
async def on_function_calls_started(_service, _function_calls):
🧰 Tools
🪛 Ruff (0.15.2)

[warning] 525-525: Unused function argument: service

(ARG001)


[warning] 525-525: Unused function argument: function_calls

(ARG001)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`
at line 525, The on_function_calls_started callback defines unused parameters
`service` and `function_calls` causing ARG001; fix it by renaming the parameters
to indicate intentional unused (e.g., `_service` and `_function_calls`) or
prefixing them with underscores so the linter ignores them while keeping the
function signature (update the async def on_function_calls_started definition
accordingly).
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.

♻️ Duplicate comments (1)
wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py (1)

525-525: ⚠️ Potential issue | 🟡 Minor

Rename unused callback arg to clear Ruff ARG001.

service is still unused in this handler. Prefix it with _ to make intent explicit and keep lint clean.

Suggested fix
-        async def on_function_calls_started(service, function_calls):
+        async def on_function_calls_started(_service, function_calls):
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`
at line 525, The handler on_function_calls_started currently declares an unused
parameter named service which triggers Ruff ARG001; rename that parameter to
_service (or _ ) in the async def on_function_calls_started signature to mark it
as intentionally unused and update any internal references (none expected)
accordingly so the lint error is resolved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`:
- Line 525: The handler on_function_calls_started currently declares an unused
parameter named service which triggers Ruff ARG001; rename that parameter to
_service (or _ ) in the async def on_function_calls_started signature to mark it
as intentionally unused and update any internal references (none expected)
accordingly so the lint error is resolved.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7881485 and 92a32dd.

📒 Files selected for processing (1)
  • wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py
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.

♻️ Duplicate comments (1)
wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py (1)

526-526: ⚠️ Potential issue | 🟡 Minor

Rename the unused callback parameter at Line 526.

service is currently unused and still triggers Ruff ARG001.

Suggested fix
-        async def on_function_calls_started(service, function_calls):
+        async def on_function_calls_started(_service, function_calls):
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`
at line 526, The callback on_function_calls_started currently declares a
parameter named service that is unused and triggers Ruff ARG001; rename the
parameter in the function signature (e.g., from service to _service or _) to
mark it as intentionally unused and update any callers or references to the
callback registration if they rely on positional args, leaving the function body
unchanged (function name: on_function_calls_started).
🧹 Nitpick comments (1)
wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py (1)

528-531: Cache the feature flag once instead of reading env on every callback.

Reading/parsing ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL per event is avoidable overhead and can cause runtime behavior drift if env changes mid-call.

Refactor sketch
+        enable_filler_phrases_before_tool_call = (
+            os.getenv('ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL', '').strip().lower()
+            == 'true'
+        )
+
         `@llm.event_handler`('on_function_calls_started')
         async def on_function_calls_started(_service, function_calls):
-            if (
-                os.getenv('ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL', '').lower()
-                != 'true'
-            ):
+            if not enable_filler_phrases_before_tool_call:
                 return
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`
around lines 528 - 531, Cache the ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL flag
once instead of calling os.getenv(...) on every event: read and parse the env
var to a boolean at module import or in the PipecatService initializer (e.g.,
store as module-level ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL or
self.enable_filler_phrases_before_tool_call) and replace the per-callback check
that currently uses os.getenv('ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL',
'').lower() != 'true' with a check against the cached boolean; ensure the
variable name matches existing style and is used wherever that runtime check
appears.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`:
- Line 526: The callback on_function_calls_started currently declares a
parameter named service that is unused and triggers Ruff ARG001; rename the
parameter in the function signature (e.g., from service to _service or _) to
mark it as intentionally unused and update any callers or references to the
callback registration if they rely on positional args, leaving the function body
unchanged (function name: on_function_calls_started).

---

Nitpick comments:
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`:
- Around line 528-531: Cache the ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL flag
once instead of calling os.getenv(...) on every event: read and parse the env
var to a boolean at module import or in the PipecatService initializer (e.g.,
store as module-level ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL or
self.enable_filler_phrases_before_tool_call) and replace the per-callback check
that currently uses os.getenv('ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL',
'').lower() != 'true' with a check against the cached boolean; ensure the
variable name matches existing style and is used wherever that runtime check
appears.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90630d7 and 30be05e.

📒 Files selected for processing (1)
  • wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant