cxas-dfcx-migration
Migrate Dialogflow CX (DFCX) agents to CXAS (Customer Experience Agent Studio) agents. Use this skill when the user mentions DFCX migration, migrating agents, converting DFCX to CXAS, porting agents, agent migration, or post-migration optimization/consolidation. Four independently runnable scripts: migrate.py (1:1), stage_1.py (variable dedup + consolidation), stage_2.py (instruction state machines + tool mocks + lint + report), stage_3.py (rewires consolidated topology from source dep graph; only needed when stage_1 ran consolidation). State persists between scripts via <target>_ir.json so each can run / re-run / resume independently.
GoogleCloudPlatform · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add GoogleCloudPlatform/cxas-scrapi --skill cxas-dfcx-migration技能说明
name: cxas-dfcx-migration description: >- Migrate Dialogflow CX (DFCX) agents to CXAS (Customer Experience Agent Studio) agents. Use this skill when the user mentions DFCX migration, migrating agents, converting DFCX to CXAS, porting agents, agent migration, or post-migration optimization/consolidation. Four independently runnable scripts: migrate.py (1:1), stage_1.py (variable dedup + consolidation), stage_2.py (instruction state machines + tool mocks + lint + report), stage_3.py (rewires consolidated topology from source dep graph; only needed when stage_1 ran consolidation). State persists between scripts via _ir.json so each can run / re-run / resume independently.
DFCX to CXAS Migration
Four small scripts, one persistent IR bundle:
| Script | What it does | Runtime | Output |
|---|---|---|---|
migrate.py | 1:1 conversion of every selected playbook/flow into the IR, and deploys base resources only (app, variables, tools). Agent deployment is DEFERRED to stage_1.py so large sources don't exceed the CXAS 100-agent cap — the compiled agents are saved in <target>_ir.json, not pushed. Pass --no-consolidate to push the full 1:1 agent set immediately (only safe below ~100 agents). | ~30 min for ~40 flows | <target>_ir.json, <target>_migration_report.md, <target>_unit_tests.json |
stage_1.py | Loads the IR bundle, runs CXASOptimizer.optimize_stage1 (variable dedup) and Gemini structural consolidation (N→M agent grouping). This is the first agent push to CXAS — only the consolidated (N→M) agents are deployed; the raw 1:1 originals are never pushed (consolidate() drops them and the pre-consolidation snapshot is used transiently for the integrity check only, never persisted). CXAS Version 0.0.2 (dedup) and 0.0.3 (consolidation). | ~15 min | Updated <target>_ir.json, <target>_grouping.json |
stage_2.py | Loads the IR bundle, runs CXASOptimizer.optimize_stage2 (instruction state machines + tool mocks). Pushes via update-pass deploys. CXAS Version 0.0.4. Re-generates unit tests. Lints. Writes the audit report. | ~10 min | Updated <target>_ir.json, <target>_optimization_report.md, regenerated <target>_unit_tests.json |
stage_3.py | Only after Stage 1 consolidation. Rewires the consolidated agents' parent → children topology by mapping the SOURCE DFCX dep graph onto the new groups (rather than relying on what the synthesized PIF XML happened to reference) according to Spoke-Hub architecture style. Sets app root_agent to the is_root group. Idempotent — safe to re-run. CXAS Version 0.0.5. | ~10 sec | Updated <target>_ir.json stage history; CXAS app's child_agents set per group |
State flows through <target>_ir.json (a Pydantic IRBundle containing the MigrationConfig, source DFCXAgentIR, target MigrationIR, stage history, and version checkpoints). Each stage loads it from disk, mutates it, and writes it back. No re-fetching or re-compiling between stages.
When to use this skill vs. the CLI directly
This skill (InquirerPy prompts + HTML pre-flight preview + Gemini model picker) is the right entry when you want to interactively drive a migration with rich pre-flight context. The same MigrationService.run_stage* methods this skill calls are also exposed via the canonical CLI for scripted / CI use:
# Same E2E plumbing, non-interactive (standard optimized profile by default):
cxas migrate dfcx --run --source-agent-id … --project-id … --target-name …
# Non-interactive Stage Checkpoint optimization runs:
cxas migrate dfcx --optimize --stage 1 --target-name my_app
cxas migrate dfcx --optimize --stage 2 --target-name my_app
cxas migrate dfcx --optimize --stage 3 --target-name my_app --architecture hub-and-spoke
cxas migrate dfcx --optimize --stage resume --target-name my_app # interactive stage picker
The skill, the dashboard, and the E2E / Checkpoint commands all go through the same MigrationService.run_stage_1/run_stage_2/run_stage_3 methods — pick whichever entry point matches your workflow.
Prerequisites
# Ensure cxas_scrapi is installed editable (so this skill picks up local changes)
pip install -e .
# Auth
gcloud auth application-default login
gcloud auth list # confirm the account has read on source + admin on target
InquirerPy is required for the interactive prompts (matches the agent-foundry skill):
pip install InquirerPy
Driving the flow interactively (from Claude)
When invoked through Claude, lead the user through one question at a time. The scripts will prompt for missing inputs via InquirerPy, but you should pre-collect:
- GCP project ID (target — where the new CXAS app will live).
- Location — default
us. Do NOT default toglobal— it does not work for CXAS apps in most projects. - Source agent — DFCX agent ID (full resource name) or path to a local
.zipexport. - Target name — display name for the new CXAS app.
Optional follow-ups: --env (PROD/AUTOPUSH), --model (Gemini), --migration-version (1.0/2.0).
Quick Reference
# 1:1 migration (interactive — InquirerPy will prompt for project + location)
python .agents/skills/cxas-dfcx-migration/scripts/migrate.py
# Fully scripted
python .agents/skills/cxas-dfcx-migration/scripts/migrate.py \
--source-agent-id "projects/<src_proj>/locations/us/agents/<uuid>" \
--project-id <target_proj> --location us \
--target-name my_cxas_app --yes
# Pre-flight HTML preview only (no migration)
python .agents/skills/cxas-dfcx-migration/scripts/migrate.py \
--source-agent-id "<id>" --project-id <proj> --target-name preview_only \
--preview-only --yes
# Stage 1 — variable dedup + Gemini consolidation
python .agents/skills/cxas-dfcx-migration/scripts/stage_1.py --target-name my_cxas_app
# Stage 1 — replay a saved grouping JSON
python .agents/skills/cxas-dfcx-migration/scripts/stage_1.py \
--target-name my_cxas_app
阅读完整来源 ↗