Skip to main content

Working with Workflow

Workflow in Credo AI consists of two parts: Workflow Stages that define the governance pipeline, and Use Case Workflow that tracks each use case's progress through that pipeline.

Workflow Stages

Workflow stages define the governance pipeline that use cases progress through. The system includes fixed start and end stages, with customizable intermediate stages.

Listing Workflow Stages

from credoai import CredoAI

client = CredoAI()

response = client.workflow_stages.list()
for stage in response.items:
print(f"{stage.name} (ID: {stage.id})")

Creating an Intermediate Stage

Only intermediate workflow stages can be created via the API. Start and end stages are system-managed.

from credoai import WorkflowStageCreate

stage = client.workflow_stages.create(
data=WorkflowStageCreate(
name="Security Review",
)
)
print(f"Created: {stage.id}")

Updating a Stage

Start and end stages cannot be modified via the API.

from credoai import WorkflowStageUpdate

updated = client.workflow_stages.update(
workflow_stage_id="ws_abc123",
data=WorkflowStageUpdate(name="Updated Stage Name"),
)

Deleting a Stage

Start and end stages cannot be deleted via the API.

client.workflow_stages.delete(workflow_stage_id="ws_abc123")

Use Case Workflow

Each use case has a workflow that tracks its progress through the governance pipeline. The workflow has both a current stage and a current step within that stage.

Step progression within each stage: assessment -> evidence_collection -> clear

Getting Workflow Status

use_case = client.use_cases("uc_abc123")

workflow = use_case.workflow.get()
print(f"Current stage: {workflow.stage}")
print(f"Current step: {workflow.step}")

Updating Workflow

from credoai import UseCaseWorkflowUpdate

use_case = client.use_cases("uc_abc123")

updated = use_case.workflow.update(
data=UseCaseWorkflowUpdate(stage_id="ws_abc123"),
)

Advancing the Step

Move to the next step within the current workflow stage:

use_case = client.use_cases("uc_abc123")

# Advance: assessment -> evidence_collection -> clear
result = use_case.workflow.advance_step()
print(f"New step: {result.step}")

Advancing the Stage

Move to the next workflow stage, resetting to the assessment step:

use_case = client.use_cases("uc_abc123")

result = use_case.workflow.advance_stage()
print(f"New stage: {result.stage}")

Rejecting a Use Case

Set the use case's workflow step to rejected. This is a terminal state.

use_case = client.use_cases("uc_abc123")

result = use_case.workflow.reject()
print(f"Step: {result.step}") # "rejected"

Next Steps