Overview
TheWorkflow class manages the lifecycle of a NovaAct workflow, including creating workflow runs, managing backend connections, and handling authentication with AWS services.
Constructor
Create a new Workflow instance.Parameters
The model ID to use (e.g., “nova-act-latest”). For valid values of
model_id, see the model version selection guide.Optional kwargs to pass to
boto3.Session() for AWS authentication. If not provided and no API key is given, credentials will be automatically loaded from environment variables (AWS_PROFILE, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc.), or default to {"region_name": "us-east-1"}.Required when using
boto_session_kwargs. The name of the workflow definition. When using nova_act_api_key, a default name is used automatically.Optional botocore Config for the boto3 client.
Optional CloudWatch log group name for workflow logs. Only supported when using
boto_session_kwargs.Optional API key for authentication. Cannot be used with
boto_session_kwargs. If used, workflow_definition_name is ignored and a default name is used.Authentication Methods
Two authentication methods are supported:- AWS IAM credentials (via
boto_session_kwargs) - API key (via
nova_act_api_key)
Usage
As a Context Manager
With the @workflow Decorator
The@workflow decorator provides a convenient way to manage workflow context automatically.
@workflow Decorator
Decorate a function to manage it as a NovaAct Workflow. This decorator wraps a function to automatically create and manage a Workflow context.Decorator Parameters
The model ID to use (e.g., “nova-act-latest”).
Optional kwargs to pass to boto3.Session() for AWS authentication.
Required when using boto_session_kwargs. The name of the workflow definition.
Optional botocore Config for the boto3 client.
Optional CloudWatch log group name for workflow logs. Only supported when using boto_session_kwargs.
Optional API key for authentication. Cannot be used with boto_session_kwargs.
Properties
workflow_definition_name
Get the workflow definition name.The workflow definition name.
workflow_run_id
Get the workflow run ID.The workflow run ID.
Raises
ValueError if the workflow has not been started (not in context).workflow_run
Get the WorkflowRun DTO for this workflow.The WorkflowRun instance if the workflow is active, None otherwise.
backend
Get the workflow backend instance.The workflow backend instance (StarburstBackend or SunburstBackend).
Helper Functions
get_current_workflow()
Get the current workflow for the execution context.The current Workflow instance, or None if not in a workflow context.
Examples
AWS IAM Authentication
API Key Authentication
Using Environment Variables
With @workflow Decorator
Error Handling
The Workflow class automatically updates the workflow run status based on execution:- SUCCEEDED: No exception occurred during execution
- FAILED: An exception was raised during execution