Skip to content

chore(agents): keep one agents instance warm - #12511

Merged
MarkusNeusinger merged 4 commits into
mainfrom
chore/agents-min-instance
Nov 2, 2026
Merged

MarkusNeusinger merged 4 commits into
mainfrom
chore/agents-min-instance

Conversation

@MarkusNeusinger

@MarkusNeusinger MarkusNeusinger commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • anyplot-agents now deploys with _MIN_INSTANCES: "1". Today it scales to zero after about 15 idle minutes, and that loses every in-memory session, resets the day counters and gives the next message a cold start (owner decision of 2026-11-02).
  • Cost, from the billing export for 2026-10-12 to 2026-10-31:
    • The idle instance costs about 0.44 CHF a day at list price (1 vCPU, 2 GiB), measured on anyplot-api's min instance: CPU 0.145 CHF a day, memory 0.145 CHF a day per GiB.
    • The Compute Flexible commitment left 0.59 CHF a day unused over the same window.
    • So the instance costs nothing extra until the commitment's first part ends on 2027-01-15. A reminder to revisit is in Todoist.
  • The design doc and a changelog fragment are updated. The deploy-agents trigger overrides only _RENDER_URL, so the new default applies.
  • A flaky backend test failed on this PR, so it also carries the fix: a cancelled local render now waits for both theme containers (asyncio.gather raised after the first and left the second docker kill running). Development backend only.

Plan

N/A

Test plan

  • tests/unit/test_cloudbuild_configs.py passes, and the YAML parses.
  • tools.changelog check --base origin/main passes.
  • After merge, deploy-agents succeeds and gcloud run services describe anyplot-agents shows minScale=1.

anyplot-agents scaled to zero after about 15 idle minutes, which lost
every in-memory session, reset the day counters and gave the next
message a cold start. Set _MIN_INSTANCES to 1 (owner decision of
2026-11-02).

The idle instance costs about 0.44 CHF a day at list price (1 vCPU and
2 GiB, measured on anyplot-api's min instance in the billing export,
2026-10-12 to 2026-10-31). The account's Compute Flexible commitment
left 0.59 CHF a day unused over the same window, so the instance costs
nothing extra until the commitment's first part ends on 2027-01-15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H7HSkGyea1k2v293XiAMo8
Copilot AI lite review requested due to automatic review settings November 1, 2026 23:21
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H7HSkGyea1k2v293XiAMo8

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical unit-test expectation still conflicts with the changed substitution default, and the changelog overstates session persistence during idle periods.

2 open issues
What changed in this PR

This pull request keeps one anyplot-agents Cloud Run instance warm by setting _MIN_INSTANCES to "1", preserving in-memory state across scale-to-zero periods and reducing cold-start latency. It also documents the operational decision and adds a changelog entry.

Changes:

  • Sets the agents service minimum instance count to one.
  • Updates the agent network documentation with lifecycle and cost details.
  • Adds a changelog fragment describing the warm-instance behavior.
File Summary Review comments
docs/​concepts/​agent-network.md Documents the warm-instance deployment decision, cost rationale, and session limitations. No comments.
changelog.d/​agents-warm-instance.md Announces reduced cold starts and retained in-memory state. Nit: Qualify session persistence to clarify that the one-hour session sweep still applies.
agents/​cloudbuild.yaml Changes the default Cloud Run minimum instance count to one. Critical: Update tests/unit/agents/test_image.py:520 and any expected fixtures, which still expect a default of "0".

Review effort: Lite

Comment thread agents/cloudbuild.yaml Resolved
Comment thread changelog.d/agents-warm-instance.md Resolved
MarkusNeusinger and others added 2 commits November 2, 2026 00:49
…gelog

The image test still expected _MIN_INSTANCES "0". The fragment claimed that
sessions survive idle periods without limit; a session still ends after an
hour without activity, and a deploy resets sessions and day counters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H7HSkGyea1k2v293XiAMo8
`gather` raises as soon as the first cancelled theme ends, so render()
returned, and removed the run directory, while the other theme's `docker
kill` was still running. That made
test_local_backend_kills_the_container_on_cancellation flaky on a loaded
runner (failed on #12511, which does not touch this code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H7HSkGyea1k2v293XiAMo8
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@MarkusNeusinger
MarkusNeusinger merged commit fec6465 into main Nov 2, 2026
16 checks passed
@MarkusNeusinger
MarkusNeusinger deleted the chore/agents-min-instance branch November 2, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants