Skip to main content

conduct-litellm-guard

Conduct Guard as a LiteLLM guardrail. Every LLM call routed through LiteLLM runs through your active Guard policy before the request leaves your network — block, warn, audit, or trigger a HITL approval, with the same signed configuration and hash-chained audit log as the rest of Conduct.

Install

pip install conduct-litellm-guard

Wire it up

  1. Mint an agent token in the Conduct console (Settings → Agent identities). Copy the cond_agt_… value.
  2. Export it in the environment where your LiteLLM proxy runs:
    export CONDUCT_AGENT_TOKEN=cond_agt_...
    
  3. Add the guardrail to your LiteLLM proxy's config.yaml:
    guardrails:
      - guardrail_name: conduct-guard
        litellm_params:
          guardrail: conduct_litellm_guard.ConductGuard
          mode: pre_call
          api_url: https://api.conductai.ai
          agent_token: os.environ/CONDUCT_AGENT_TOKEN
          fail_mode: fail_closed
    
  4. Start the proxy:
    litellm --config config.yaml
    

A full example lives in examples/config.yaml.

What the guardrail does

For every incoming request the guardrail calls Conduct's guard_check tool (JSON-RPC over the MCP endpoint) with a compact summary of the LiteLLM request — model, call type, message count, temperature, stream flag, plus the last user message so the audit trail carries context.

Guard returns one of five verdicts:

Verdict LiteLLM behaviour
ok / allow Request forwarded to the upstream model.
advisory Forwarded, metadata.conduct_guard annotated.
WARNING Forwarded, warning surfaced in metadata.
BLOCKED LiteLLM returns an error to the caller. No upstream token spent.
PENDING approval Blocked pending HITL. Caller receives an error citing the rule.

Configuration reference

Field Required Default Notes
api_url no https://api.conductai.ai Point at a self-hosted Conduct API when needed.
agent_token yes CONDUCT_AGENT_TOKEN env cond_agt_* token minted in the Conduct console.
workspace_id no resolved from the token Usually unnecessary — the token owns its workspace.
fail_mode no fail_closed fail_closed blocks when Guard is unreachable, fail_open allows.
timeout no 8.0 Seconds. Guard checks return in <100ms in the healthy path.

Session tracking

Guard uses a session ID to correlate the pre-call check with any resume-verdict / HITL approval that follows. The adapter picks the first value it finds in this order:

  1. litellm_metadata.trace_id
  2. metadata.X-Conduct-Session-Id (explicit override — set this if you want deterministic control over the session boundary).
  3. metadata.conduct_session_id.
  4. A deterministic hash of the user field plus the first user message.

If none of the above are available and the caller sends no user or messages, session tracking is skipped (single-shot mode). Approvals still work — they just can't be resumed against a prior check.

Fail modes

  • fail_closed (default) — blocks the call if Guard is unreachable or the policy evaluator errors. Matches Conduct's default posture across every other enforcement surface.
  • fail_open — allows the call and logs a warning. Use during rollout or if Guard is a soft dependency for your setup.

License

conduct-litellm-guard is distributed under the same FSL-1.1-MIT license as the rest of Conduct. On 2028-08-23 it converts to MIT.

Links

  • Conduct Guard — the policy engine.
  • Conduct Router — Conduct's own LLM proxy.
  • Source — this package lives under packages/conduct-litellm-guard/.
  • Issues — file bugs and requests against the parent repo.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conduct_litellm_guard-0.1.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

conduct_litellm_guard-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file conduct_litellm_guard-0.1.0.tar.gz.

File metadata

  • Download URL: conduct_litellm_guard-0.1.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for conduct_litellm_guard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 98d6d46ee78e1c34151c300a4a9fc15789da10bb7299b26411f01a0908dc53bc
MD5 0fc4c353e26dfd63dd8cd42da4b99b1b
BLAKE2b-256 d9271b192746c0cb70f9f966fd95c362b628b1e163471610d79c2a54d39c68bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for conduct_litellm_guard-0.1.0.tar.gz:

Publisher: publish-litellm-guard.yml on sseshachala/conductai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file conduct_litellm_guard-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for conduct_litellm_guard-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 468b3b159751b72e3ad411f7987d736465a86d9539bbf7a736711f1e2b12af95
MD5 c541da06bc9e8ae220f20e041ab5333d
BLAKE2b-256 0c45e615b4e831557efcfbc8c4db9daf285a6ae62dd4da0220bc931cf36f750f

See more details on using hashes here.

Provenance

The following attestation bundles were made for conduct_litellm_guard-0.1.0-py3-none-any.whl:

Publisher: publish-litellm-guard.yml on sseshachala/conductai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page