Skip to content

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

Open
david-siqi-liu wants to merge 1 commit into
mainfrom
david/ug-configure-ttl
Open

david-siqi-liu wants to merge 1 commit 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
Unity Gateway fetched the workspace managed coding-agent config from the
control plane on every non-dry-run launch. Reuse a read younger than a
5-minute TTL so back-to-back launches don't each round-trip, while every
`ug configure` path still reads fresh so it never applies a since-changed
config.

- 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.

Co-authored-by: Isaac <no-reply@databricks.com>
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.

1 participant