-
Notifications
You must be signed in to change notification settings - Fork 20
feat: add suspend/resume support for RPA invocations in evaluations #1083
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
Draft
Chibionos
wants to merge
6
commits into
main
Choose a base branch
from
investigate-rpa-samples
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+217
−1
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1e7d126
feat: Add suspend/resume support for RPA invocations in evaluations
9013c4f
feat: Add --resume option and trigger pass-through to eval runtime
2f213ef
feat: Add comprehensive logging for suspend/resume detection in eval …
617ffba
docs: add suspend/resume eval runtime architecture diagram
3722a69
chore: remove draw.io diagram and event-trigger test agent
a35d2a5
style: fix linting issues in functions runtime
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,11 @@ | |
| UiPathErrorContract, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you need to undo everything in this file (this is used for arbitrary python code, no langgraph deps) |
||
| UiPathRuntimeError, | ||
| ) | ||
| from uipath.runtime.resumable.trigger import ( | ||
| UiPathResumeTrigger, | ||
| UiPathResumeTriggerName, | ||
| UiPathResumeTriggerType, | ||
| ) | ||
| from uipath.runtime.schema import UiPathRuntimeSchema | ||
|
|
||
| from .schema_gen import get_type_schema | ||
|
|
@@ -124,6 +129,71 @@ async def _execute_function( | |
|
|
||
| return convert_from_class(result) if result is not None else {} | ||
|
|
||
| def _detect_langgraph_interrupt( | ||
| self, output: dict[str, Any] | ||
| ) -> UiPathResumeTrigger | None: | ||
| """Detect LangGraph __interrupt__ field and extract InvokeProcess trigger. | ||
|
|
||
| LangGraph's interrupt() creates an __interrupt__ field in the output dict: | ||
| { | ||
| "query": "...", | ||
| "final_result": "", | ||
| "__interrupt__": [Interrupt(value=InvokeProcess(...), id="...")] | ||
| } | ||
|
|
||
| We extract the InvokeProcess from the interrupt and convert it to a UiPath trigger. | ||
| """ | ||
| try: | ||
| if not isinstance(output, dict): | ||
| return None | ||
|
|
||
| # Check for LangGraph's __interrupt__ field | ||
| if "__interrupt__" not in output: | ||
| return None | ||
|
|
||
| interrupts = output["__interrupt__"] | ||
| if not interrupts or not isinstance(interrupts, list): | ||
| logger.warning("__interrupt__ field exists but is not a list") | ||
| return None | ||
|
|
||
| # Extract first interrupt | ||
| interrupt_obj = interrupts[0] | ||
| if not hasattr(interrupt_obj, "value"): | ||
| logger.warning("Interrupt object missing 'value' attribute") | ||
| return None | ||
|
|
||
| invoke_process = interrupt_obj.value | ||
|
|
||
| # Check if it's an InvokeProcess object (has name and input_arguments) | ||
| if not ( | ||
| hasattr(invoke_process, "name") | ||
| and hasattr(invoke_process, "input_arguments") | ||
| ): | ||
| logger.warning( | ||
| f"Interrupt value is not InvokeProcess (type: {type(invoke_process)})" | ||
| ) | ||
| return None | ||
|
|
||
| logger.info( | ||
| f"Detected LangGraph interrupt - suspending execution for process: {invoke_process.name}" | ||
| ) | ||
|
|
||
| # Convert InvokeProcess to UiPath trigger | ||
| return UiPathResumeTrigger( | ||
| trigger_type=UiPathResumeTriggerType.JOB, | ||
| trigger_name=UiPathResumeTriggerName.JOB, | ||
| item_key=f"job-{uuid.uuid4()}", # Generate unique job key | ||
| folder_path=getattr(invoke_process, "process_folder_path", "Shared"), | ||
| payload={ | ||
| "process_name": invoke_process.name, | ||
| "input_arguments": invoke_process.input_arguments or {}, | ||
| "folder_key": getattr(invoke_process, "process_folder_key", None), | ||
| }, | ||
| ) | ||
| except Exception as e: | ||
| logger.warning(f"Failed to detect LangGraph interrupt: {e}") | ||
| return None | ||
|
|
||
| async def execute( | ||
| self, | ||
| input: dict[str, Any] | None = None, | ||
|
|
@@ -134,6 +204,23 @@ async def execute( | |
| func = self._load_function() | ||
| output = await self._execute_function(func, input or {}) | ||
|
|
||
| logger.info( | ||
| f"Output type: {type(output)}, has __interrupt__: {'__interrupt__' in output if isinstance(output, dict) else False}" | ||
| ) | ||
|
|
||
| # Check if output represents a LangGraph interrupt (suspend) | ||
| trigger = self._detect_langgraph_interrupt(output) | ||
| logger.info(f"Trigger detected: {trigger}") | ||
| if trigger: | ||
| logger.info( | ||
| f"Detected LangGraph interrupt - suspending execution with trigger: {trigger.item_key}" | ||
| ) | ||
| return UiPathRuntimeResult( | ||
| output=None, # No final output yet (suspended) | ||
| status=UiPathRuntimeStatus.SUSPENDED, | ||
| trigger=trigger, | ||
| ) | ||
|
|
||
| return UiPathRuntimeResult( | ||
| output=output, | ||
| status=UiPathRuntimeStatus.SUCCESSFUL, | ||
|
|
||
Oops, something went wrong.
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.
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.
if the runtime is suspended, you need to pass the result as suspended to the serverless exector