Repository navigation
PC-4990: end the CAS exchange after an exchange error - #1964
Draft
al3xanndru wants to merge 1 commit into
Draft
al3xanndru wants to merge 1 commit into
al3xanndru wants to merge 1 commit into
Conversation
A faulted conversational run (e.g. max iterations) sent exchangeError but never endExchange. The CAS chat UI leaves its generating state (Stop button, "Generating...") only on endExchange, so the user could not send the message the max-steps error tells them to send. emit_exchange_error_event now ends the exchange after the error, honouring end_exchange=False; emit_exchange_end_event is sent at most once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This branch has not been deployed
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.



Problem
PC-4990: when a conversational low-code agent hits its max-iterations limit in Studio Web's debug chat, the chat shows "Maximum number of sequential steps reached. You may send a new message to tell the agent to continue." But the input is still in its generating state. "Generating…" is still shown and the send button is still the Stop square, so the user can't send the message the error asks for. Re-checked on cloud on Oct 29: it still reproduces (maxIterations = 3, one tool, prompt asks for ten sequential calls).
Root cause
When a run faults,
UiPathChatRuntime(uipath-runtime) callschat_bridge.emit_exchange_error_event(error)and stops there. Only the successful branch callsemit_exchange_end_event().SocketIOChatBridge.emit_exchange_error_eventsends only theexchangeErrorevent, so CAS never getsendExchangefor a faulted exchange.The CAS chat client (
UiPath/AgentInterfaces,lib/react-sdk/src/providers/ConversationProvider.tsx) clears the generating state only inexchange.onExchangeEnd:chat.stopResponse(),setShowLoading(false),setWaiting(false). AnexchangeErrorstart only adds the error banner (onAnyErrorStart→chat.setError). The CAS cloud service relays agent events and does not end an exchange on an error. So every faulted URT conversational run leaves the UI on Stop, not just max iterations. Max iterations is the case users hit most, and its message tells them to send another message.The max-iterations check (
uipath_langchain/agent/react/llm_node.py) runs before the LLM call. Every earlier assistant message and tool call is already closed, so the missingendExchangeis the only thing that keeps the UI stuck.Change
packages/uipath/src/uipath/_cli/_chat/_bridge.py:emit_exchange_error_eventnow callsemit_exchange_end_event()after it sends the error. The error is terminal for the exchange: low-code jobs end, and coded jobs fault.emit_exchange_end_eventstill honoursend_exchange=False, so the exchange stays open for a downstream consumer.emit_exchange_end_eventnow sends the event at most once per bridge (that is, per exchange). A failure raised after the exchange already ended (the runtime's outerexceptpath) does not send a secondendExchange. The flag is set only after a successful send, so a failed send can still be retried.RuntimeErroris raised as before.uipath2.14.44 → 2.14.45.Tests
packages/uipath/tests/cli/chat/test_bridge.py, new classTestSocketIOChatBridgeErrorEndsExchange:exchangeError(AGENT_MAXIMUM_SEQUENTIAL_STEPS_REACHEDwith the Temporal message) and thenendExchange, checked against the exact payloads.end_exchange=False, only the error is sent.endExchangeis sent.endExchangecan be retried by a later error.UiPathChatRuntime(uipath-runtime 0.13.5): a delegate that yields a FAULTEDTERMINATION_MAX_ITERATIONSresult producesexchangeErrorand thenendExchange.test_emit_exchange_error_event_sends_when_connected: it now expects 2 emits.Results:
pytest tests/cli/chat: 119 passed. Against the unfixed bridge, 6 of the new or updated tests fail (3 cases × asyncio/trio).ruff check .andruff format --check .are clean, as isscripts/lint_httpx_client.py.mypy src/uipath/_cli/_chat tests/cli/chat: no issues.packages/uipathsuite: see the summary in the draft record.Risks / open questions
onClickStopResponseends the exchange itself), and the job is ending anyway. CAS owners should confirm thatendExchangeafterexchangeErroris the expected agent-side protocol. The SDK'sExchangeEventHelperallows it:sendErrorStartdoes not end the exchange.uipath-runtime-python'sUiPathChatRuntimeFAULTED branch, next to the success path'semit_exchange_end_event(). It is in the bridge because that is the CAS-specific layer that already owns exchange-end policy (end_exchange). The once-only guard keeps it correct if the runtime later adds its own end call.Agents/backend/Execution.Engines.Conversational.V1/ConversationalEngineWorkflow.cs) also sends onlySendExchangeErroron max steps. It is not changed here: the reported runs are URT (configurablemaxIterations,AGENT_RUNTIME.TERMINATION_MAX_ITERATIONS).uipath≥ 2.14.45.Drafted by the wabbit-dri draft-fixes loop for PC-4990 (draft #1), for a human to review: not ready to merge as is.
🤖 Generated with Claude Code