
How do you run an autonomous AI agent in the cloud 24/7 for just $5.70 a month? I recently wanted to...
How do you run an autonomous AI agent in the cloud 24/7 for just $5.70 a month?
I recently wanted to build a background worker with persistent disk storage and an instant web dashboard, but I didn't want the headache of managing a virtual machine or paying a massive monthly bill.
If you are building long-running agents, you know this exact cloud hosting dilemma:
Last year, I built a multi-agent Trend Spotter with ADK. It worked well, but I wanted to make it fully autonomous: a continuous, long-running agent that scans and summarizes tech feeds in the background without manual triggers or high hosting costs.
Google Cloud's new Cloud Run instances primitive solves this exact problem. It gives you a single, always-on container that runs 24/7, costs $5.70 a month on a shared CPU, provides a free HTTPS endpoint, and lets you mount cloud storage like a normal local disk.
Here is how to build and deploy a production long-running agent with this setup (you can follow along with the complete source code in the repo.
I want to stay up to date with what is happening in AI and agent engineering. But instead of manually opening 20 browser tabs across different websites every morning, I wanted to build my own long-running agent that updates me on recent news anytime I want.

The whole application runs inside one Cloud Run instance:

A tech briefing agent is just one example. Because Cloud Run instances give you an always-on background worker, a free web endpoint, and safe local disk storage, you can use this exact same pattern for many developer workflows:
Standard serverless platforms are designed for quick web requests. They wait for a user to click a button, run for one second, and shut down.
Long-running background agents have different needs:

With an instance, you get the simplicity of serverless with the stability of a VM. Because your instance is always hot with a public HTTPS endpoint, it easily handles three trigger styles in one container:
Cloud Run instances are great for single-worker background agents. You should pick a different tool if you need:
Instead of a single instance, you could build an event-driven system: a Cloud Scheduler triggers a Cloud Run Job for polling, while a scale-to-zero Cloud Run Service hosts the dashboard and listens for webhooks.
While this decoupled approach drops compute costs to virtually $0.00 in the free tier, you lose single-container simplicity. You are forced to manage multiple cloud services and message queues (to prevent concurrent webhooks from corrupting your state), while accepting cold starts on your web dashboard.

You can deploy this setup to Google Cloud in about five minutes.
export PROJECT_ID="your-project-id"
export REGION="us-west1"
export BUCKET_NAME="${PROJECT_ID}-agent-data"
export REPO_NAME="agent-repo"
gcloud config set project $PROJECT_ID
gcloud services enable run.googleapis.com storage.googleapis.com artifactregistry.googleapis.com cloudbuild.googleapis.com secretmanager.googleapis.com
Note: Cloud Run instances are not available in every region. Please pick a supported region near you from the Cloud Run instances locations page.
gcloud storage buckets create gs://$BUCKET_NAME \
--location=$REGION \
--uniform-bucket-level-access
gcloud artifacts repositories create $REPO_NAME \
--repository-format=docker \
--location=$REGION
gcloud builds submit \
--tag ${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPO_NAME}/tech-briefing-agent:latest .
gcloud iam service-accounts create briefing-agent-sa \
--display-name="Briefing Agent SA"
gcloud storage buckets add-iam-policy-binding gs://$BUCKET_NAME \
--member="serviceAccount:briefing-agent-sa@${PROJECT_ID}.iam.gserviceaccount.com" \
--role="roles/storage.objectUser"
Never pass API keys in plain text. Store your Gemini API key in Google Cloud Secret Manager and grant your service account permission to read it:
echo -n "YOUR_GEMINI_API_KEY" | gcloud secrets create gemini-api-key \
--data-file=- \
--replication-policy="automatic"
gcloud secrets add-iam-policy-binding gemini-api-key \
--member="serviceAccount:briefing-agent-sa@${PROJECT_ID}.iam.gserviceaccount.com" \
--role="roles/secretmanager.secretAccessor"
gcloud beta run instances create tech-briefing-agent \
--image=${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPO_NAME}/tech-briefing-agent:latest \
--region=$REGION \
--port=8080 \
--cpu=1 \
--memory=1Gi \
--public \
--service-account=briefing-agent-sa@${PROJECT_ID}.iam.gserviceaccount.com \
--add-volume mount-path=/data,type=cloud-storage,mount-options="uid=1000;gid=1000;file-mode=0700;dir-mode=0700",bucket=$BUCKET_NAME \
--set-secrets "GEMINI_API_KEY=gemini-api-key:latest" \
--set-env-vars "DATA_DIR=/data,POLL_INTERVAL_MINUTES=30"
We set --cpu=1 and --memory=1Gi to keep the cost at $5.70. If you omit these, it defaults to 2 CPUs and 2 GiB (~$11.40/month, see pricing table). To improve load times, you can increase the CPU and memory.
[!TIP] Adjust uid=1000;gid=1000 in the mount-options flag to match the specific non-root user ID defined in your Dockerfile, if different.
When this command finishes, Cloud Run gives you a live HTTPS web address. Open it in your browser to see your briefing dashboard.
Here is the real monthly bill for running this 24/7:

For less than the price of two cups of coffee, you have a private agent running day and night.
Want to dive deeper into Cloud Run Instances? Check out these official Google Cloud resources:
Now that the hosting problem is solved, how do you make the agent smart and resilient? How do you stop it from summarizing noise when it hits a paywall, or build self-correcting reflection loops?
Join us in the next part where we will dive into graph engineering and the architecture of the agent using ADK 2.0.
Happy building!
geminiA controlled Gemini 3.7 Flash benchmark shows why agentic video is excellent for long-form search—but...
aiAI engineering sounds fancy. New terms are everywhere: agentic development, AI-native engineering,...
aiMost teams running on Google Cloud don't pick one compute model and stay there. Some services live...
devchallengeWe're back with another DEV Weekend Challenge, a short bite-sized challenge planned to fit into your...
flutterDiscover how to eliminate Flutter StatefulWidget boilerplate and overcome Dart's single-inheritance wall by combining ScrollController with CubitSignalMixin and BlocSignalMixin for a 100% StatelessWidget UI.
discussTL;DR I recently finished a project from Udacity's Future AWS Agent Engineer Nanodegree Program,...
Workflows from the Neura Market marketplace related to this Midjourney resource