Skip to main content

AI coding agent with per-tool permissions, cost tracking, and token optimization

Project description

Cohrint Agent

AI coding agent with per-tool permissions, cost tracking, prompt optimization, and anomaly detection. Works across Claude (API), Claude Code, Codex CLI, and Gemini CLI.

Install

pip install cohrint-agent

Requires Python 3.9+.

Quick Start

Interactive REPL

# Set your API key, then launch
export ANTHROPIC_API_KEY=sk-...
cohrint-agent

One-shot prompt

cohrint-agent "explain the main function in cli.py"

Pipe mode

echo "summarize this file" | cohrint-agent

Backends

Cohrint auto-detects the best backend. You can override with --backend:

Backend Description Requires
api Direct Anthropic API (exact token counts) ANTHROPIC_API_KEY
claude Claude Code subprocess (free tier / subscription) claude binary
codex OpenAI Codex CLI subprocess codex binary
gemini Gemini CLI subprocess gemini binary
cohrint-agent --backend claude "refactor this function"
cohrint-agent --backend codex "write unit tests for auth.py"

Auto-detect priority: COHRINT_BACKEND env → ANTHROPIC_API_KEYclaude binary → codex binary → gemini binary.

Session Management

Sessions are persisted to ~/.cohrint/sessions/. Resume any previous session:

# List sessions and costs
cohrint-agent summary

# Resume by session ID
cohrint-agent --resume abc12345

REPL Commands

Command Description
/help Show all commands
/tools Show tool approval status
/allow Bash,Write Approve specific tools
/allow all Approve all tools for this session
/cost Show current session cost
/optimize on|off Toggle prompt optimization
/model claude-opus-4-6 Switch model mid-session
/reset Clear history, permissions, cost
/quit Exit (shows final cost summary)

Cost Tracking

Every turn shows token usage and cost. Exit shows a full session summary:

  +----- Cost Summary -----+
  Model:             claude-sonnet-4-6
  Input tokens:      1,234
  Output tokens:     456
  Cost:              $0.0123
  Session total:     $0.0456
  Prompts:           3
  +-------------------------+

For Claude Code / Codex / Gemini (subscription or free tier), costs are labeled ~$0.00 (free tier) or ~$0.0123 (estimated).

Cohrint Dashboard

Send telemetry to your Cohrint dashboard for cross-session cost analysis:

export COHRINT_API_KEY=crt_...
cohrint-agent

Or pass inline: cohrint-agent --cohrint-key crt_...

All Flags

cohrint-agent [OPTIONS] [PROMPT]

  PROMPT              One-shot prompt (omit for interactive REPL)

  --backend           api | claude | codex | gemini (auto-detected)
  --model             Model ID (default: claude-sonnet-4-6)
  --max-tokens        Max output tokens (default: 16384)
  --resume SESSION_ID Resume a previous session
  --api-key           Anthropic API key (or ANTHROPIC_API_KEY env)
  --cohrint-key       Cohrint dashboard API key (or COHRINT_API_KEY env)
  --system            Custom system prompt
  --no-optimize       Disable prompt optimization
  --cwd               Set working directory
  --debug             Enable debug output

Environment Variables

Variable Description
ANTHROPIC_API_KEY Anthropic API key
COHRINT_API_KEY Cohrint dashboard key
COHRINT_BACKEND Force backend (api/claude/codex/gemini)
COHRINT_MODEL Default model override

License

MIT

Project details


Download files

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

Source Distribution

cohrint_agent-0.4.1.tar.gz (194.3 kB view details)

Uploaded Source

Built Distribution

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

cohrint_agent-0.4.1-py3-none-any.whl (134.4 kB view details)

Uploaded Python 3

File details

Details for the file cohrint_agent-0.4.1.tar.gz.

File metadata

  • Download URL: cohrint_agent-0.4.1.tar.gz
  • Upload date:
  • Size: 194.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cohrint_agent-0.4.1.tar.gz
Algorithm Hash digest
SHA256 471381a5004cecf64c7c800bd02ba3cda31c7605fa455c27baa99b9ea52fc1be
MD5 40e2bb44cd666c6b5c0e51b0ed48f94a
BLAKE2b-256 0aa021448eceb16d82b874a292b4d8a03d194922ba563f13bd6f46d93f5693fc

See more details on using hashes here.

File details

Details for the file cohrint_agent-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: cohrint_agent-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 134.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cohrint_agent-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 184f7b088baafd879799612f14e446e127ce744a3906c7dec1e07cb58c4f5a25
MD5 8a270b77787d72875a5f2c959c45b96b
BLAKE2b-256 ee61c8b8b16a45bd54f03f2ec5e17d528d8179b0d30e0fc9fbb1e7d5b1fc59a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page