Skip to main content
Connic
Back to BlogProduct Spotlight

Staging to Production: How Connic Environments Isolate AI Agents

Connic environments map git branches to isolated deployments, each with its own secrets, connectors, budgets, and run history, so one agent spec ships safely.

August 6, 20268 min readAuthor: Connic Engineering

Your agent works. It handles every test invoice and the answers hold up. Then comes the production deployment, and the questions change: which Stripe key does the agent hold, which database does its connector point at, and what happens to a real customer if a half-finished branch ships?

Connic answers this with environments: the same agent specification, deployed several times, each deployment wrapped in its own configuration. This post walks through how the isolation works, from git branch mapping to secrets, connectors, budgets, and the test gate that stands between a merge and production.

What is a Connic environment?

An environment is a complete, isolated context for running your agents. The agent specification, the YAML and Python you version in git, stays identical everywhere. What changes per environment is everything around it:

Variables and secrets
Each environment holds its own key-value set. The same ${STRIPE_API_KEY} reference resolves to a sandbox key in staging and the live key in production.
Connector wiring
A connector belongs to exactly one environment, with its own configuration, credentials, and enabled state. Staging listens to sandbox events, production to live ones.
Deployments and runs
Each environment keeps its own deployment history and run history. The environment selector in the dashboard scopes agents, runs, connectors, and variables to the active environment.
Budget rules
Spend alerts and hard limits can target one or more environments, so a runaway staging experiment cannot eat the production budget.

The isolation goes deeper than configuration. Database rows, agent sessions, retrieval content, variables, and connectors are all keyed by environment, and each environment runs on its own runtime service with its own event queue. A staging trigger cannot land in a production runner.

The Git & Environments settings panel showing a Production environment mapped to the main branch and marked as default, and a Staging environment mapped to develop, both with PR tests enabled.
Project Settings → Git & Environments: each environment is linked to a git branch, one is marked as default, and PR tests are toggled per environment.

Every project starts with a default environment, and a common setup adds a second one: Production tracking main, Staging tracking develop. Creating an environment takes a name, a branch to track if a repository is connected, and, if you want a head start, a copy of another environment's variables. The default environment is what the dashboard opens on and what connic deploy targets when no environment is given.

Git branch mapping does the routing

Each environment can track one git branch. Push to that branch and Connic builds a new deployment for that environment from that exact commit. Pushes to branches that are not mapped to any environment are ignored. Two things about this routing are easy to miss:

Deployments are independent
Merging develop into main does not promote the staging build. The merge is a push on main, so the production environment builds fresh from the merge commit. Every mapped branch triggers its own deployment, and nothing else moves.
Nothing rolls back on its own
Rollback is a manual action: activate a previous deployment from the environment's history and traffic moves back to it. Failed builds and failed test gates never activate in the first place, so the previous deployment keeps serving.

Push twice in quick succession and the newer deployment supersedes the older one still building. Activation never drops work either: the previous deployment drains its in-flight runs before stopping, and queued runs are re-triggered against the new one.

Projects without a git connection, and teams that deploy from CI, use the CLI instead. Every environment has an ID you can copy from its settings:

CI/CD
# deploy the current commit to a specific environment
connic deploy --env <environment-id>

Read the deployment pipeline documentation for the full build, test, and activation flow, including CI examples.

One agent spec, safely in production

Create a project, map two branches, and deploy the same agent to staging and production with separate credentials in an afternoon.

Get started free

Variables and sensitive values

Environment variables are per-environment key-value pairs. Supported fields in agent YAML, such as MCP server URLs and headers, reference them as ${VAR_NAME}, and Python tools read them from os.environ. Values resolve at deploy time to whatever the active environment has bound, so the YAML you commit holds no credentials at all.

Mark a variable as sensitive and its value is masked in the dashboard after creation, masked in logs, and never returned by the API again. Values are stored encrypted and injected into your agent containers at deploy time.

Because injection happens at deploy time, variable changes, including secret rotations, take effect on the next deployment. The running deployment keeps the previous values until you redeploy. For bulk work, a variable can be created across several environments in one step, and a new environment can start from a copy of another's variables. Read how Connic secures agents in production for the wider security picture.

Connectors are wired per environment

Connectors, the pieces that trigger agents from external events such as Stripe webhooks, Kafka topics, Postgres notifications, or inbound email, belong to exactly one environment. The staging Stripe connector and the production Stripe connector are two separate connectors with separate configuration, separate credentials, and separate run histories.

This is the part plain .env files never covered. Two sets of keys are easy to store somewhere. The event wiring is not: which topic, which webhook endpoint, which inbox. In Connic that wiring belongs to the environment and switches with it.

Local development gets the same treatment. A connic dev session runs in its own dev environment, ephemeral or named, with its own variables and connectors, grouped separately in the environment selector. A hot-reload experiment cannot accidentally point a webhook at production.

Budgets that stop at the environment boundary

Model spend is scoped the same way. Budget rules come in two types: alerts that notify, and limits that hard-stop. Either can target the whole project, specific environments, or specific agents, on a daily or monthly period.

A limit does not kill anything. When spend crosses the threshold, new runs in the scoped environments are queued instead of started, with the reason recorded on each run. Once the period rolls over or the limit is raised, queued runs resume automatically within minutes. A typical setup is a small daily limit on staging and an alert-only threshold on production. Set up spend alerts and limits in the usage documentation.

The deploy gate: tests before anything ships

Every deployment, whether triggered by a push or the CLI, passes through the deploy gate before it can serve traffic:

Build
The agent image is built from the commit that triggered the deployment.
Test
A one-shot test container runs every case in your tests/ directory against the just-built image.
Deploy
Only a full pass activates the new deployment. Otherwise it is marked failed and the previous deployment keeps serving.

Projects without a tests/ directory skip the gate, and it can be toggled per environment. The CLI has a --skip-tests escape hatch, but git-triggered deploys never use it: a merge cannot sneak past the suite.

A deployment pipeline showing the build image phase completed and the run tests phase failed, with the failing test cases listed below.
A failed test phase stops the release: the deployment is marked failed and the previously active one keeps serving traffic.

Point the gate at test credentials

By default the suite runs in the environment being deployed, with that environment's variables and connectors. For production that is exactly what you do not want: a release test should not charge a real card or write to the live database. The fix is the test environment override. Point Production's Test environment setting at a sibling environment, say prod-test, that holds stub credentials and stage-only connectors. The gate then executes the suite with that environment's variables and credentials, and the test runs land in its run history rather than production's.

Run the suite before the merge

The same suite can also run before the merge instead of after it. For a branch-mapped environment with PR testing enabled, every pull request targeting that branch runs the tests, in the test environment if one is set, and reports a connic/pr-tests status on the commit, so you can require a green check before merging. PR testing is available on the Pro plan. See how the deploy gate and PR testing work in the testing documentation, or read how the testing framework defines cases.

A safe release, start to finish

Put together, a release to production looks like this:

  • 1.Map the branches. Production tracks main and is the default environment; Staging tracks develop.
  • 2.Create prod-test. A sibling environment with test credentials and sandbox connector wiring, set as Production's test environment.
  • 3.Build on develop. Every push deploys to Staging, where the agent runs with staging keys against sandbox services.
  • 4.Open the pull request to main. PR tests run the suite against prod-test and post a connic/pr-tests check on the commit.
  • 5.Merge. Production builds from the merge commit, the deploy gate re-runs the suite in prod-test, and only a full pass activates the deployment. The previous one drains and stops.
  • 6.If something slips through, roll back. Activate the previous deployment from the history; nothing is rebuilt.

No test run holds a production credential along the way, and nothing promotes or rolls back implicitly. Every deployment is an explicit build from a known commit, gated by the same suite. For the broader journey, read how teams take agents from prototype to production.

Run history and the audit trail

Operations stay separated after the deploy too. Runs are recorded against their environment, the environment selector scopes what the dashboard shows, and each environment keeps a deployment history with status, commit hash, test results, and durations.

For the who-did-what layer, the project audit log records environment changes, variable changes (values are never written to the log), deployments, and git connection events, with before and after snapshots. Deploys triggered by a push are recorded as system actions, so the trail distinguishes a human deploy from branch automation. Find it under Project Settings → Audit Log.

Frequently Asked Questions

No. Environments deploy independently. Merging develop into main is a push on main, so the production environment builds fresh from the merge commit and runs its own deploy gate. Nothing is promoted, and rollback is equally explicit: you activate a previous deployment from the environment's history.

No. Variables are injected into agent containers at deploy time, so changes, including rotated secrets, take effect on the next deployment. Until then the running deployment keeps the previous values.

No. A value marked as sensitive is masked in the dashboard after creation, masked in logs, and never returned by the API. It is stored encrypted and injected into agent containers at deploy time. To rotate one, overwrite it with a new value and redeploy.

New runs in the limited scope are queued, not cancelled, with the reason recorded on each run. They resume automatically once the period rolls over or the limit is raised or removed, typically within a few minutes.

Getting started

  • 1.Connect your repository, then open Project Settings → Git & Environments and map Production to main and a new Staging environment to develop
  • 2.Add variables per environment and mark keys and credentials as sensitive
  • 3.Create connectors in each environment: sandbox wiring in staging, live wiring in production
  • 4.Optionally add a test environment override and a staging budget limit, then push

For the full reference, read the environments documentation or explore the environments feature page. If you are new to Connic, start with the quickstart guide to deploy your first agent, then split its world into staging and production.

More from the Blog

Product Spotlight

LLM Context Compression for Long-Running AI Agents

Connic compresses older conversation history and oversized tool results, then retries the model call, so long-running agent sessions survive context limits.

July 20, 20268 min read
Product Spotlight

Connic Tests: Catch Agent Regressions Before They Reach Production

A YAML-driven testing framework built for non-deterministic AI agents. Repeated-run pass thresholds, expression-based assertions, custom-code mocking, multimodal fixtures, and a deploy gate that blocks failed checks by default.

May 6, 20268 min read
Product Spotlight

Human-in-the-Loop AI Agents: How Approvals Work in Production

How to pause an AI agent before refunds, deletes, or external calls, route the decision to a human, and resume automatically, with a full audit trail.

April 5, 202610 min read
Product Spotlight

A/B Testing for AI Agents: Ship Better Prompts with Confidence

You changed the prompt and it feels better. Run a controlled experiment to find out whether it is, and let real traffic decide.

March 27, 20269 min read
Product Spotlight

Secure AI Agents: A Production Safety Checklist

Shipping AI agents without a security strategy is a liability. A practical checklist covering prompt injection, PII handling, output validation, and the guardrails you need before go-live.

March 21, 202612 min read
Product Spotlight

Agent Guardrails: Real-Time Safety for Your AI Agents

Connic Guardrails intercept agent inputs and outputs in real time to block prompt injection, redact PII, and enforce topic restrictions.

March 3, 20269 min read
Product Spotlight

Connic Bridge: AI Agents for Private Infrastructure

Connic Bridge creates a secure outbound tunnel so your AI agents can reach private Kafka, databases, and internal services without opening inbound ports.

February 19, 20267 min read
Product Spotlight

Agent Observability: Track Costs, Tokens & Runs

Deploying AI agents without visibility is flying blind. Build custom dashboards, track LLM costs per model, and catch failures before users do.

January 23, 20268 min read
Product Spotlight

Composer SDK: Better Agent Development Tooling

Stop manual uploads and YAML guessing. The Composer SDK adds scaffolding, validation, cloud-backed hot-reload development, and CLI deployments.

December 27, 20255 min read