Skip to main content

agentcompile

PyPI Python CI License

pip install agentcompile

Wrap your agent's model client. Jobs your agent repeats run compiled, with no model call; everything else goes to your model unchanged, with your own provider key.

from openai import OpenAI
import agentcompile

client = agentcompile.wrap(OpenAI(), key="ack_...")   # or AGENTCOMPILE_KEY

resp = client.chat.completions.create(
    model="gpt-5", messages=messages, tools=tools,
    conversation_id=ticket.id,                         # one id per conversation
)

Anthropic works the same way (agentcompile.wrap(Anthropic()), then client.messages.create(...)). So do async clients, streaming and tool calls. Instead of the keyword, you can set the id for a block of calls:

with agentcompile.conversation(ticket.id):
    run_agent(client)

What happens on each call

  1. With a conversation id, the SDK asks AgentCompile for a decision (/v1/decide; it waits at most timeout, default 2 s).
  2. compiled: the answer (a tool call or a reply) comes back in exactly the provider's response shape; your loop runs the tool as usual.
  3. forwarded: your model is called as normal.
  4. fail-open: AgentCompile errored, was slow or sent something unusable, so your model is called as normal.
  5. no conversation id: your model is called and no decision is made.

Your provider key never leaves your process. mode="shadow" decides but always calls your model, so you can see what it would have done before you switch it on.

The trail

Every call is written to ~/.agentcompile/trail.jsonl (trail= sets a path, or False turns it off; on_event= gets each event).

agentcompile trail          # recent calls and a summary
agentcompile trail -f       # follow live
14:02:11  c1            compiled         get_order_details                         gpt-5  48 ms decide
14:02:12  c2            forwarded        no job matched                            gpt-5  51 ms decide
2 calls: compiled 1, forwarded 1. Model calls avoided: 1 (50%).

Keys

Your AgentCompile key (ack_...) identifies your company by itself. We show it once and store only its hash; a new key revokes the old one. AgentCompile is pre-launch: to get a key, write to founders@tryagentcompile.com.

Releasing

Commit with conventional messages (fix: ... is a patch, feat: ... a minor version, feat!: ... a major one). A release PR stays open with the next version and its changelog; merging it tags the release and publishes it to PyPI. The version always comes from the git tag.

Development

pip install -e ".[dev]"
pytest tests

Metadata

Release files for agentcompile 0.2.1

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

Source distribution (sdist)

Source distribution for agentcompile 0.2.1
File Size Uploaded
agentcompile-0.2.1.tar.gz 20.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentcompile 0.2.1
File Interpreter ABI Platform
agentcompile-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.5 kB

Release files / agentcompile-0.2.1.tar.gz

Download URL agentcompile-0.2.1.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
50fbcf9de1bfcbfa3d171c6ed2f98bf28e89add6419702724bef7d89e2e95003
BLAKE2b-256 checksum
How to use checksums
d01f3a068543a631d5191bbe118fda2a97f31697e689bcb40d4e64a9d912bbcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / agentcompile-0.2.1-py3-none-any.whl

Download URL agentcompile-0.2.1-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba81cd84c1a9e987a12184ac9b68bfc2c11d9ad237f3c466454d81d3432f47a7
BLAKE2b-256 checksum
How to use checksums
0fd5c39a74550fedceb505f01875bf0411a1bcc950db00885bebc00220eb13b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release 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