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

python
def compute_config_revision(config: Optional[Dict[str, Any]]) -> str

Parameters

ParamField Optional

The parsed gateway config mapping (or `None`/empty).

Returns

ResponseField str

A 12-character hex revision id; a stable sentinel for an empty config.

Uses

  • json.dumps
  • hexdigest
  • hashlib.sha256
  • canonical.encode

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 1556


Related Documentation