CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 4 · Lesson 39/56

    CI/CD for agents: bundles, index updates, prompt promotion and testing

    Apply CI/CD best practices such as updating a Vector Search index, promoting prompts across environments, and testing individual components of an agent.

    18 min read
    1.47% of exam
    8 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Define an agent's resources in a Declarative Automation Bundle and deploy it per environment with validate, deploy and run
    • Add the right Vector Search update step to a pipeline for Triggered, Continuous and Direct Vector Access indexes
    • Promote a prompt version from dev to staging to production by reassigning aliases, and roll it back by moving the alias back
    • Arrange unit, integration and canary tests so each one catches a different agent failure

    Key concept

    Parameterize, don't hardcode — The same bundle, agent code and prompt reference are deployed to dev, staging and production. Whatever differs between environments comes from bundle targets, variables or prompt aliases, so promoting a change means moving a pointer or picking a target, not editing code.

    1.Deploying an agent as a bundle per environment

    A CI/CD pipeline sends every change to an agent through code review and an automated deploy, so a production rollout never depends on one developer's laptop. For an agent on Databricks Apps, once the pipeline is set up, every merge to the main branch deploys and restarts the agent. An agent is more than its Python code, though. It also needs an MLflow experiment, often a Lakebase database for memory, a prompt in the registry and a Vector Search index. A pipeline that ships only the code leaves all of those to be set up by hand.

    Declarative Automation Bundles (formerly Databricks Asset Bundles) solve this by declaring code, jobs and infrastructure in one YAML file, databricks.yml, and deploying them as a single unit. Each environment is a target in that file. Databricks recommends separate workspaces for development, staging and production, one repository for code and bundle configuration, trunk-based branching, and versioned artifacts such as Git commit hashes so every deployment can be traced and rolled back. CI authenticates as a service principal, and workload identity federation is the recommended method because it removes the need for stored Databricks secrets.

    The deploy job runs the same short sequence for every target:

    1. Run unit tests on the pull request or on the commit to main.
    2. Run databricks bundle validate to catch misconfigurations, such as missing libraries, before anything is deployed.
    3. Run databricks bundle deploy --target prod to create or update the declared resources.
    4. Run databricks bundle run <bundle-key> --target prod to start the agent app. The key must match the resource key in databricks.yml.
    5. Wait for the app to report healthy, then send a smoke-test request.

    Two agent-specific failures show up the first time this runs on a fresh CI runner. First, agent templates leave MLFLOW_EXPERIMENT_ID empty in databricks.yml. The quickstart script fills it in on a developer's machine, but a CI runner does not, so bundle deploy fails with a Terraform type error: For input string: "". The fix is to commit the numeric experiment ID. Experiments are scoped to a workspace, so a pipeline that deploys to several workspaces needs a separate experiment in each targets.<env> block, or a bundle variable. Second, the advanced templates declare a Lakebase Postgres resource, which bundle deploy provisions. The app's service principal still needs Postgres-level grants on its memory tables. Those grants are a one-time step, run between the first deploy and the first run. After that, CI redeploys go straight through deploy and then run.

    Checkpoint 1 of 6· Put it in order

    A CI pipeline deploys an advanced agent template, which declares a Lakebase Postgres resource for memory, to a new production workspace for the first time. Put the steps in order.

    1. 1.Run databricks bundle validate to catch misconfigurations before anything is deployed
    2. 2.Run databricks bundle deploy --target prod to create the declared resources, including the Lakebase database
    3. 3.Run databricks bundle run <bundle-key> --target prod to start the agent app
    4. 4.Wait for the app to report healthy, then send a canary request to /invocations
    5. 5.Grant the app's service principal Postgres-level privileges on its memory tables

    Sources12

    2.Updating the Vector Search index in the pipeline

    A retriever can only be as current as its index, and a deployment that changes the source table hasn't finished until the index reflects that change. A Delta Sync index follows its source table through the table's change feed, so a pipeline that writes the table depends on Enabling Change Data Feed so a Delta Sync index can follow the table having been done when the table was created. What happens after the write depends on the sync mode, compared in Triggered vs continuous sync. A Continuous index updates by itself when the source changes. A Triggered index waits until someone or something starts a sync, so in CI/CD that sync has to be an explicit pipeline step.

    Sync step for a Triggered Delta Sync index, using the Python SDKpython
    client = AISearchClient()
    index = client.get_index(index_name="vector_search_demo.vector_search.en_wiki_index")
    
    index.sync()

    The same step is available as POST /api/2.0/vector-search/indexes/{index_name}/sync or as the CLI command databricks vector-search-indexes sync-index my-delta-sync-index, which fits a shell step in a workflow file. The CLI rejects any other index type: the index to synchronize must be a Delta Sync index. Infrastructure changes need the sync step too. After a pipeline raises an endpoint's target QPS with update_endpoint(), the indexes have to be synced before the new configuration takes effect.

    Two shortcuts are wrong. Deleting and recreating the index on every run replaces a single sync call with a full rebuild. Editing the index's storage directly is also off-limits: a Delta Sync index keeps its data in a Unity Catalog table that you can query, but must not drop or modify. To change the index, change the source table and sync.

    A Direct Vector Access index has no source table to follow. When embeddings come from a model outside Databricks, the pipeline computes the vectors and writes them, along with their metadata, into the index itself, using the SDK's index.upsert() or the REST API to insert, update or delete rows. Use this type when the team doesn't want a synced Delta table as the source of truth. In exchange, keeping the index current is entirely the pipeline's job.

    CI step that upserts externally computed vectors into a Direct Vector Access indexbash
    databricks vector-search-indexes upsert-data-vector-index my-index '{"vectors": [{"id": "1", "vector": [0.1, 0.2, 0.3], "metadata": {"title": "Document 1"}}]}'
    Which pipeline step keeps each index type current
    Index setupWhat the pipeline does after data changesCall
    Delta Sync, ContinuousNothing extra: the index updates when the source table changesNone
    Delta Sync, TriggeredWrites the source table, then starts a syncindex.sync() or POST /api/2.0/vector-search/indexes/{index_name}/sync
    Direct Vector AccessWrites vectors and metadata into the index itselfindex.upsert()

    Checkpoint 2 of 6· Exam question

    A nightly ETL job appends newly ingested documents to a Delta table that backs a Delta Sync Vector Search index. The team wants the index to reflect the new rows within minutes of the ETL job finishing, but does not want a streaming pipeline running continuously between batches. Which CI/CD configuration best satisfies this requirement?

    Checkpoint 3 of 6· Exam question

    A team computes document embeddings using a custom model hosted outside Databricks and wants a CI/CD job to push the newly computed vectors and metadata into a production Vector Search index after every build, without maintaining a synced Delta table as the source of truth. Which approach fits this requirement?

    Sources34

    3.Promoting and rolling back prompts with aliases

    A prompt moves through environments differently from code. A deployed agent loads its prompt through an alias such as @production, as taught in Prompt aliases and loading by alias. Promotion then needs no build and no redeploy: the pipeline reads which version the source environment's alias points to and points the target environment's alias at the same version. This works because the two objects behave differently. Prompt versions are immutable snapshots with auto-incrementing numbers, while aliases are mutable pointers. What staging tested is exactly what production will load.

    Promotion step: give the target environment's alias the same version as the source'spython
    def promote_prompt(name: str, from_env: str, to_env: str):
        """Promote prompt from one environment to another."""
    
        # Get current version in source environment
        source = mlflow.genai.load_prompt(f"prompts:/{name}@{from_env}")
    
        # Point target environment to same version
        mlflow.genai.set_prompt_alias(
            name=name,
            alias=to_env,
            version=source.version
        )
    
        print(f"Promoted {name} v{source.version} from {from_env} to {to_env}")

    In a pipeline, this becomes two gated calls. When work merges, dev is pointed at the new version. When staging is approved, promote_prompt(name, "dev", "staging") runs. When production is approved, promote_prompt(name, "staging", "production") runs. Re-registering the same text produces a new version number, and copying prompt text into an environment variable or a file bypasses the registry. Both add something untested and lose the link to what was validated.

    Rollback works the same way in reverse: point the alias back at an earlier version. To make that a one-line call, record the outgoing version under its own alias before moving production. If the new prompt misbehaves, set production to the version held by production-previous. Every version is still there, so nothing has to be restored. Even delete_prompt_alias() removes only the pointer, never the versions.

    Rollback-ready production update that saves the outgoing version under production-previouspython
    def safe_production_update(name: str, new_version: int):
        """Update production with rollback capability."""
        try:
            # Save current production
            current = mlflow.genai.load_prompt(f"prompts:/{name}@production")
            mlflow.genai.set_prompt_alias(name, "production-previous", current.version)
        except:
            pass  # No current production
    
        # Update production
        mlflow.genai.set_prompt_alias(name, "production", new_version)

    Two details matter when this runs in production. First, keep the prompt name and alias in environment variables, so each environment's deployment chooses its alias without a code change. Second, an agent deployed as a Custom Agent cannot reach the prompt registry through its default setup. It must use manual authentication, overriding the security environment variables so the Databricks client connects to the registry with credentials you configure. That override has a side effect: it disables automatic passthrough, the mechanism that otherwise supplies credentials for the other resources the agent depends on. With passthrough off, those resources no longer get credentials automatically, so a resource that worked before the override can start failing authentication until you configure access for it as well. For traceability, call mlflow.set_active_model() with a name built from the Git commit before loading the prompt. MLflow then records which prompt version each application version used, which is the first thing to check when a rollback is being considered.

    Checkpoint 4 of 6· Check yourself

    Right after the pipeline moved the production alias from version 4 to version 5, answer quality drops. Before the move, the pipeline saved version 4 under the production-previous alias. What is the quickest correct rollback?

    Checkpoint 5 of 6· Exam question

    A team stores its agent's system prompt in the MLflow Prompt Registry and loads it in production code using the URI prompts:/catalog.schema.answer_prompt@production. After validating a new prompt version in staging, they need to promote it to production as part of their CI/CD pipeline without changing or redeploying the application code. Which action accomplishes this?

    Sources567

    4.Testing agent components from unit to canary

    An agent fails in layers. A tool might parse a date wrongly, the retriever might return the wrong chunks, the assembled agent might call the right tools in the wrong order, or the deployed app might never finish booting. A single end-to-end test catches all of these but can't tell you which one happened. So the pipeline tests each layer separately, cheapest first, in the environment where that layer can actually be checked.

    Test layers for an agent and where each runs in the pipeline
    LayerWhat it checksWhere it runsMechanism
    UnitA single tool function or retriever helper, called directly with fixed inputsCI runner, on every pull requestpytest
    ConfigurationBundle definition: resources, libraries, targetsCI runner, before deploydatabricks bundle validate
    IntegrationThe full agent working against real endpoints, indexes and promptsStaging workspace after bundle deployEvaluation dataset compared against the previous version
    CanaryThe deployed app answers a real request after it bootsTarget environment after bundle runPOST to /invocations with an OAuth token

    Unit tests treat each tool and retriever as ordinary business logic and test it with pytest, without starting the agent. They are fast enough to run on every pull request. Integration testing follows the standard ML flow: code is deployed to a staging workspace and tested there, and only vetted artifacts are promoted. For an agent, the integration check is an evaluation run over a fixed dataset, so the new version is measured against the old one and a fix in one area can't quietly cause a regression in another. Building and scoring those datasets is covered in Evaluating agents with MLflow scoring and tracing.

    The canary step exists because databricks bundle run reports success too early. It returns as soon as the runner tells the agent to start, but the agent process can still crash while booting, for example on a missing Postgres grant. So after the health check passes, the workflow sends a real request to /invocations and fails the job on anything other than HTTP 200. The token must be the workspace OAuth token from databricks auth token, because Databricks Apps reject every other token type. A canary that uses a personal access token fails even when the agent is healthy.

    Smoke-test step in deploy.yml that posts a canary request to the deployed agentyaml
    - name: Smoke test invocations
      env:
        APP_NAME: my-agent
      run: |
        APP_URL=$(databricks apps get "$APP_NAME" --output json | jq -r '.url')
        TOKEN=$(databricks auth token | jq -r '.access_token')
        STATUS=$(curl -sS -o /tmp/canary.json -w "%{http_code}" \
          -X POST "$APP_URL/invocations" \
          -H "Authorization: Bearer $TOKEN" \
          -H "Content-Type: application/json" \
          -d '{"input": [{"role": "user", "content": "ping"}], "stream": false}')
        if [ "$STATUS" != "200" ]; then
          echo "Smoke test failed with status $STATUS:" >&2
          cat /tmp/canary.json >&2
          exit 1
        fi
        echo "Smoke test passed."

    A failed canary should start a rollback, not just send an alert. Databricks recommends tracking deployment success rates and automating rollback when a deployment fails. Each kind of change already has a cheap way back: redeploy the bundle from the previous commit for code, or point the alias back for a prompt. Prompt aliases also allow a gentler canary. Because aliases are mutable references, the registry supports A/B tests and gradual rollouts in which a new prompt version serves part of the traffic under its own alias before production is moved.

    Checkpoint 6 of 6· Check yourself

    In a deploy job, databricks bundle run --target prod exits with success. Moments later the agent process crashes while booting because its service principal has no Postgres grant on the memory tables. Which pipeline step is meant to catch this failure?

    Sources2816

    Sources

    (8)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Once the pipeline is configured, every merge to your main branch deploys and restarts your agent on Databricks Apps.”
      ↩︎ Deploying an agent as a bundle per environment
      “If experiment_id is empty, databricks bundle deploy fails with a Terraform type error”
      ↩︎ Deploying an agent as a bundle per environment
      “Granting these Postgres-level privileges is a one-time setup.”
      ↩︎ Deploying an agent as a bundle per environment
      “add the following smoke-test step to deploy.yml that posts a canary request to /invocations”
      ↩︎ Testing agent components from unit to canary
      “Databricks Apps only accept OAuth tokens for invocation.”
      ↩︎ Testing agent components from unit to canary
      “databricks bundle run returns as soon as the runner signals the agent to start, but the agent process may still fail during boot.”
      ↩︎ Exam trap 4
      “Granting these Postgres-level privileges is a one-time setup. Run it locally between the first bundle deploy and bundle run.”
      ↩︎ Checkpoint
      “databricks bundle run returns as soon as the runner signals the agent to start, but the agent process may still fail during boot.”
      ↩︎ Checkpoint
    2. 2.
      “Use Declarative Automation Bundles to deploy code, jobs, and infrastructure as a single unit.”
      ↩︎ Deploying an agent as a bundle per environment
      “Declarative Automation Bundles (formerly known as Databricks Asset Bundles)”
      ↩︎ Deploying an agent as a bundle per environment
      “Maintain separate workspaces for development, staging, and production.”
      ↩︎ Deploying an agent as a bundle per environment
      “Databricks recommends workload identity federation for CI/CD authentication.”
      ↩︎ Deploying an agent as a bundle per environment
      “Implement unit tests for business logic using libraries, such as pytest for Python and ScalaTest for Scala.”
      ↩︎ Testing agent components from unit to canary
      “Data scientists submit ML code, which runs unit tests and deploys to a staging workspace for integration testing.”
      ↩︎ Testing agent components from unit to canary
      “Implement automated rollback mechanisms for failed deployments.”
      ↩︎ Testing agent components from unit to canary
      “Parameterize instead of hardcoding environment-specific settings, such as cluster size and secrets.”
      ↩︎ Key concept
    3. 3.
      “Indexes created with Continuous sync mode automatically update when the source table or view changes.”
      ↩︎ Updating the Vector Search index in the pipeline
      “You can use the Python SDK or the REST API to insert, update, or delete data from a Direct Vector Access Index.”
      ↩︎ Updating the Vector Search index in the pipeline
      “After updating target QPS, sync your indexes to apply the new configuration.”
      ↩︎ Updating the Vector Search index in the pipeline
      “If you are using Triggered sync mode, you can start the sync using the UI, the Python SDK, or the REST API.”
      ↩︎ Exam trap 1
      “you should not drop or modify the table, as it is not intended to be manually updated.”
      ↩︎ Exam trap 2
      “If you are using Triggered sync mode, you can start the sync using the UI, the Python SDK, or the REST API.”
      ↩︎ Prediction
    4. 5.
      “Promote prompts between environments by reassigning aliases:”
      ↩︎ Promoting and rolling back prompts with aliases
      “To access the prompt registry from an agent deployed using Custom Agents, you must use manual authentication”
      ↩︎ Promoting and rolling back prompts with aliases
      “Overriding these security environment variables disables automatic passthrough for other resources your agent depends on.”
      ↩︎ Promoting and rolling back prompts with aliases
      “reassign the production alias to point to a newer version without changing or redeploying your application code.”
      ↩︎ Exam trap 3
      “reassign the production alias to point to a newer version without changing or redeploying your application code.”
      ↩︎ Prediction
    5. 6.
      “Versions: Immutable snapshots with auto-incrementing numbers”
      ↩︎ Promoting and rolling back prompts with aliases
      “Remove aliases (versions remain)”
      ↩︎ Promoting and rolling back prompts with aliases
      “for A/B testing and gradual rollouts”
      ↩︎ Testing agent components from unit to canary
      “Aliases: Mutable pointers to specific versions”
      ↩︎ Checkpoint
    6. 7.
      “MLflow automatically creates lineage between your prompt versions and application versions.”
      ↩︎ Promoting and rolling back prompts with aliases

    Spotted a mistake, or was something unclear? Tell us.