Detect Code Skew • AI Agent SDK

detect_code_skew: Return shortened “(boot, disk)“ fingerprints if the code changed.

detect_code_skew

Function

</div>

This function is defined in the protocols module.

Return shortened `(boot, disk)` fingerprints if the code changed.

This is the pure, side-effect-free heart of the code-skew guard. It does not read the filesystem or git; callers pass the fingerprint captured at boot and a freshly-read on-disk fingerprint (see :func:read_code_fingerprint).

The check is intentionally fail-open: if either fingerprint is unknown (`None / empty) it returns None` so the caller proceeds normally and never blocks an operation just because the revision could not be read.

Signature

python
def detect_code_skew(boot_fp: Optional[str], disk_fp: Optional[str]) -> Optional[Tuple[str, str]]

Parameters

ParamField Optional[str]

Fingerprint captured when the gateway started.

ParamField Optional[str]

Fingerprint of the code currently on disk.

Returns

ResponseField Optional[Tuple[str, str]]

…”“ fingerprint); other fingerprints are returned unchanged.

Uses

  • fp.partition

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 5887


Related Documentation