fix(workflows): return corrective instructions as tool output instead of generate_reply#6372
Open
u9g wants to merge 5 commits into
Open
fix(workflows): return corrective instructions as tool output instead of generate_reply#6372u9g wants to merge 5 commits into
u9g wants to merge 5 commits into
Conversation
… of generate_reply The confirm_* tools (and credit_card's update_* validation branches) called session.generate_reply() from inside tool execution to voice corrective messages - scheduling a separate speech that competes with the turn's own tool_response reply and leaves nothing in the chat context. Return the instruction as the tool's output instead, so it flows through the normal tool-response reply and merges with sibling tool outputs in the same turn. on_enter hooks and the DTMF event handlers keep generate_reply - they run outside tool execution where there is no tool-output channel.
An intake agent exposing one collect_* tool per data-capture workflow (email, phone, address, DOB with time, name, credit card), all with require_confirmation=True so text-only simulations still exercise the confirm_* tool paths, plus an `lk agent simulate` scenarios.yaml driving each corrective branch: value corrected at the confirmation step, time of birth before the date, and the card number length / repeat-mismatch / expired-date validations. Expectations grade the two regressions the tool-output refactor could introduce: going silent where generate_reply used to speak, and completing with a stale value.
| async def collect_date_of_birth(self, context: RunContext) -> str: | ||
| """Collect the user's date of birth (and time of birth if they know it).""" | ||
| result = await beta.workflows.GetDOBTask(include_time=True, require_confirmation=True) | ||
| logger.info(f"captured dob: {result.date_of_birth} time: {result.time_of_birth}") |
…f sensitive information' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…f sensitive information' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The data-capture workflows'
confirm_*tools (andcredit_card'supdate_*validation branches) calledsession.generate_reply()from inside tool execution to voice corrective messages — scheduling a separate speech that competes with the turn's own tool_response reply and leaves nothing in the chat context. This PR returns the instruction as the tool's output instead, so it flows through the normal tool-response reply and merges with sibling tool outputs in the same turn.on_enterhooks and the DTMF event handlers keepgenerate_reply— they run outside tool execution where there is no tool-output channel.Testing
Adds a simulation harness (
examples/data_capture_sim) — an intake agent exposing onecollect_*tool per data-capture workflow (email, phone, address, DOB with time, name, credit card), all withrequire_confirmation=Trueso text-only simulations still exercise theconfirm_*paths, plus anlk agent simulatescenarios file driving each corrective branch: value corrected at the confirmation step, time of birth before the date, and the card number length / repeat-mismatch / expired-date validations. Expectations grade the two regressions this refactor could introduce: going silent wheregenerate_replyused to speak, and completing with a stale value.The sim runs in CI (
.github/workflows/data-capture-sim.yml) on any change tolivekit-agents/livekit/agents/beta/workflows/**or the sim harness itself.