Skip to main content

anosys-codex (Python)

AnoSys observability and analytics hook for OpenAI Codex CLI.

This package automatically captures Codex CLI's telemetry, agent turns, tool calls (shell, apply_patch, Code Mode custom tools, web_search), token usage breakdowns (prompt, completion, cache read/write, reasoning tokens), and estimated API costs, sending them directly to your AnoSys workspace.

It integrates seamlessly with Codex CLI's native notify hook mechanism.


Installation

pip install anosys-codex

After installing the package, run the setup wizard to configure the hook:

anosys-codex install

The installer will prompt you for:

  1. AnoSys API Key for logs: Your ingestion API key from the AnoSys Console.

    Pixel Type Requirement: This key must belong to a CC (Claude Code / Codex CLI) pixel. The installer automatically validates the key against https://console.anosys.ai/api/resolveapikeys to ensure it resolves to a /cc/ endpoint. Keys belonging to T (OTEL) or Web Traffic (a/g) pixels are rejected with a warning.

  2. Content Redaction: If enabled, sensitive conversation content (prompts, answers, code, tool inputs/outputs) will be redacted and replaced with [REDACTED]. Only metadata and token statistics will be tracked.
  3. Automatic Config Update: Confirms whether to automatically write notify = ["anosys-codex", "run"] to ~/.codex/config.toml (and creates a .bak backup first).

Non-Interactive / Headless Installation

For CI/CD pipelines, Docker containers, devcontainer setups, or non-interactive dotfiles:

anosys-codex install --api-key "your_logs_api_key" -y

Using environment variables:

export ANOSYS_API_KEY="your_logs_api_key"
anosys-codex install -y

Using explicit granular flags:

anosys-codex install \
  --api-key "your_logs_api_key" \
  --auto-update \
  --no-redaction

Important (Codex Security Trust): Codex requires explicit user approval for unmanaged external notify hooks. After running install, start a Codex CLI session, type /hooks, and select approve / trust for the anosys-codex run hook entry.


CLI Commands

The CLI safely manages ~/.codex/config.toml and creates automatic timestamped backups (config.toml.<TIMESTAMP>.bak) before applying any modifications.

status

Check the current installation and registration status of the hook:

anosys-codex status

install

Installs or updates the notify hook in ~/.codex/config.toml and creates ~/.codex/anosys-env.sh:

anosys-codex install [options]

Options:
  --api-key <key>             AnoSys logs API key
  -y, --yes                   Skip interactive prompts (non-interactive mode)
  --redaction                 Enable content redaction
  --no-redaction              Disable content redaction
  --auto-update               Automatically update ~/.codex/config.toml
  --no-auto-update            Print manual setup instructions instead of modifying config

uninstall

Safely removes the AnoSys notify hook entry from ~/.codex/config.toml and deletes ~/.codex/anosys-env.sh:

anosys-codex uninstall

run

Executed automatically by the Codex CLI on turn-complete notify events. You do not need to invoke this manually:

anosys-codex run

How It Works

  1. When a Codex turn completes, Codex CLI triggers notify = ["anosys-codex", "run"] defined in ~/.codex/config.toml.
  2. The hook runner receives the session thread ID and locates the session's rollout transcript at ~/.codex/sessions/YYYY/MM/DD/rollout-<ts>-<session_id>.jsonl.
  3. It incrementally extracts user prompts, assistant messages, model details, token counts (including cached inputs and reasoning tokens), and tool calls.
  4. It maps the turn into the AnoSys schema (cvs200: 'CodexHook'), estimates USD cost using OpenAI's model pricing table, applies optional PII redaction, and batches the payload to https://api.anosys.ai/ingestion.
  5. If network connectivity is temporarily unavailable, failed records are buffered locally in ~/.codex/state/pending_records.jsonl and automatically replayed on subsequent runs.

Environment Variables

Variable Description
ANOSYS_HOOK_APIKEY / ANOSYS_API_KEY AnoSys ingestion API key
ANOSYS_HOOK_ENDPOINT_URL Override default ingestion URL (https://api.anosys.ai/ingestion)
REDACTION / ANOSYS_REDACT_CONTENT Set to "true" to redact prompts, code, and tool outputs
ANOSYS_HOOK_DRY_RUN Set to "true" to log payloads to stderr without sending to network
CODEX_HOME Custom directory for Codex config and sessions (defaults to ~/.codex)

Metadata

Release files for anosys-codex 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anosys-codex 0.1.0
File Size Uploaded Provenance
anosys_codex-0.1.0.tar.gz 19.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for anosys-codex 0.1.0
File Interpreter ABI Platform
anosys_codex-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.8 kB

Release files / anosys_codex-0.1.0.tar.gz

Download URL anosys_codex-0.1.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
654bb5524615804fd0ebad2f76fe4a3579bc688e2196d1748539c8d48e189c34
BLAKE2b-256 checksum
How to use checksums
a6c7085c980fc8e976908917e1daf39eada39f3bc054e3b374b2df07fb1a2bd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / anosys_codex-0.1.0-py3-none-any.whl

Download URL anosys_codex-0.1.0-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5db4f89be8ea5e742d227df8160e3e408e23e30b94b5eda042ae9be46da45744
BLAKE2b-256 checksum
How to use checksums
c6470ed0316fad9080fb89f02cdf29c725c02fffe9b79303946bfa457cd44ce5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for anosys-codex 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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