Skip to content

[AIGTWY-4756] Cache managed config reads for 5 min between launches - #696

Merged
david-siqi-liu merged 2 commits into
mainfrom
david/ug-configure-ttl
Sep 17, 2026
Merged

david-siqi-liu merged 2 commits into
mainfrom
david/ug-configure-ttl

Conversation

@david-siqi-liu

@david-siqi-liu david-siqi-liu commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Unity Gateway fetched the workspace managed coding-agent config from the control plane on every non-dry-run launch, even when it had just been read. This reuses a recent read so back-to-back launches stop re-fetching, while ug configure always reads fresh.

  • Add force_refresh to refresh_managed_config: launches reuse a persisted read younger than a 5-minute TTL. ug configure reads fresh instead, both the main path and ug configure --agent (whose only managed read is the AI-tools install gate), so it never decides from a since-changed config.
  • Persist retrieved_at and an outcome (published, no config, or feature-disabled) as local wrapper metadata, leaving the raw gateway config verbatim for ug export.
  • Invalidate the cache on a missing, unparseable, or future-dated timestamp, a wrong workspace, or an age at or over the TTL. A failed or auth-failed refresh never advances the timestamp, so a stale read cannot look fresh, and it keeps falling back to the last known-good config.
  • Harden read_json_safe against non-UTF-8 bytes so a corrupted cache file read on every launch reads as absent instead of crashing the launch.

Successful no-config and feature-disabled reads are cached for the TTL, so after an admin enables the feature or publishes a config a launch may take up to five minutes to pick it up; ug configure reads fresh and is unaffected. Dynamic budget recommendation reads stay per-launch, unchanged.

This pull request and its description were written by Isaac.

@david-siqi-liu david-siqi-liu added the quicktree-assisted PR created with quicktree-assisted workflow label Sep 16, 2026
@david-siqi-liu
david-siqi-liu marked this pull request as ready for review September 16, 2026 23:21
@david-siqi-liu
david-siqi-liu force-pushed the david/ug-configure-ttl branch 2 times, most recently from 998c1c1 to d13cac1 Compare September 17, 2026 15:12
Unity Gateway fetched the workspace managed coding-agent config from the
control plane on every non-dry-run launch, even when it had just been read.
Reuse a read younger than a 5-minute TTL so back-to-back launches stop
re-fetching, while every `ug configure` path reads fresh.

- refresh_managed_config gains force_refresh; launches use the cache by
  default, and the configure paths pass force_refresh=True (including the
  AI-tools install gate, which runs only during configure).
- Persist retrieved_at plus an outcome (published / none / feature_disabled)
  as wrapper metadata, leaving the raw config verbatim for ug export.
- Invalidate the cache on a missing, unparseable, or future-dated stamp, a
  wrong workspace, or an age at/over the TTL; failed refreshes never advance
  the stamp, so a stale read cannot masquerade as fresh.
- Harden read_json_safe against non-UTF-8 bytes so a corrupted cache file
  read on every launch reads as absent rather than crashing the launch.
- Add a managed integration test: a launch within the TTL reuses the cached
  read (retrieved_at unchanged), and a backdated stamp forces a fresh read.

Co-authored-by: Isaac <no-reply@databricks.com>
Comment thread src/ucode/managed_config.py
@david-siqi-liu
david-siqi-liu merged commit 5f5e349 into main Sep 17, 2026
20 checks passed
@david-siqi-liu
david-siqi-liu deleted the david/ug-configure-ttl branch September 17, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

quicktree-assisted PR created with quicktree-assisted workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants