-
Notifications
You must be signed in to change notification settings - Fork 2.7k
add built-in GetNameTask() and GetDOBTask() #4592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughAdds 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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this 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
📒 Files selected for processing (2)
livekit-agents/livekit/agents/beta/workflows/__init__.pylivekit-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__.pylivekit-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__.pylivekit-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_CHECKINGfor 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 thedone()check prevents double completion.
193-201: LGTM!Clean decline handler with appropriate
IGNORE_ON_ENTERflag 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.
There was a problem hiding this 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
📒 Files selected for processing (2)
livekit-agents/livekit/agents/beta/workflows/__init__.pylivekit-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__.pylivekit-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__.pylivekit-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.
There was a problem hiding this 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_dobmethod 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_timepersisting when DOB is updated was previously flagged in an earlier review.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 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
TurnDetectionModeis appropriate since it's only used in type annotations.
18-21: LGTM!Clean dataclass with appropriate fields. The
from __future__ import annotationsimport ensures Python 3.9+ compatibility for the union type syntax.
88-92: LGTM!The
on_entermethod correctly generates context-appropriate prompts based on whether time collection is enabled.
139-173: LGTM!The
update_timemethod 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_ENTERflag 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
ToolErrorto signal the decline case, allowing callers to distinguish between successful capture and user decline. TheIGNORE_ON_ENTERflag anddone()guard are correctly applied.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| "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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| "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.
name = await GetNameTask(first_name=True, middle_name=False, last_name=True, verify_spelling=True)set either
first_name,middle_name, orlast_nametoTrueto collect the fieldbirthday = await GetDOBTask(include_time=True)results are returned as
datetime.dateand optionallydatetime.timeSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.