fix(crew): SDK auto-fills tool_call response for transfer/end-call (no user code) - #104
Merged
Merged
Conversation
…o user code)
Crew transfer/end-call tools are fire-and-forget: they emit an
SDKAgentTransferConversationEvent / SDKAgentEndCallEvent and return nothing, so
the tool_call event showed only {arguments} with no response — unlike
single-prompt agents, whose built-in transfer tool returns {status,
transfer_number}.
Rather than make users return a dict from their @function_tool, the SDK now does
it: OutputCrewNode.send_event (which already latches handoff events) records a
handoff summary, and ToolRegistry._execute_single attaches it as the
tool_call_end response when the tool itself returned None. Same shape
single-prompt surfaces (status/action/transfer_number/transfer_type/on_hold_music),
zero user code. Only the observability event is enriched; the tool's own return
value and the LLM-facing result are unchanged.
Tests: transfer + end-call tools get the handoff response; a plain None tool
still has no response.
…esponse Transfer has two kinds: cold (direct connect) and warm (brief the specialist, then bridge). The event summary now reflects which happened: warm transfers add the private/public handoff option (type + prompt); cold transfers carry none. transfer_type (cold_transfer|warm_transfer) + on_hold_music already distinguished them; this adds the whisper detail for warm.
…oop) CrewNode init grabs the event loop, which raises on Python 3.9 when there is no current loop. Construct the node inside asyncio.run so the handoff-response tests pass on 3.9.
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.
Why
Follow-up to #102. Crew
transfer_callshows on the Events tab now, but itsresponsewas empty ({"arguments": {}}) while single-prompt shows{status, transfer_number}. Reason: the crewtransfer_callis a fire-and-forget@function_toolthat emits a transfer event and returns nothing, and the tool_callresponseis literally the tool's return value (same as the orchestrator — pipecat recordsfunction_response: result). Single-prompt looks rich only because its built-in transfer tool returns a dict.We don't want to make users return a dict from their tool. So the SDK does it.
Fix (SDK-side, zero user code)
OutputCrewNode.send_eventalready latches handoff events (_HANDOFF_EVENTS). It now also records a handoff summary, andToolRegistry._execute_singleattaches that summary as thetool_call_endresponsewhen the tool itself returnedNone:{ "arguments": {}, "response": { "status": "success", "action": "transfer_call", "transfer_number": "+91...", "transfer_type": "warm_transfer", "on_hold_music": "relaxing_sound" } }ToolResultare unchanged (no behavior change).None-returning tool with no handoff stays as before (noresponse).transfer_calland end-call, matching single-prompt.Tests
transfer + end-call tools get the handoff response; plain None tool has none. ruff clean; crew suite (32) green.
Ships in the next release (5.11.2); crews get it on redeploy with no code change.