Compute Config Revision • AI Agent SDK
compute_config_revision: Return a stable, short revision id for a gateway config mapping.
compute_config_revision
Function
</div>
This function is defined in the protocols module.
Return a stable, short revision id for a gateway config mapping.
Deterministic hash over the canonical form of `config` (keys sorted, whitespace-insensitive) so the same logical config always yields the same revision regardless of key ordering or formatting. Comparing the revision of the running config against the revision of what is on disk gives a first-class config-drift signal (“did my change take effect / is a restart still owed?”).
Pure and dependency-free (stdlib `json + hashlib`) so it lives in core and is reused by both the SDK and the bot without divergence.
Signature
def compute_config_revision(config: Optional[Dict[str, Any]]) -> strParameters
OptionalThe parsed gateway config mapping (or `None`/empty).
Returns
strA 12-character hex revision id; a stable sentinel for an empty config.
Uses
json.dumpshexdigesthashlib.sha256canonical.encode
Source
View on GitHubpraisonaiagents/gateway/protocols.py at line 1556