- Studio
- What is Mistral Workflows?
Migrate from SDK v3 to v4
Migrate from SDK v3 to v4
This page lists every change in Workflows SDK v4 (mistralai-workflows 4.x) that can break a v3 worker, with the change to make for each.
SDK v4 requires a Workflows API that serves the v2 event route with its token service. Mistral AI Studio supports it. Check a self-hosted platform before upgrading, as described in Events use only the v2 event route. A platform without the v2 event route must stay on SDK v3.
SDK v3 is deprecated and supported until 31 May 2027. Plan your upgrade before then.
Before you upgrade
Upgrade to SDK 3.19.0 or a later v3 release first. These releases emit a FutureWarning for most calls whose behavior changes in v4, so you can fix them while the identity in use stays the same. See Execution identity.
Then work through the sections below. Most changes fail fast at import, at worker startup, or with a TypeError. The sections on schedules, execution identity and events change runtime behavior and need a decision before you upgrade.
Dependencies
The Mistral AI plugin follows the SDK's major version. mistralai-workflows-plugins-mistralai v4 requires mistralai-workflows v4, and the SDK's mistralai extra installs plugin v4. Upgrade both in the same change:
# v3
uv add "mistralai-workflows[mistralai]>=3,<4"
# v4
uv add "mistralai-workflows[mistralai]>=4,<5"
If you pin mistralai-workflows-plugins-mistralai separately, raise that pin to v4 as well. The resolver rejects SDK v4 with plugin v3, and plugin v4 with SDK v3.
Other dependency changes:
- The webhook extra is removed. Remove it from your extras. [all] and [all-plugins] no longer include the webhook plugin.
- mistralai-workflows-plugins-evaluations 0.8.0 and later require SDK v4. Stay on 0.7.x with SDK v3. See Evaluations plugin.
- The SDK requires temporalio>=1.35.0,<1.38.0. SDK 3.17.1 to 3.20.0 required 1.35 only. Drop any pin of your own that excludes these versions.
ToolCallClient is now ConnectorClient
Plugin v4 removes ToolCallClient without an alias. Import ConnectorClient from the same module. Depends(slot) injects it, and call_tool(tool_name, arguments) keeps its signature:
# v3
from mistralai.workflows.plugins.mistralai.connectors import ToolCallClient
# v4
from mistralai.workflows.plugins.mistralai.connectors import ConnectorClient
ConnectorClient also adds mcp_client() and http_client(). See Connectors.
Display name and description removed from @workflow.define
@workflow.define no longer accepts workflow_display_name or workflow_description. They were only applied when the workflow was first registered, so code could not keep them in sync. Set them in AI Studio or with the Update Workflow API:
# v3
@workflows.workflow.define(
name="expense-report",
workflow_display_name="Expense Report",
workflow_description="Generate an expense report",
)
# v4
@workflows.workflow.define(name="expense-report")
curl -X PUT "https://api.mistral.ai/v1/workflows/expense-report" \
-H "Authorization: Bearer $MISTRAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"display_name": "Expense Report", "description": "Generate an expense report"}'
Use the workflow's registered name in the URL: if your worker sets WORKFLOW_NAME_PREFIX, the name includes that prefix. Existing workflows keep the display name and description they already have. A workflow registered for the first time shows its name until a display name is set.
Related changes:
- Every @workflow.define() argument after name is keyword-only. A v3 call that passed workflow_description by position, such as @workflow.define("x", "Some description"), raises TypeError: remove the description, as for the keyword form. Pass the arguments v4 keeps, such as execution_timeout or on_behalf_of, by keyword.
- get_workflow_definition() returns display_name and description as None. Read them from the API (GET /v1/workflows/{workflow_identifier}).
- get_workflow_display_name is removed from mistralai.workflows.core.definition.workflow_definition.
- WORKFLOW_EXECUTION_STARTED events from v4 workers have display_name set to null. Workers on SDK v3 and the TypeScript SDK still send it, so treat the field as optional and read a workflow's display name from the API.
schedules argument removed
The schedules argument of @workflow.define, deprecated since 3.8.0, is removed. Create schedules with the schedules API or in AI Studio. They no longer depend on worker code or restarts.
# v3
@workflows.workflow.define(
name="report-workflow",
schedules=[ScheduleDefinition(input={"report_type": "daily"}, cron_expressions=["0 9 * * *"])],
)
class ReportWorkflow: ...
# v4
@workflows.workflow.define(name="report-workflow")
class ReportWorkflow: ...
# From a deployment script, once a worker has registered the workflow
await client.workflows.schedules.schedule_workflow_async(
workflow_identifier="report-workflow",
deployment_name="production",
schedule_id="report-workflow-daily",
schedule=models.ScheduleDefinition(input={"report_type": "daily"}, cron_expressions=["0 9 * * *"]),
)
v4 workers send no schedules when they register. On Mistral AI Studio, upgrading to v4 leaves every existing schedule running, including the schedules your v3 workers declared and the schedules created or edited in AI Studio. To stop a schedule that v3 code declared, delete it in AI Studio or with the schedules API. Archiving the workflow also removes it. A v3 worker that registers again still replaces its deployment's declared schedules with the ones it declares, so remove schedules= from every v3 deployment, or upgrade them all.
The Schedule alias is removed from mistralai.workflows.core.workflow. Import Schedule from mistralai.workflows, or ScheduleDefinition from mistralai.workflows.models.
Route workflows by deployment name
SDK v4 removes TEMPORAL_TASK_QUEUE and config.temporal.task_queue. Set DEPLOYMENT_NAME instead. A v4 worker refuses to start without it, including when automatic configuration discovery is disabled. The worker ignores the old variable, and reading or assigning the removed Python field raises an error.
# v3
TEMPORAL_TASK_QUEUE=invoice-parser
# v4
DEPLOYMENT_NAME=invoice-parser
from mistralai.workflows import config
# v3
config.temporal.task_queue = "invoice-parser"
# v4
config.worker.deployment_name = "invoice-parser"
Use the same deployment name when you execute or schedule a workflow:
# v3
await client.workflows.execute_workflow_async(
workflow_identifier="parse-invoice", input=invoice, task_queue="invoice-parser"
)
await client.workflows.schedules.schedule_workflow_async(
workflow_identifier="parse-invoice", schedule=schedule, workflow_task_queue="invoice-parser"
)
# v4
await client.workflows.execute_workflow_async(
workflow_identifier="parse-invoice", input=invoice, deployment_name="invoice-parser"
)
await client.workflows.schedules.schedule_workflow_async(
workflow_identifier="parse-invoice", schedule=schedule, deployment_name="invoice-parser"
)
The mistralai Python and @mistralai/mistralai TypeScript clients still accept task_queue and workflow_task_queue (taskQueue and workflowTaskQueue), and still return task_queue on registration responses. These fields are deprecated: use deployment_name (deploymentName). The API treats them as deployment names, so they must identify an active deployment and match deployment_name when both are sent. Without a deployment_name, the API selects the only active deployment, and returns an error when several are active.
Other routing changes:
- config.get_effective_task_queue() no longer accepts raise_on_conflict. It returns DEPLOYMENT_NAME, or "default" when that is unset. Drop the argument.
- WorkflowSpecWithTaskQueue.task_queue is optional and deprecated, and can be None. The worker still fills it with the deployment name when it registers. Read the deployment name from config.worker.deployment_name or from a registration's deployment_name.
Workflows need a worker
In v3, calling execute_workflow() outside workflow code ran the workflow's entrypoint inline, without the orchestrator. v4 removes this: the call raises a WorkflowsException with code child_workflow_outside_workflow and status 400 before the workflow runs. Code that maps SDK errors to HTTP responses treats it as a caller error.
Call | v3 | v4 |
|---|---|---|
| execute_workflow() from workflow code | Child workflow | Unchanged |
| execute_workflow() anywhere else, including inside an activity | Entrypoint ran inline (wait=False already raised) | Raises child_workflow_outside_workflow |
| execute_activities_in_parallel() outside workflow code | Ran inline | Raises child_workflow_outside_workflow |
| Decorated workflow entrypoint called directly, such as await MyWorkflow().run(params) | Ran inline | Raises child_workflow_outside_workflow |
| Activity called directly | Ran in-process | Unchanged |
To run a workflow, start it on a worker and execute it through the API, as shown in Child workflows.
To run a workflow from a test, start it on an in-process worker with create_test_worker, over the test server that the SDK's pytest fixtures start. Install pytest and pytest-asyncio, then import the fixtures in conftest.py:
from mistralai.workflows.testing.fixtures import ( # noqa: F401
mock_upsert_search_attributes,
setup_test_config,
temporal_env,
)
# v3
result = await workflows.execute_workflow(GreetUserWorkflow, params=GreetParams(user_id="123"))
# v4
import pytest
from mistralai.workflows.testing import create_test_worker
@pytest.mark.asyncio
async def test_greet_user(temporal_env) -> None:
async with create_test_worker(temporal_env, workflows=[GreetUserWorkflow], activities=[fetch_user]):
result = await temporal_env.client.execute_workflow(
"greet-user", {"user_id": "123"}, id="test-greet-user", task_queue="test-task-queue"
)
assert result == {"result": "Hello, user-123"}
The client returns raw JSON: a primitive return value comes back as {"result": ...}. The first run downloads the test server into the system temp directory.
Direct activity calls keep their dependency injection, validation and client-side retries, which follow the activity's retry policy. One difference: an ApplicationError raised with non_retryable=True is no longer retried, matching Temporal. The setup_test_config fixture no longer sets config.worker.local_retry_backoff_coefficient to 0, so a test that calls a failing activity directly now waits between retries. Set the coefficient to 0 in the test or in your own fixture to keep it fast.
Events use only the v2 event route
SDK v3 workers published events over the v2 event route by default from 3.16.0, and fell back to the v1 route when the v2 route was unavailable. SDK v4 workers publish only over the v2 route and never fall back:
- EVENTS_API_VERSION is ignored. Remove it.
- config.worker.events_api_version is removed. Reading it raises AttributeError, and assigning it raises ValueError.
- EventsApiVersion and DEFAULT_EVENTS_API_VERSION are removed from mistralai.workflows.core.config.config. Importing either raises ImportError.
To check a platform before upgrading, run an SDK v3 worker on 3.16.0 or later with EVENTS_API_VERSION=v2-only. It publishes over the v2 route and raises instead of falling back, as SDK v4 does.
A publish that would have fallen back in v3 now fails:
Failure | Event sent from workflow code | Event sent from an activity |
|---|---|---|
| Client error (4xx) not listed in the next row, such as a 404 when the API has no v2 route | The workflow fails without retrying | The activity fails without retrying |
| Temporary error: a 5xx, 408 or 429, a timeout, or a 401 for an expired event-route token | Retried until it succeeds or the workflow reaches its execution timeout | Retried for up to a minute, then the attempt fails and the activity's retry policy applies |
The error is a temporalio ApplicationError with type == "WorkflowEventPublishFailed" (not an importable class) that names the event type and, when the API responded, the HTTP status. An event too large to publish (413) is dropped and logged as an error, and the workflow or activity continues.
Manual calls to EventContext.publish_events_batch() and publish_event() follow the same rules and no longer log and swallow publishing failures. Outside a workflow or activity, temporary failures retry for up to a minute before raising. Code that tolerates lost events must catch the failure itself.
A failed publish inside an activity can make the activity retry, including the work done before the publish. Make that work idempotent, and derive event IDs from stable activity inputs when consumers need to deduplicate.
Each manual publish from workflow code now runs an SDK activity and records it in the workflow history. Batch progress updates instead of publishing each streamed item, and use continue-as-new to bound history growth. Once a run has made such a publish, keep it on v4 workers until it finishes: a v3 worker cannot replay it.
Cancelled runs emit WORKFLOW_EXECUTION_CANCELED
A run cancelled while it awaits an activity or a child workflow now emits WORKFLOW_EXECUTION_CANCELED instead of WORKFLOW_EXECUTION_FAILED, matching the CANCELED status the run ends with. Consumers that detect cancellation from a FAILED event must handle CANCELED. The event carries the reason passed with the cancel request wherever the run was waiting.
ACTIVITY_TASK_* events are off by default
A v4 worker sends only WORKFLOW and CUSTOM_TASK events. ACTIVITY_TASK_STARTED, _COMPLETED, _RETRYING and _FAILED are off, so code that reads them from the event stream, including tests that assert on them, gets none. Turn them back on with the worker setting:
EMITTED_EVENT_CATEGORIES=WORKFLOW,CUSTOM_TASK,ACTIVITY
The list is exactly what the worker sends, and it must include CUSTOM_TASK: a worker without it refuses to start. A run keeps the WORKFLOW setting it started with. ACTIVITY follows the current setting of the worker that runs each activity, so changing it also affects runs in flight. See Emitted event categories.
In tests, pass the categories to EventContext:
from mistralai.workflows.core._events.event_context import EventContext
from mistralai.workflows.testing import ALL_EVENT_CATEGORIES
async with EventContext(publisher, emitted_event_categories=ALL_EVENT_CATEGORIES):
...
The EventContext constructor changed: its first argument is an event publisher, such as the one create_capturing_mock_event_publisher() returns, instead of an Events client. events_api_version is removed, and worker_client is keyword-only.
Custom workers and test helpers
run_worker, create_test_worker and create_test_worker_with_events register the activities the SDK schedules from workflow code. v4 adds new ones. A worker you build with temporalio.worker.Worker must register them too, or its workflows fail with "Activity function ... is not registered on this worker". Add get_internal_activities() instead of naming each activity:
from mistralai.workflows.testing import get_internal_activities
Worker(
client,
task_queue=queue,
workflows=workflows,
activities=[*my_activities, *get_internal_activities()],
)
Importing mistralai.workflows.testing no longer requires pytest, so a worker image without test dependencies can call get_internal_activities().
The event publisher test helper is renamed:
# v3
from mistralai.workflows.testing import create_capturing_mock_events_client
publisher = create_capturing_mock_events_client(captured_events)
# v4
from mistralai.workflows.testing import create_capturing_mock_event_publisher
publisher = create_capturing_mock_event_publisher(captured_events)
Execution identity
get_mistral_client(run_as=...) chooses the identity of each request. AUTO and EXECUTOR differ only outside on_behalf_of=True workflows:
run_as | In an on_behalf_of=True workflow | In any other workflow | Outside a workflow |
|---|---|---|---|
| RunAs.AUTO | Executing user | Deployment | Raises |
| RunAs.EXECUTOR | Executing user | Raises | Raises |
| RunAs.DEPLOYMENT | Deployment | Deployment | Deployment |
Every "Raises" is a non-retryable WorkflowError, raised before the request is sent. In an on_behalf_of=True workflow, AUTO and EXECUTOR also raise when the run has no user, for example when a schedule started it.
EXECUTOR is for Mistral clients only. Connectors accept "auto" and "deployment", and raise ValueError for "executor".
Version | Change |
|---|---|
| 3.17.0 | RunAs in mistralai.workflows.core.auth (named ConnectorRunAs in 3.15 and 3.16, now removed) |
| 3.19.0 | RunAs.EXECUTOR, and FutureWarnings on the identity APIs v4 removes and on requests whose identity changes in v4 |
| 4.0.0 | get_mistral_client() defaults to RunAs.AUTO, AUTO follows the running workflow's own declaration, and the deprecated APIs are removed |
None of these changes needs a platform upgrade.
Find affected calls with the 3.19.0 warnings
On 3.19.0 and later v3 releases, these calls emit a FutureWarning while keeping their v3 identity:
- get_mistral_client(use_executor_credentials=True): pass run_as=RunAs.EXECUTOR.
- should_use_executor_credentials(): pass run_as=RunAs.AUTO, after checking the cases below.
- use_executor_credentials_for() from the Mistral AI plugin's connectors: pass run_as to connector() or get_mistral_client().
- A request from get_mistral_client() without run_as, made without a workflow context or from an on_behalf_of=True workflow. In v4 it raises without a workflow context, and calls as the executing user in an on-behalf-of workflow. Pass run_as explicitly.
Fix every warning before moving to v4, with these exceptions:
- Workers authenticating with MISTRAL_API_HEADERS keep use_executor_credentials=should_use_executor_credentials() until v4. On v3, AUTO drops the configured headers even when it calls as the deployment.
- A child not declared on_behalf_of=True, started by an on-behalf-of parent, gets the on-behalf-of warning, which is wrong for it: v4 calls as the deployment there. Pass run_as=RunAs.DEPLOYMENT, which keeps the deployment on both v3 and v4.
use_executor_credentials replaced by run_as
Removed in v4 | Replacement |
|---|---|
| get_mistral_client(use_executor_credentials=True) | get_mistral_client(run_as=RunAs.EXECUTOR) |
| get_mistral_client(use_executor_credentials=False) | get_mistral_client(run_as=RunAs.DEPLOYMENT) |
| should_use_executor_credentials() | run_as=RunAs.AUTO |
| ConnectorRunAs | RunAs, from the same modules |
| use_executor_credentials_for() | connector(..., run_as=...), or get_mistral_client(run_as=...) with the same RunAs value |
from mistralai.workflows.client import get_mistral_client
from mistralai.workflows.core.auth import RunAs
# v3
client = get_mistral_client(use_executor_credentials=True)
client = get_mistral_client(use_executor_credentials=as_executor)
# v4
client = get_mistral_client(run_as=RunAs.EXECUTOR)
client = get_mistral_client(run_as=RunAs.EXECUTOR if as_executor else RunAs.DEPLOYMENT)
Map False to DEPLOYMENT explicitly, since v4 defaults to AUTO. Every get_mistral_client() argument after api_key is keyword-only, so a positional call raises TypeError.
Don't replace use_executor_credentials=True with AUTO. In a workflow not declared on_behalf_of=True, AUTO calls as the deployment where the old flag raised, so code that must act as the user, such as reading their resources, acts as the deployment instead.
AUTO replaces use_executor_credentials=should_use_executor_credentials() except in two cases:
- No workflow context. The old pattern called as the deployment, and AUTO raises. This covers code outside a workflow and activities on a worker without the SDK's ContextHandlerInterceptor: run_worker() installs it, and create_test_worker installs it only if you pass interceptors=[ContextHandlerInterceptor()].
- A client built outside an activity, such as at module level, at worker startup, or in a shared Depends. The old flag was fixed when the client was built, so such a client always called as the deployment. AUTO decides on each request, so it calls as the executing user inside an on_behalf_of=True workflow.
In both cases, pass run_as=RunAs.DEPLOYMENT.
get_mistral_client() defaults to RunAs.AUTO
In v4, a request from get_mistral_client() without run_as:
- Raises without a workflow context, with WorkflowError("run_as=AUTO requires a workflow context ..."). This affects requests at worker startup, in scripts, in test setup, and in activities called directly.
- Calls as the executing user in an on_behalf_of=True workflow, instead of the deployment.
- Calls as the deployment in any other workflow, as before.
Pass run_as=RunAs.DEPLOYMENT where the deployment identity is meant:
# Worker startup
async def main() -> None:
await get_mistral_client(run_as=RunAs.DEPLOYMENT).models.list_async()
await workflows.run_worker([ReportWorkflow])
# Scripts
client = get_mistral_client(api_key=os.environ["MISTRAL_API_KEY"], run_as=RunAs.DEPLOYMENT)
# Test setup
@pytest_asyncio.fixture
async def mistral_client(server_url: str) -> AsyncGenerator[Mistral, None]:
async with get_mistral_client(server_url=server_url, run_as=RunAs.DEPLOYMENT) as client:
yield client
AUTO follows the running workflow's own on_behalf_of
In v3, a child workflow took its on_behalf_of flag from its parent. In v4, an execution takes the flag from its own workflow's declaration when it starts. This affects every request that resolves AUTO: clients created with run_as=RunAs.AUTO, connectors, whose run_as defaults to "auto", and the Mistral AI plugin's activities.
Parent | Child | v3 | v4 |
|---|---|---|---|
| on_behalf_of=True | Not declared | Requested the user's identity, which the API refuses for a workflow not declared on-behalf-of, so requests failed | Calls as the deployment |
| Not declared | on_behalf_of=True | Called as the deployment on older APIs; current APIs refuse it for v3 workers too | The Workflows API refuses to start the child |
The Workflows API refuses an on-behalf-of child whose parent does not run on behalf of a user, with a 403 "On-behalf-of workflows cannot be started by a workflow that does not run on behalf of a user". The check is on the server, so SDK v3 workers get the same refusal. A run that continues as new into a different workflow declared on_behalf_of=True is refused the same way, with a 403 "On-behalf-of workflows cannot continue an execution that does not run on behalf of a user".
Before upgrading, find parent and child workflows whose declarations differ:
- A child not declared on-behalf-of, started by an on-behalf-of parent. Its AUTO requests use the deployment's credentials and MISTRAL_API_HEADERS, as run_as=RunAs.DEPLOYMENT does. These headers are not forwarded on cross-origin redirects. Check that the deployment is allowed to make them, or declare the child on_behalf_of=True to call as the user.
- An on-behalf-of child of a parent not declared on-behalf-of. Remove on_behalf_of=True from the child to call as the deployment, or declare the parent on_behalf_of=True too if every run of the parent has a user.
# Started by a schedule, so its runs have no user.
@workflows.workflow.define(name="nightly-report")
class NightlyReport:
@workflows.workflow.entrypoint
async def run(self) -> None:
await workflows.execute_workflow(SummarizeInbox, SummarizeParams())
# v3 on an older API: AUTO requests in this child called as the deployment.
# v4: the API refuses to start this child, because its parent does not run on behalf of a user.
@workflows.workflow.define(name="summarize-inbox", on_behalf_of=True)
class SummarizeInbox: ...
# v4: remove the declaration to keep calling as the deployment.
@workflows.workflow.define(name="summarize-inbox")
class SummarizeInbox: ...
A changed on_behalf_of declaration applies only to executions started after the redeploy. A run started by continue-as-new, a retry or a cron run keeps the flag its execution started with. Runs started by SDK v3 workers have no recorded flag: after the upgrade, their remaining requests use the declaration in the deployed code, so an in-flight child whose declaration differs from its parent's changes identity at the upgrade.
run_worker stops the worker on SIGTERM
In v3, run_worker did not handle SIGTERM. As PID 1 in a container, the worker ignored it until SIGKILL. Under an init process such as tini, it died at once without stopping the worker.
In v4, run_worker stops the worker on SIGTERM. It stops polling, gives running activities up to GRACEFUL_SHUTDOWN_TIMEOUT_SECONDS (default 25) to finish, cancels the rest, flushes telemetry and returns None. The process then exits normally. A fatal worker error or Ctrl+C also waits up to that time for running activities. After Ctrl+C, run_worker raises KeyboardInterrupt instead of returning. In v3 the default was 0, which cancelled running activities at once.
Set GRACEFUL_SHUTDOWN_TIMEOUT_SECONDS a few seconds below your delay between SIGTERM and SIGKILL (Kubernetes gives a pod 30 seconds by default), so the telemetry flush can finish. Set it to 0 to cancel running activities at once. A SIGTERM during startup lets startup finish, registration retries included, then run_worker returns None without polling.
An activity cancelled at the end of the drain fails its attempt with a retryable WorkerShutdown error, and Temporal retries it on another worker if its retry policy allows. An activity with maximum_attempts=1 therefore fails. Give such activities retries, or let a long activity wait on activity.wait_for_worker_shutdown() and finish before the drain ends.
run_worker takes SIGTERM only when no other handler owns it, the same rule asyncio.run applies to SIGINT:
- If a SIGTERM handler is already installed when run_worker starts, such as one from your code, a tracer like ddtrace or a framework wrapper, that handler stays and run_worker does not stop on SIGTERM.
- Several attached run_worker calls in one process share one handler, and one SIGTERM stops them all.
- run_worker(detach=True) never installs a handler. On Windows, or outside the main thread, run_worker does not handle SIGTERM.
When a detached worker stops on a terminal error, such as a refused registration, run_worker(detach=True) raises the WorkflowsException to the caller. v3 exited the process. Code that embeds a detached worker must handle the exception.
If you run other long-lived tasks next to run_worker, stop them when it returns. Otherwise the process keeps running after the worker stops:
server = asyncio.create_task(serve_http())
try:
await workflows.run_worker([MyWorkflow])
finally:
server.cancel()
Configuration
v4 also accepts the worker configuration in code: pass a WorkflowsConfig to run_worker(). See Configuring a worker in code.
Payload and storage settings read only nested names
In v3, once a payload or blob storage config was set through its nested names, bare names in the environment filled its missing fields: MAIN_KEY, SECONDARY_KEY and MODE for encryption, BUCKET_NAME, ENDPOINT_URL, PREFIX and the other storage fields for blob storage and offloading, and MIN_SIZE_BYTES for offloading and compression. An unrelated MAIN_KEY could become the encryption key. v4 reads only the nested names, such as TEMPORAL_PAYLOAD_ENCRYPTION__MAIN_KEY or BLOB_STORAGE_CONFIGS__<NAME>__BUCKET_NAME. A worker that relied on a bare MAIN_KEY fails at startup with "You must configure payload encryption key". S3 credentials in AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY still apply.
Explicit worker headers replace inherited ones
WorkerConfig(mistral_api_headers=...) and WorkerConfig(mistral_api_header_files=...) now replace every inherited entry for that field, including those from environment variables, dotenv files and settings secrets. Previously the entries were merged, so even an explicit {} kept inherited headers. {} now clears the mapping, as None already did. If you passed some headers in code and relied on the platform injecting others, such as Authorization through MISTRAL_API_HEADERS, pass the complete mapping. The worker logs a warning naming each inherited header an explicit mapping drops.
WorkerVersioningConfig(auto_register_as_current=...) set in code now overrides WORKER_AUTO_REGISTER_AS_CURRENT from the environment and dotenv files. Controller-managed workers still never promote their own version.
MISTRAL_API_HEADER_FILES also shipped in SDK 3.20.0. It maps a header name to a file the worker re-reads, such as a rotating service-account token: {"<header name>": "<file path>"}. From 3.20.0, the worker also sends the headers from MISTRAL_API_HEADERS and MISTRAL_API_HEADER_FILES on its Temporal connection, so check that your Temporal endpoint, or a proxy in front of it, accepts them.
Decorator settings are resolved at worker startup
Importing the SDK and declaring workflows no longer reads decorator settings such as WORKFLOW_NAME_PREFIX, DEFAULT_ENFORCE_DETERMINISM and VERSIONING. run_worker or prepare_workflows resolves them when the worker starts. Code that reads workflow names before run_worker, such as a startup log or a discovery step, gets the declared name without WORKFLOW_NAME_PREFIX. Read names inside prepare_workflows, or apply the prefix from your resolved WorkflowsConfig. Invalid values still fail at startup.
Running one workflow type on the same task queue and deployment version with two different configurations in one process now raises a WorkflowsException with code workflow_definition_error. Give the workers different deployment names, or run them in separate processes.
Telemetry and logging
OTEL_ENDPOINT removed
The OTEL_ENDPOINT variable and the config.common.otel_endpoint field are removed. Code that reads or sets the field raises an error. A worker that still sets the variable logs a warning and exports every signal without its own endpoint to Mistral instead of your collector. Set the per-signal endpoints:
# v3
OTEL_ENDPOINT=http://collector:4318
# v4
OTEL_TRACES_ENDPOINT=http://collector:4318
OTEL_METRICS_ENDPOINT=http://collector:4318
OTEL_LOGS_ENDPOINT=http://collector:4318
See Observability for authenticating custom endpoints.
The SDK no longer sets OTLP environment variables
In v3, loading the SDK's configuration set OTEL_EXPORTER_OTLP_CERTIFICATE from CA_BUNDLE, and OTEL_EXPORTER_OTLP_HEADERS to Authorization=Bearer <MISTRAL_API_KEY>, for the whole process. Every OTLP exporter in the process read them, including your own OpenTelemetry setup. v4 passes the CA bundle and the Mistral key to its own exporters only. If your exporters relied on these variables, set them yourself. When you set them, the SDK's exporters use your certificate instead of CA_BUNDLE and also send your headers, including to the default Mistral ingest, where the SDK still sets Authorization to the Mistral credential.
OTEL_REDACTION also applies to exported logs
In v3, OTEL_REDACTION only redacted spans. In v4 it also applies to the log records the worker exports over OTLP:
- default: secrets and PII are scrubbed from the string values of log bodies and attributes. JSON bodies stay valid JSON.
- strict: the whole log body is replaced with {"event": "[REDACTED]"}, and wf.result is masked on spans.
- none: logs and spans are exported unredacted, as v3 exported logs.
Console logs are not affected.
Independently of OTEL_REDACTION, v4 masks credential values found in the environment, such as MISTRAL_API_KEY and credential headers in MISTRAL_API_HEADERS, in console and exported log events. none turns this off for exported logs only.
SDK logs no longer include error messages
SDK log events no longer contain exception messages, API response bodies, tracebacks, task state or custom trace-event attributes. extract_error_context() no longer returns error_message, api_error_body or api_error_message. Search logs on error_type, error_chain, http_status and api_error_code instead.
Importing the SDK no longer configures logging
SDK 3.17.0 already includes this change. Before 3.17.0, importing mistralai.workflows replaced the root logger's handlers, applied LOG_LEVEL and LOG_FORMAT, and set httpx, httpcore, asyncio, aiocache and urllib3 to WARNING. Now run_worker sets up logging when the worker starts:
When run_worker starts | Result |
|---|---|
| Nothing is configured | The SDK installs its console handler and applies LOG_LEVEL, LOG_FORMAT and the library levels, as the import did before. |
| Standard library logging is configured | SDK events go through your handlers as text. LOG_LEVEL, LOG_FORMAT and the library levels don't apply. |
| structlog is configured | The SDK does nothing. |
A worker that calls run_worker without configuring logging logs as before. A script that imports the SDK without running a worker prints only warnings and errors until logging is configured: configure it yourself, or call setup_default_logging():
from mistralai.workflows.core.config.config import setup_default_logging
setup_default_logging()
Full payload encryption encrypts failure messages
SDK 3.17.0 already includes this change. With TEMPORAL_PAYLOAD_ENCRYPTION__MODE=full, failure messages and stack traces are encrypted, and failure events carry only the error type, such as ValueError. Workflow code and clients holding the key still read the full message. AI Studio shows "Encoded failure". Code that parses failure messages without the key must use the error type instead. See Encryption.
Removed APIs
Removed | Replacement |
|---|---|
| mistralai.workflows.client.get_async_client() | get_mistral_client() for Mistral API calls |
| from mistralai.workflows.plugins.mistralai import Mistral | from mistralai.client import Mistral |
| apply_worker_runtime_config(api_key=...) | apply_worker_runtime_config(): authentication resolves through the token provider |
| AsyncExecutorCredentialsHook(server_url=..., api_key=...), same for SyncExecutorCredentialsHook | AsyncExecutorCredentialsHook(server_url=..., token_provider=...) |
| A positional second argument (api_key in v3) on AsyncExecutorCredentialsHook or SyncExecutorCredentialsHook | Pass token_provider= by keyword: a positional second argument raises TypeError |
from mistralai.workflows.core.auth import StaticTokenProvider
from mistralai.workflows.hooks.executor_credentials_hook import AsyncExecutorCredentialsHook
hook = AsyncExecutorCredentialsHook(server_url="https://api.mistral.ai", token_provider=StaticTokenProvider("..."))
The identity APIs removed in v4 are listed in use_executor_credentials replaced by run_as.
Evaluations plugin
From mistralai-workflows-plugins-evaluations 0.8.0, which requires SDK v4, the plugin's calls use RunAs.AUTO: the executing user in an on_behalf_of=True workflow, the deployment otherwise. run_worker() installs the interceptor that provides the workflow context, so deployed workers are unchanged. Without it, the plugin fails without retrying instead of using the deployment's credentials. In tests on create_test_worker, pass the interceptor:
from mistralai.workflows.core.temporal.context_handler_interceptor import ContextHandlerInterceptor
from mistralai.workflows.testing import create_test_worker
async with create_test_worker(
temporal_env,
workflows=[MyEvalWorkflow],
activities=[...],
interceptors=[ContextHandlerInterceptor()],
):
...
A plugin activity called directly, outside any workflow, has no context: start the evaluation workflow on a worker instead. The SDK's evaluations extra now installs plugin 0.8.0 or later, which can cross other breaking plugin releases listed in the plugin's changelog.