[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[[["\u003cp\u003eAgent versions are immutable snapshots of your agent, while the draft agent is the editable, live version that changes with each update.\u003c/p\u003e\n"],["\u003cp\u003eProduction traffic should always use agent versions to ensure stability, and draft agents should undergo testing before being promoted to production.\u003c/p\u003e\n"],["\u003cp\u003eCustom environments can be created for testing, development, or production and allow you to publish different agent versions to each one.\u003c/p\u003e\n"],["\u003cp\u003eChanging an agent version in a production environment during active sessions may cause errors due to potential inconsistencies between versions, so schedule version changes during down-time or off-peak hours.\u003c/p\u003e\n"],["\u003cp\u003eYou can revert an environment to a previous agent version or load a prior version to draft, but loading a previous version to draft overwrites all recent changes to draft and is irreversible.\u003c/p\u003e\n"]]],[],null,["# Versions and environments\n\nYou can create multiple versions of your agent\nand publish them to separate environments.\n\nWhen you edit an agent,\nyou are editing the *draft agent* .\nAt any point, you can save the draft agent as an *agent version*,\nwhich is an immutable snapshot of your agent.\n\nWhen you save the draft agent,\nit is published to the *default environment* .\nWhen you create agent versions,\nyou can publish them to *custom environments*.\nYou can create a variety of custom environments for:\n\n- testing\n- development\n- production\n- etc.\n\nProduction traffic\n------------------\n\n### Always use agent versions for production traffic\n\nA draft agent is updated every time a developer on your team makes a change.\nIt is easy to break a draft agent unintentionally,\nespecially if multiple people have write access to the agent.\nIn addition, a recently edited draft agent\nmay be inconsistent with the trained model,\nbecause training may have a delay or require manual execution.\n\nYou should always use agent versions for your production traffic.\nDraft agents should be tested before promoting them to production versions,\nand you can rollback to a previous version if any problems are discovered.\n\n### Consider possible agent errors while changing versions\n\nIf you change an agent version in your production environment\nwhile sessions are active,\nit may cause agent errors for some active sessions.\nThese errors may happen if the previous and new versions\nare inconsistent with each other\nin a way that disrupts session state.\nDue to this,\nyou should plan to change versions during\ndown-time or off-peak hours.\n\nPublish a version in a new environment\n--------------------------------------\n\nTo publish an agent draft to a version\nand create a custom environment: \n\n### Console\n\n1. Go to the [Dialogflow ES console](https://dialogflow.cloud.google.com).\n2. Select your agent near the top of the left sidebar menu.\n3. Click the settings *settings* button next to the agent name.\n4. Click the **Environments** tab.\n5. Click **Publish a version**.\n6. Add an optional description and click **Next**.\n7. Select **+New Environment**.\n\n | **Note:** You can create an agent version without publishing it by selecting **Create version without publishing** from the environment menu.\n8. Enter an environment name.\n\n9. Choose the fulfillment method for the environment.\n\n10. Select Text-to-speech settings for the environment.\n\n11. Click **Publish**.\n\n12. The environment information is now listed\n in the **Custom environments** section.\n\n### API\n\n1. Call the `create` method for the [Version type](/dialogflow/es/docs/reference/common-types#versions) to create a new agent version.\n2. Call the `create` method for the [Environment type](/dialogflow/es/docs/reference/common-types#environments) to create a new environment. Provide the agent version you just created to the `agentVersion` field.\n\nRevert an environment to a previous version\n-------------------------------------------\n\nYou can revert an environment to a previous agent version: \n\n### Console\n\n1. Click an environment in the **Custom environments** section.\n2. The environment settings dialog opens.\n3. Click the option *more_vert* button for a previously published version in the **Publishing History** section.\n4. Click **Revert to this version**.\n5. The publishing history will be updated.\n\n### API\n\nCall the `patch`/`update` method for the\n[Environment type](/dialogflow/es/docs/reference/common-types#environments)\nto update an environment.\nProvide the agent version you previously created to the `agentVersion` field.\n\nLoad a previous version to draft\n--------------------------------\n\nLoading a previous version to draft\noverwrites the draft agent in the default environment\nwith a selected agent version.\n| **Caution:** Loading a previous version to draft will negate all recent changes to draft and can't be undone. You may want to save the draft to a version before taking these steps.\n\nTo load a previous version to draft: \n\n### Console\n\n1. Go to the [Dialogflow ES console](https://dialogflow.cloud.google.com).\n2. Select your agent near the top of the left sidebar menu.\n3. Click the settings *settings* button next to the agent name.\n4. Click the **Environments** tab.\n5. Click **View all versions** in the **Draft** section.\n6. Click the option *more_vert* button for a version that you want to load to draft.\n7. Click **Load to Draft**.\n8. Click **Yes, I'm sure**.\n9. Reload any open console browser tabs, so they are refreshed with the latest agent data.\n\n### API\n\nCall the `patch`/`update` method for the\n[Environment type](/dialogflow/es/docs/reference/common-types#environments)\nwith the following inputs:\n\n- Use `-` as the environment ID to specify the default environment.\n- Set `allowLoadToDraftAndDiscardChanges` to true.\n- For the `agentVersion` field, supply the agent version that will overwrite the draft agent.\n\nExport a version\n----------------\n\nTo export a version, you need to [load it to draft](#load-to-draft) first, then\n[export the agent](/dialogflow/es/docs/agents-settings#export).\n\nTest your agent in an environment\n---------------------------------\n\nYou can use the API to test your agent in any of your custom environments.\nCall the\n[detect intent](/dialogflow/docs/quick/api)\nmethod, but alter the endpoint URL by inserting\n`environments/environment-name/users/-/` between `agent` and `sessions`.\n\nFor example, the following endpoint uses the \"development\" environment with an unspecified user: \n\n \"https://dialogflow.googleapis.com/v2/projects/my-project-id/agent/environments/development/users/-/sessions/123456789:detectIntent\"\n\nEnvironment-specific settings\n-----------------------------\n\nFulfillment and text-to-speech are configured by the environment,\nso the agent will use the environment's settings for these features.\n\nFor more information about how data is applied at various levels, see\n[agent application levels](/dialogflow/es/docs/data-level).\n\nGoogle Assistant\n----------------\n\nIf you are using\n[Actions on Google release environments](https://developers.google.com/assistant/console/releases),\nsee the versioning limitations for the\n[Dialogflow fulfillment library](/dialogflow/docs/fulfillment-inline-editor#library).\n\nMega agent\n----------\n\nSee [how versions and environments work in mega agents](/dialogflow/es/docs/agents-mega#versions).\n\nLimitations\n-----------\n\nThe following limitations apply:\n\n- Maximum number of environments per agent: 10\n- Maximum number of versions per agent: 1000"]]