Skip to content

Conversation

@tinalenguyen
Copy link
Member

@tinalenguyen tinalenguyen commented Jan 22, 2026

name = await GetNameTask(first_name=True, middle_name=False, last_name=True, verify_spelling=True)

set either first_name, middle_name, or last_name to True to collect the field

birthday = await GetDOBTask(include_time=True)
results are returned as datetime.date and optionally datetime.time

Summary by CodeRabbit

  • New Features
    • Added a name-capture workflow to collect first/middle/last names with optional spelling verification, robust handling of varied inputs, plus confirmation and decline flows.
    • Added a date-of-birth capture workflow (optional time capture) with validation, confirmation and decline flows.
    • Public API updated to expose the new tasks and their result types for use in workflows.

✏️ Tip: You can customize this high-level summary in your review settings.

@chenghao-mou chenghao-mou requested a review from a team January 22, 2026 22:53
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

Adds two new workflow tasks and result dataclasses for capturing user identity details: a name-capture flow (first/middle/last) and a DOB-capture flow (date, optional time); and exposes these entities via the workflows package public API.

Changes

Cohort / File(s) Summary
Name workflow module
livekit-agents/livekit/agents/beta/workflows/name.py
New module (+~203 lines) adding GetNameResult (dataclass) and GetNameTask (AgentTask). Implements collection/normalization guidance, stateful update_name, confirm_name, and decline_name_capture tools with validation and ToolError handling.
DOB workflow module
livekit-agents/livekit/agents/beta/workflows/dob.py
New module (+~204 lines) adding GetDOBResult (dataclass) and GetDOBTask (AgentTask). Implements DOB (and optional time) collection, validation (including future-date checks), stateful update_dob, update_time, confirm_dob, and decline_dob_capture tools.
Public API exports
livekit-agents/livekit/agents/beta/workflows/__init__.py
Imports and adds GetNameResult, GetNameTask, GetDOBResult, and GetDOBTask to __all__, exposing the new workflow entities from the package.

Sequence Diagram

sequenceDiagram
    actor User
    participant Agent as GetNameTask / GetDOBTask
    participant LLM
    participant Tools as update/confirm/decline

    User->>Agent: Start capture task
    activate Agent
    Agent->>LLM: on_enter() — build prompt & instructions
    LLM-->>Agent: Prompt / guidance
    Agent-->>User: Ask for required fields (name parts or DOB/time)
    deactivate Agent

    User->>Tools: submit via update_* (name or dob)
    activate Tools
    Tools->>Agent: update internal state & validate input
    Agent-->>User: verification/clarification message
    deactivate Tools

    alt User confirms
        User->>Tools: confirm_*
        activate Tools
        Tools->>Agent: validate required fields present
        Agent-->>User: finish with Result dataclass
        deactivate Tools
    else User declines
        User->>Tools: decline_* (reason)
        activate Tools
        Tools-->>User: finish with error/decline message
        deactivate Tools
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I twitch my whiskers, listen close and bright,
I hop through names and dates by soft lamp-light,
I catch each letter, number, sound, and time,
I tuck them safe — precise, polite, sublime.
Hooray! A captured truth, snug as a rhyme.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.64% 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 accurately and concisely summarizes the main changes: adding two built-in tasks (GetNameTask and GetDOBTask) to the workflows module.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

Copy link
Contributor

@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: 2

🤖 Fix all issues with AI agents
In `@livekit-agents/livekit/agents/beta/workflows/name.py`:
- Line 150: The current construction of full_name uses "
".join([self._first_name, self._middle_name, self._last_name]) which yields
extra spaces when some parts are empty; update the code that sets full_name
(where self._first_name, self._middle_name, self._last_name are referenced) to
join only non-empty name parts (e.g., filter out falsy/empty strings or use a
generator that yields only parts with content) and ensure the result is trimmed
if necessary so names like "John  Doe" or trailing spaces are eliminated.
- Line 96: The workflow classes (e.g., in name.py) declare tools as tools:
NotGivenOr[list[llm.Tool | llm.Toolset]] = NOT_GIVEN but then call
super().__init__(..., tools=tools or []), which forces NOT_GIVEN into an empty
list and mismatches the parent AgentTask/Agent signature (AgentTask expects
tools: list[...] | None). Fix by making the types consistent: either change
AgentTask and Agent to accept tools: NotGivenOr[list[llm.Tool | llm.Toolset]]
(propagate NotGivenOr through their tools parameters and handle NOT_GIVEN
appropriately in AgentTask), or remove NotGivenOr from the workflow constructors
and declare tools as Optional[list[llm.Tool | llm.Toolset]] = None and pass
tools through to super() unchanged; update the function signatures for the
chosen approach and adjust all affected classes (name.py, warm_transfer.py,
email_address.py, address.py) and their calls to super().__init__ accordingly so
tools is handled consistently.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b01b3c and 881e928.

📒 Files selected for processing (2)
  • livekit-agents/livekit/agents/beta/workflows/__init__.py
  • livekit-agents/livekit/agents/beta/workflows/name.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Format code with ruff
Run ruff linter and auto-fix issues
Run mypy type checker in strict mode
Maintain line length of 100 characters maximum
Ensure Python 3.9+ compatibility
Use Google-style docstrings

Files:

  • livekit-agents/livekit/agents/beta/workflows/__init__.py
  • livekit-agents/livekit/agents/beta/workflows/name.py
🧠 Learnings (1)
📚 Learning: 2026-01-22T03:28:16.289Z
Learnt from: longcw
Repo: livekit/agents PR: 4563
File: livekit-agents/livekit/agents/beta/tools/end_call.py:65-65
Timestamp: 2026-01-22T03:28:16.289Z
Learning: In code paths that check capabilities or behavior of the LLM processing the current interaction, prefer using the activity's LLM obtained via ctx.session.current_agent._get_activity_or_raise().llm instead of ctx.session.llm. The session-level LLM may be a fallback and not reflect the actual agent handling the interaction. Use the activity LLM to determine capabilities and to make capability checks or feature toggles relevant to the current processing agent.

Applied to files:

  • livekit-agents/livekit/agents/beta/workflows/__init__.py
  • livekit-agents/livekit/agents/beta/workflows/name.py
🧬 Code graph analysis (2)
livekit-agents/livekit/agents/beta/workflows/__init__.py (1)
livekit-agents/livekit/agents/beta/workflows/name.py (2)
  • GetNameResult (18-21)
  • GetNameTask (24-201)
livekit-agents/livekit/agents/beta/workflows/name.py (3)
livekit-agents/livekit/agents/llm/tool_context.py (3)
  • ToolError (62-77)
  • ToolFlag (92-94)
  • Toolset (41-46)
livekit-agents/livekit/agents/voice/agent.py (3)
  • AgentTask (648-813)
  • instructions (99-104)
  • complete (687-706)
livekit-agents/livekit/agents/voice/events.py (2)
  • RunContext (32-81)
  • speech_handle (52-53)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: livekit-plugins-deepgram
  • GitHub Check: type-check (3.9)
  • GitHub Check: unit-tests
  • GitHub Check: type-check (3.13)
🔇 Additional comments (6)
livekit-agents/livekit/agents/beta/workflows/name.py (5)

1-14: LGTM!

Imports are well-organized with proper use of TYPE_CHECKING for type-only imports.


17-21: LGTM!

Simple and clean dataclass for the result type.


110-116: LGTM!

Clean implementation that adapts the prompt based on the number of requested name parts.


165-191: LGTM!

Good safeguards in place: wait_for_playout() ensures speech completes, speech handle comparison prevents auto-confirmation in the same turn, and the done() check prevents double completion.


193-201: LGTM!

Clean decline handler with appropriate IGNORE_ON_ENTER flag and completion guard.

livekit-agents/livekit/agents/beta/workflows/__init__.py (1)

4-4: LGTM!

Import and __all__ export follow the established pattern for workflow modules.

Also applies to: 15-16

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link
Contributor

@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

🤖 Fix all issues with AI agents
In `@livekit-agents/livekit/agents/beta/workflows/dob.py`:
- Around line 129-136: Clear any previously stored time at the start of the DOB
update and reject partial time inputs: in the method that contains the shown
block (where birth_time is computed and self._current_time is assigned), set
self._current_time = None before processing inputs so an omitted time clears
stale data; if both hour and minute are provided, validate and set
self._current_time to the constructed time; if only one of hour/minute is given,
raise ToolError to reject partial inputs; this ensures confirm_dob and related
logic never return a leftover time.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7fb565 and 50b243d.

📒 Files selected for processing (2)
  • livekit-agents/livekit/agents/beta/workflows/__init__.py
  • livekit-agents/livekit/agents/beta/workflows/dob.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Format code with ruff
Run ruff linter and auto-fix issues
Run mypy type checker in strict mode
Maintain line length of 100 characters maximum
Ensure Python 3.9+ compatibility
Use Google-style docstrings

Files:

  • livekit-agents/livekit/agents/beta/workflows/__init__.py
  • livekit-agents/livekit/agents/beta/workflows/dob.py
🧠 Learnings (1)
📚 Learning: 2026-01-22T03:28:16.289Z
Learnt from: longcw
Repo: livekit/agents PR: 4563
File: livekit-agents/livekit/agents/beta/tools/end_call.py:65-65
Timestamp: 2026-01-22T03:28:16.289Z
Learning: In code paths that check capabilities or behavior of the LLM processing the current interaction, prefer using the activity's LLM obtained via ctx.session.current_agent._get_activity_or_raise().llm instead of ctx.session.llm. The session-level LLM may be a fallback and not reflect the actual agent handling the interaction. Use the activity LLM to determine capabilities and to make capability checks or feature toggles relevant to the current processing agent.

Applied to files:

  • livekit-agents/livekit/agents/beta/workflows/__init__.py
  • livekit-agents/livekit/agents/beta/workflows/dob.py
🧬 Code graph analysis (2)
livekit-agents/livekit/agents/beta/workflows/__init__.py (2)
livekit-agents/livekit/agents/beta/workflows/dob.py (2)
  • GetDOBResult (19-21)
  • GetDOBTask (24-180)
livekit-agents/livekit/agents/beta/workflows/name.py (2)
  • GetNameResult (18-21)
  • GetNameTask (24-203)
livekit-agents/livekit/agents/beta/workflows/dob.py (4)
livekit-agents/livekit/agents/llm/tool_context.py (3)
  • ToolError (62-77)
  • ToolFlag (92-94)
  • Toolset (41-46)
livekit-agents/livekit/agents/voice/agent.py (3)
  • AgentTask (648-813)
  • instructions (99-104)
  • complete (687-706)
livekit-agents/livekit/agents/voice/events.py (2)
  • RunContext (32-81)
  • speech_handle (52-53)
livekit-agents/livekit/agents/voice/speech_handle.py (1)
  • SpeechHandle (16-254)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: livekit-plugins-deepgram
  • GitHub Check: unit-tests
  • GitHub Check: livekit-plugins-elevenlabs
  • GitHub Check: type-check (3.13)
  • GitHub Check: type-check (3.9)
🔇 Additional comments (7)
livekit-agents/livekit/agents/beta/workflows/dob.py (5)

18-21: LGTM: result dataclass is clear and minimal.


24-87: LGTM: task initialization and instructions are well-structured.


88-92: LGTM: prompt selection is concise and correct.


151-171: LGTM: confirmation safeguards are solid.


172-180: LGTM: decline flow is straightforward.

livekit-agents/livekit/agents/beta/workflows/__init__.py (2)

1-6: LGTM: imports align with new workflow exports.


9-23: LGTM: all now correctly exposes the new tasks/results.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@tinalenguyen tinalenguyen changed the title add built-in GetNameTask() add built-in GetNameTask() and GetDOBTask*( Jan 22, 2026
@tinalenguyen tinalenguyen changed the title add built-in GetNameTask() and GetDOBTask*( add built-in GetNameTask() and GetDOBTask() Jan 22, 2026
Copy link
Contributor

@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

🤖 Fix all issues with AI agents
In `@livekit-agents/livekit/agents/beta/workflows/dob.py`:
- Around line 70-71: The concatenation of the literal sentence and
extra_instructions in dob.py can run together when extra_instructions is
non-empty; update the string assembly (the expression that builds the final
instruction string containing "Always explicitly invoke a tool..." and the
extra_instructions variable) to insert an explicit separator (e.g., a space or
newline) between the fixed sentence and extra_instructions so the two parts
never merge.
♻️ Duplicate comments (1)
livekit-agents/livekit/agents/beta/workflows/dob.py (1)

94-137: LGTM!

The update_dob method properly validates the date, rejects future dates with a clear error message, and returns a well-formatted response prompting user confirmation.

Note: The concern about stale _current_time persisting when DOB is updated was previously flagged in an earlier review.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 50b243d and d973c71.

📒 Files selected for processing (1)
  • livekit-agents/livekit/agents/beta/workflows/dob.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Format code with ruff
Run ruff linter and auto-fix issues
Run mypy type checker in strict mode
Maintain line length of 100 characters maximum
Ensure Python 3.9+ compatibility
Use Google-style docstrings

Files:

  • livekit-agents/livekit/agents/beta/workflows/dob.py
🧠 Learnings (1)
📚 Learning: 2026-01-22T03:28:16.289Z
Learnt from: longcw
Repo: livekit/agents PR: 4563
File: livekit-agents/livekit/agents/beta/tools/end_call.py:65-65
Timestamp: 2026-01-22T03:28:16.289Z
Learning: In code paths that check capabilities or behavior of the LLM processing the current interaction, prefer using the activity's LLM obtained via ctx.session.current_agent._get_activity_or_raise().llm instead of ctx.session.llm. The session-level LLM may be a fallback and not reflect the actual agent handling the interaction. Use the activity LLM to determine capabilities and to make capability checks or feature toggles relevant to the current processing agent.

Applied to files:

  • livekit-agents/livekit/agents/beta/workflows/dob.py
🧬 Code graph analysis (1)
livekit-agents/livekit/agents/beta/workflows/dob.py (5)
livekit-agents/livekit/agents/llm/tool_context.py (3)
  • ToolError (62-77)
  • ToolFlag (92-94)
  • Toolset (41-46)
livekit-agents/livekit/agents/voice/agent.py (3)
  • AgentTask (648-813)
  • instructions (99-104)
  • complete (687-706)
livekit-agents/livekit/agents/voice/events.py (2)
  • RunContext (32-81)
  • speech_handle (52-53)
livekit-agents/livekit/agents/voice/speech_handle.py (1)
  • SpeechHandle (16-254)
livekit-agents/livekit/agents/llm/chat_context.py (1)
  • ChatContext (218-656)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: type-check (3.9)
  • GitHub Check: type-check (3.13)
  • GitHub Check: livekit-plugins-deepgram
  • GitHub Check: unit-tests
🔇 Additional comments (6)
livekit-agents/livekit/agents/beta/workflows/dob.py (6)

1-16: LGTM!

Imports are well-organized with standard library imports first, followed by relative imports. The TYPE_CHECKING guard for TurnDetectionMode is appropriate since it's only used in type annotations.


18-21: LGTM!

Clean dataclass with appropriate fields. The from __future__ import annotations import ensures Python 3.9+ compatibility for the union type syntax.


88-92: LGTM!

The on_enter method correctly generates context-appropriate prompts based on whether time collection is enabled.


139-173: LGTM!

The update_time method properly validates the time input and provides a well-formatted response that includes the date when available.


175-194: LGTM!

Well-designed confirmation flow:

  • IGNORE_ON_ENTER flag prevents premature invocation.
  • Speech handle comparison ensures the user explicitly confirmed rather than the LLM auto-confirming in the same turn.
  • Proper guard with done() check prevents double completion.

196-204: LGTM!

The decline handler properly uses ToolError to signal the decline case, allowing callers to distinguish between successful capture and user decline. The IGNORE_ON_ENTER flag and done() guard are correctly applied.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +70 to +71
"Always explicitly invoke a tool when applicable. Do not simulate tool usage, no real action is taken unless the tool is explicitly called."
+ extra_instructions
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing separator before extra_instructions.

If extra_instructions is non-empty, it will be concatenated directly to the previous sentence without a space or newline, causing instructions to run together (e.g., "...explicitly called.Remember to be polite").

Proposed fix
-                "Always explicitly invoke a tool when applicable. Do not simulate tool usage, no real action is taken unless the tool is explicitly called."
-                + extra_instructions
+                "Always explicitly invoke a tool when applicable. Do not simulate tool usage, no real action is taken unless the tool is explicitly called.\n"
+                + extra_instructions
📝 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
"Always explicitly invoke a tool when applicable. Do not simulate tool usage, no real action is taken unless the tool is explicitly called."
+ extra_instructions
"Always explicitly invoke a tool when applicable. Do not simulate tool usage, no real action is taken unless the tool is explicitly called.\n"
extra_instructions
🤖 Prompt for AI Agents
In `@livekit-agents/livekit/agents/beta/workflows/dob.py` around lines 70 - 71,
The concatenation of the literal sentence and extra_instructions in dob.py can
run together when extra_instructions is non-empty; update the string assembly
(the expression that builds the final instruction string containing "Always
explicitly invoke a tool..." and the extra_instructions variable) to insert an
explicit separator (e.g., a space or newline) between the fixed sentence and
extra_instructions so the two parts never merge.

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.

2 participants