agentcompile
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
- With a conversation id, the SDK asks AgentCompile for a decision (
/v1/decide; it waits at mosttimeout, default 2 s). - 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.
- forwarded: your model is called as normal.
- fail-open: AgentCompile errored, was slow or sent something unusable, so your model is called as normal.
- 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.
Development
pip install -e ".[dev]"
pytest tests
Metadata
Release files for agentcompile 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agentcompile-0.1.0.tar.gz | 16.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentcompile-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.9 kB
Release files / agentcompile-0.1.0.tar.gz
| Download URL | agentcompile-0.1.0.tar.gz |
|---|---|
| Size | 16.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36376d285df8744ca9b813e59af2e1c14e4cd54c2505b11a369b1ec0c01a2c7f
|
|
BLAKE2b-256 checksum How to use checksums |
b922b7d7548b20c4388b10a6d8cd98ba527622d99aa58f388f26dca610b22a5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Release files / agentcompile-0.1.0-py3-none-any.whl
| Download URL | agentcompile-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce7b546b7e36ac4fe7b43f78fd0e462778350d7f2cf7f9bff5e24d5fce603fe4
|
|
BLAKE2b-256 checksum How to use checksums |
c8b1bb6b62ed156b0a2cc1360ddeb5746325f53db5e5c6650cc22aaaff5efd2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|