Skip to main content

UiPath Runtime abstractions

Project description

UiPath Runtime

PyPI downloads Python versions

Core runtime abstractions and contracts for the UiPath Python SDK.

Overview

uipath-runtime provides the foundational interfaces and base classes for building agent runtimes in the UiPath ecosystem. It defines the contracts that all runtime implementations must follow, handles execution context, event streaming, tracing, and error management.

This package is typically used as a dependency by higher-level packages like uipath-langchain, uipath-llamaindex, or the main uipath SDK. You would use this directly only if you're building custom runtime implementations.

Installation

uv add uipath-runtime

Core Concepts

Runtime Base Class

All runtimes extend UiPathBaseRuntime and implement these core methods:

from uipath.runtime import UiPathBaseRuntime, UiPathRuntimeContext, UiPathRuntimeResult, UiPathRuntimeEvent

class MyCustomRuntime(UiPathBaseRuntime):
    def __init__(self, context: UiPathRuntimeContext):
        super().__init__(context)

    async def get_schema(self) -> UiPathRuntimeSchema:
        # Returns the runtime's JSON schemas
        return UiPathRuntimeSchema(
            input={
                "type": "object",
                "properties": {
                    "message": {
                        "type": "string",
                        "description": "Input message"
                    }
                },
                "required": ["message"]
            },
            output={
                "type": "object",
                "properties": {
                    "result": {
                        "type": "string",
                        "description": "Execution result"
                    }
                },
                "required": ["result"]
            }
        )

    async def execute(self) -> UiPathRuntimeResult:
        # Execute framework-specific agent invoke logic
        return UiPathRuntimeResult(
            output={"result": "success"},
            status=UiPathRuntimeStatus.SUCCESSFUL
        )

    async def stream(
        self,
    ) -> AsyncGenerator[UiPathRuntimeEvent, None]:
        # Stream events during execution for real-time monitoring
        yield UiPathRuntimeStateEvent(
            payload={"status": "starting"},
            execution_id=self.context.execution_id
        )

        # Yield final result
        yield UiPathRuntimeResult(
            output={"completed": True},
            status=UiPathRuntimeStatus.SUCCESSFUL
        )

    async def validate(self) -> None:
        # Validate configuration before execution
        if not self.context.entrypoint:
            raise UiPathRuntimeError(
                UiPathErrorCode.ENTRYPOINT_MISSING,
                "Missing entrypoint",
                "Detailed error message here",
                UiPathErrorCategory.USER,
            )

    async def cleanup(self) -> None:
        # Clean up resources after execution
        pass

Runtime Factory

The factory pattern handles runtime instantiation, instrumentation, and tracing:

from uipath.runtime import UiPathRuntimeFactory, UiPathRuntimeContext, UiPathRuntimeExecutor

factory = UiPathRuntimeFactory(MyCustomRuntime)

executor = UiPathRuntimeExecutor()

# Add OpenTelemetry instrumentation
executor.add_instrumentor(MyInstrumentor, get_current_span)

# Add span exporters for tracing
executor.add_span_exporter(JsonLinesFileExporter("trace.jsonl"))

# Execute
context = UiPathRuntimeContext(entrypoint="main.py", input='{"query": "hello"}')
async with factory.from_context(context):
    result = await executor.execute(runtime)

Event Streaming

Runtimes can stream events during execution for real-time monitoring:

async for event in executor.stream(runtime):
    if isinstance(event, UiPathRuntimeStateEvent):
        print(f"State update: {event.payload}")
    elif isinstance(event, UiPathRuntimeMessageEvent):
        print(f"Message: {event.payload}")
    elif isinstance(event, UiPathRuntimeResult):
        print(f"Completed: {event.output}")

Execution Context

Runtime context carries configuration and state throughout execution:

context = UiPathRuntimeContext(
    entrypoint="agent.py",
    input='{"query": "hello"}',
    job_id="job-123",
    resume=False,
)

Error Handling

Structured error handling with categorization:

from uipath.runtime.error import (
    UiPathRuntimeError,
    UiPathErrorCode,
    UiPathErrorCategory
)

raise UiPathRuntimeError(
    UiPathErrorCode.EXECUTION_ERROR,
    "Failed to execute agent",
    "Detailed error message here",
    UiPathErrorCategory.USER,
)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uipath_runtime-0.0.4.tar.gz (78.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uipath_runtime-0.0.4-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file uipath_runtime-0.0.4.tar.gz.

File metadata

  • Download URL: uipath_runtime-0.0.4.tar.gz
  • Upload date:
  • Size: 78.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for uipath_runtime-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2fab9512ca8f3c317c1b86d0dedc4e694bae671d1198d35a664aacd30ac794da
MD5 7bcf3d625cf651ffbd08385df66d0583
BLAKE2b-256 6e032cc1034e764a4708b75e98354f1abfedf51b0672dd7cef5c23d5f0c31f3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for uipath_runtime-0.0.4.tar.gz:

Publisher: cd.yml on UiPath/uipath-runtime-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file uipath_runtime-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: uipath_runtime-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for uipath_runtime-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0e90b2c5d51d1cab60f9736c9d2d514a71dc39fcc70e49bd60f255f74a80ceb4
MD5 f4274fbb8b49b98ae8d9e26b384ce094
BLAKE2b-256 c08e9cbcdb7d7a37297212155c714f3a1624208924d6f759549066674e673b9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for uipath_runtime-0.0.4-py3-none-any.whl:

Publisher: cd.yml on UiPath/uipath-runtime-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page