agent-jit-runtime 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_jit_runtime-0.1.0/.gitattributes +1 -0
- agent_jit_runtime-0.1.0/.github/workflows/ci.yml +19 -0
- agent_jit_runtime-0.1.0/.gitignore +11 -0
- agent_jit_runtime-0.1.0/CLAUDE.md +18 -0
- agent_jit_runtime-0.1.0/LICENSE +202 -0
- agent_jit_runtime-0.1.0/PKG-INFO +223 -0
- agent_jit_runtime-0.1.0/README.md +200 -0
- agent_jit_runtime-0.1.0/START_HERE.md +52 -0
- agent_jit_runtime-0.1.0/benchmarks/ablation_eval.py +134 -0
- agent_jit_runtime-0.1.0/benchmarks/appworld_check1.py +229 -0
- agent_jit_runtime-0.1.0/benchmarks/appworld_eval.py +256 -0
- agent_jit_runtime-0.1.0/benchmarks/appworld_facts.py +60 -0
- agent_jit_runtime-0.1.0/benchmarks/drift_eval.py +74 -0
- agent_jit_runtime-0.1.0/benchmarks/explain_compile.py +64 -0
- agent_jit_runtime-0.1.0/benchmarks/local_tool_calling.py +513 -0
- agent_jit_runtime-0.1.0/benchmarks/plot_payback.py +109 -0
- agent_jit_runtime-0.1.0/benchmarks/results/ablation_mock.json +110 -0
- agent_jit_runtime-0.1.0/benchmarks/results/appworld_check1.json +533 -0
- agent_jit_runtime-0.1.0/benchmarks/results/appworld_facts.json +86 -0
- agent_jit_runtime-0.1.0/benchmarks/results/appworld_haiku_smoke.json +83 -0
- agent_jit_runtime-0.1.0/benchmarks/results/appworld_triples.json +380 -0
- agent_jit_runtime-0.1.0/benchmarks/results/appworld_triples_diagnosis.json +28 -0
- agent_jit_runtime-0.1.0/benchmarks/results/appworld_triples_diagnosis_after_list_items.json +28 -0
- agent_jit_runtime-0.1.0/benchmarks/results/drift_mock.json +42 -0
- agent_jit_runtime-0.1.0/benchmarks/results/local_tool_calling_easy.json +53 -0
- agent_jit_runtime-0.1.0/benchmarks/results/local_tool_calling_easy_all.json +121 -0
- agent_jit_runtime-0.1.0/benchmarks/results/local_tool_calling_hard.json +56 -0
- agent_jit_runtime-0.1.0/benchmarks/results/local_tool_calling_hard_all.json +128 -0
- agent_jit_runtime-0.1.0/benchmarks/results/support_desk_gemma4.json +2232 -0
- agent_jit_runtime-0.1.0/benchmarks/results/support_desk_gemma4_gated.json +2234 -0
- agent_jit_runtime-0.1.0/benchmarks/results/support_desk_haiku_seed11.json +980 -0
- agent_jit_runtime-0.1.0/benchmarks/results/support_desk_haiku_seed12.json +974 -0
- agent_jit_runtime-0.1.0/benchmarks/results/support_desk_haiku_seed13.json +946 -0
- agent_jit_runtime-0.1.0/benchmarks/results/support_desk_mock.json +2247 -0
- agent_jit_runtime-0.1.0/benchmarks/support_desk_eval.py +209 -0
- agent_jit_runtime-0.1.0/docs/PLAN.md +161 -0
- agent_jit_runtime-0.1.0/docs/ablations.md +60 -0
- agent_jit_runtime-0.1.0/docs/appworld-results.md +56 -0
- agent_jit_runtime-0.1.0/docs/blog-post.md +68 -0
- agent_jit_runtime-0.1.0/docs/payback-haiku.svg +43 -0
- agent_jit_runtime-0.1.0/docs/prior-work-notes.md +93 -0
- agent_jit_runtime-0.1.0/docs/superpowers/plans/2026-11-28-agent-jit-milestone-1.md +438 -0
- agent_jit_runtime-0.1.0/docs/superpowers/plans/2026-11-28-agent-jit-milestone-2.md +262 -0
- agent_jit_runtime-0.1.0/docs/superpowers/plans/2026-11-29-agent-jit-milestone-3.md +114 -0
- agent_jit_runtime-0.1.0/docs/superpowers/plans/2026-11-29-support-desk-workload.md +51 -0
- agent_jit_runtime-0.1.0/docs/superpowers/specs/2026-11-28-agent-jit-design.md +119 -0
- agent_jit_runtime-0.1.0/docs/support-desk-results.md +111 -0
- agent_jit_runtime-0.1.0/docs/week1-appworld-checks.md +93 -0
- agent_jit_runtime-0.1.0/pyproject.toml +58 -0
- agent_jit_runtime-0.1.0/src/agent_jit/__init__.py +5 -0
- agent_jit_runtime-0.1.0/src/agent_jit/adapters/__init__.py +1 -0
- agent_jit_runtime-0.1.0/src/agent_jit/adapters/anthropic.py +160 -0
- agent_jit_runtime-0.1.0/src/agent_jit/adapters/appworld.py +93 -0
- agent_jit_runtime-0.1.0/src/agent_jit/adapters/loop_agent.py +35 -0
- agent_jit_runtime-0.1.0/src/agent_jit/adapters/ollama.py +113 -0
- agent_jit_runtime-0.1.0/src/agent_jit/branches.py +74 -0
- agent_jit_runtime-0.1.0/src/agent_jit/compiler.py +659 -0
- agent_jit_runtime-0.1.0/src/agent_jit/core.py +390 -0
- agent_jit_runtime-0.1.0/src/agent_jit/demo.py +238 -0
- agent_jit_runtime-0.1.0/src/agent_jit/eval/__init__.py +1 -0
- agent_jit_runtime-0.1.0/src/agent_jit/eval/baselines.py +94 -0
- agent_jit_runtime-0.1.0/src/agent_jit/eval/harness.py +124 -0
- agent_jit_runtime-0.1.0/src/agent_jit/eval/metrics.py +49 -0
- agent_jit_runtime-0.1.0/src/agent_jit/eval/supportdesk.py +446 -0
- agent_jit_runtime-0.1.0/src/agent_jit/guards.py +185 -0
- agent_jit_runtime-0.1.0/src/agent_jit/ir.py +64 -0
- agent_jit_runtime-0.1.0/src/agent_jit/journal.py +219 -0
- agent_jit_runtime-0.1.0/src/agent_jit/provenance.py +460 -0
- agent_jit_runtime-0.1.0/src/agent_jit/py.typed +0 -0
- agent_jit_runtime-0.1.0/src/agent_jit/roi.py +20 -0
- agent_jit_runtime-0.1.0/src/agent_jit/router.py +136 -0
- agent_jit_runtime-0.1.0/src/agent_jit/runtime.py +137 -0
- agent_jit_runtime-0.1.0/src/agent_jit/slicer.py +66 -0
- agent_jit_runtime-0.1.0/src/agent_jit/stats.py +75 -0
- agent_jit_runtime-0.1.0/src/agent_jit/store.py +114 -0
- agent_jit_runtime-0.1.0/src/agent_jit/tools.py +81 -0
- agent_jit_runtime-0.1.0/src/agent_jit/tracer.py +57 -0
- agent_jit_runtime-0.1.0/tasks/lessons.md +8 -0
- agent_jit_runtime-0.1.0/tests/__init__.py +0 -0
- agent_jit_runtime-0.1.0/tests/chaos/__init__.py +0 -0
- agent_jit_runtime-0.1.0/tests/chaos/test_faults.py +124 -0
- agent_jit_runtime-0.1.0/tests/chaos/test_router_faults.py +79 -0
- agent_jit_runtime-0.1.0/tests/conftest.py +110 -0
- agent_jit_runtime-0.1.0/tests/property/__init__.py +0 -0
- agent_jit_runtime-0.1.0/tests/property/test_guard_before_write.py +58 -0
- agent_jit_runtime-0.1.0/tests/property/test_history_schema.py +41 -0
- agent_jit_runtime-0.1.0/tests/property/test_no_double_write.py +54 -0
- agent_jit_runtime-0.1.0/tests/property/test_routing_and_items.py +125 -0
- agent_jit_runtime-0.1.0/tests/toy_agent.py +115 -0
- agent_jit_runtime-0.1.0/tests/unit/__init__.py +0 -0
- agent_jit_runtime-0.1.0/tests/unit/test_answer_dependencies.py +79 -0
- agent_jit_runtime-0.1.0/tests/unit/test_anthropic_adapter.py +165 -0
- agent_jit_runtime-0.1.0/tests/unit/test_appworld_adapter.py +133 -0
- agent_jit_runtime-0.1.0/tests/unit/test_branches.py +82 -0
- agent_jit_runtime-0.1.0/tests/unit/test_compiler.py +209 -0
- agent_jit_runtime-0.1.0/tests/unit/test_compiler_branches.py +233 -0
- agent_jit_runtime-0.1.0/tests/unit/test_core.py +130 -0
- agent_jit_runtime-0.1.0/tests/unit/test_core_m2.py +207 -0
- agent_jit_runtime-0.1.0/tests/unit/test_demo.py +69 -0
- agent_jit_runtime-0.1.0/tests/unit/test_desk_drift.py +86 -0
- agent_jit_runtime-0.1.0/tests/unit/test_eval_baselines.py +98 -0
- agent_jit_runtime-0.1.0/tests/unit/test_eval_harness.py +193 -0
- agent_jit_runtime-0.1.0/tests/unit/test_eval_metrics.py +50 -0
- agent_jit_runtime-0.1.0/tests/unit/test_final_review.py +199 -0
- agent_jit_runtime-0.1.0/tests/unit/test_guards.py +160 -0
- agent_jit_runtime-0.1.0/tests/unit/test_journal.py +220 -0
- agent_jit_runtime-0.1.0/tests/unit/test_list_items.py +106 -0
- agent_jit_runtime-0.1.0/tests/unit/test_loop_agent.py +76 -0
- agent_jit_runtime-0.1.0/tests/unit/test_ollama_adapter.py +104 -0
- agent_jit_runtime-0.1.0/tests/unit/test_prefix.py +96 -0
- agent_jit_runtime-0.1.0/tests/unit/test_provenance.py +260 -0
- agent_jit_runtime-0.1.0/tests/unit/test_recording.py +45 -0
- agent_jit_runtime-0.1.0/tests/unit/test_request_shapes.py +158 -0
- agent_jit_runtime-0.1.0/tests/unit/test_review_fixes.py +108 -0
- agent_jit_runtime-0.1.0/tests/unit/test_roi.py +38 -0
- agent_jit_runtime-0.1.0/tests/unit/test_router.py +205 -0
- agent_jit_runtime-0.1.0/tests/unit/test_runtime.py +154 -0
- agent_jit_runtime-0.1.0/tests/unit/test_schema_hash.py +92 -0
- agent_jit_runtime-0.1.0/tests/unit/test_slicer.py +111 -0
- agent_jit_runtime-0.1.0/tests/unit/test_stats.py +80 -0
- agent_jit_runtime-0.1.0/tests/unit/test_supportdesk.py +123 -0
- agent_jit_runtime-0.1.0/tests/unit/test_tools.py +22 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto eol=lf
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
pull_request:
|
|
5
|
+
jobs:
|
|
6
|
+
check:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
strategy:
|
|
9
|
+
matrix:
|
|
10
|
+
python: ["3.11", "3.12"]
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: actions/setup-python@v5
|
|
14
|
+
with:
|
|
15
|
+
python-version: ${{ matrix.python }}
|
|
16
|
+
- run: pip install -e ".[dev]"
|
|
17
|
+
- run: ruff check .
|
|
18
|
+
- run: mypy --strict src tests
|
|
19
|
+
- run: pytest
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# agent-jit
|
|
2
|
+
|
|
3
|
+
A tracing-JIT runtime for tool-using LLM agents. Read `docs/PLAN.md` before any task: it holds the
|
|
4
|
+
design decisions, the verified prior work and the evaluation plan.
|
|
5
|
+
|
|
6
|
+
## Rules
|
|
7
|
+
|
|
8
|
+
1. **Never invent results.** Every number in docs, README, commits or a CV bullet is either
|
|
9
|
+
measured by a script in `benchmarks/` (with the command to reproduce it) or labeled as a target.
|
|
10
|
+
2. **Net cost includes compile cost.** Never report savings without the tokens the compiler spent.
|
|
11
|
+
3. **Prior work is cited, never claimed missing.** Before writing "nothing does X", re-check
|
|
12
|
+
`docs/PLAN.md` section 2 and search again; the field publishes monthly.
|
|
13
|
+
4. **Safety first in the runtime.** A mutating tool never runs after a failed guard; completed
|
|
14
|
+
steps are never re-executed on fallback; unannotated tools are treated as `write`.
|
|
15
|
+
5. **Small, tested steps.** Every module lands with unit tests; property-based tests guard the
|
|
16
|
+
runtime invariants. CI must stay green (ruff, mypy --strict, pytest).
|
|
17
|
+
6. **Keep it a library.** Middleware that wraps existing agents, not a new agent framework.
|
|
18
|
+
7. Commit and push at the end of every working session; uncommitted work is lost.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agent-jit-runtime
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A tracing-JIT runtime for tool-using LLM agents
|
|
5
|
+
Project-URL: Homepage, https://github.com/Rayyan-Oumlil/agent-jit
|
|
6
|
+
Project-URL: Issues, https://github.com/Rayyan-Oumlil/agent-jit/issues
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: agents,cost-reduction,jit,llm,tool-use
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Typing :: Typed
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: hypothesis>=6.100; extra == 'dev'
|
|
18
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
19
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
21
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# agent-jit
|
|
25
|
+
|
|
26
|
+
**A JIT compiler for LLM agents.** agent-jit watches a tool-using agent work, spots the multi-step
|
|
27
|
+
tasks it repeats, and compiles them into guarded Python code that runs without the inner-loop LLM.
|
|
28
|
+
When a guard fails mid-run, it hands the job back to the agent as already-executed tool history, and
|
|
29
|
+
a journal at the tool boundary stops a write from running twice.
|
|
30
|
+
|
|
31
|
+
> **Status: 0.1.0 (alpha). All four milestones are on `main`: the runtime, safety rules, evaluation
|
|
32
|
+
> harness, property and chaos tests, ablations, a drift workload and a write-up.** An end-to-end toy
|
|
33
|
+
> demo works with a mock LLM and no API key. On AppWorld nothing compiled (no savings). On a
|
|
34
|
+
> repeated-request support-desk workload agent-jit used fewer tokens at equal success; every number,
|
|
35
|
+
> its caveats and its command are under "Evaluation" and in
|
|
36
|
+
> [docs/support-desk-results.md](docs/support-desk-results.md).
|
|
37
|
+
> Design: [docs/PLAN.md](docs/PLAN.md) and
|
|
38
|
+
> [docs/superpowers/specs/2026-11-28-agent-jit-design.md](docs/superpowers/specs/2026-11-28-agent-jit-design.md).
|
|
39
|
+
|
|
40
|
+
## Evaluation (milestone 3)
|
|
41
|
+
|
|
42
|
+
What exists, all under `src/agent_jit/adapters/`, `src/agent_jit/eval/` and `benchmarks/`:
|
|
43
|
+
|
|
44
|
+
- `adapters/appworld.py`: exposes AppWorld's APIs as discrete tools (reads: `show_*`, `search_*`,
|
|
45
|
+
`login`; everything else is treated as a write).
|
|
46
|
+
- `adapters/anthropic.py`: a client restricted to `claude-haiku-5-5`. It refuses a call whose
|
|
47
|
+
estimated size (about 3 characters per token, plus the largest possible reply) would take the spend
|
|
48
|
+
past the budget, and tracks usage per token kind because cache reads and writes are priced
|
|
49
|
+
differently. The estimate is rough, so the budget is a tight guard, not an exact limit.
|
|
50
|
+
- `eval/`: baselines (plain agent, exact-match cache, a lexical semantic cache, a one-shot replay in
|
|
51
|
+
the spirit of LOOP), metrics (net tokens including compile tokens, hit/fallback rate, latency
|
|
52
|
+
percentiles) and an episode harness that scores every episode with the environment's own check.
|
|
53
|
+
- `benchmarks/appworld_eval.py --llm mock` runs all of it on real AppWorld worlds with a mock model
|
|
54
|
+
(plumbing only, it never solves a task).
|
|
55
|
+
|
|
56
|
+
Caveats that apply to any result from this harness: the success signal agent-jit records with is
|
|
57
|
+
AppWorld's own ground-truth evaluator (an oracle, which a deployment would not have), the baselines
|
|
58
|
+
record runs whether or not they succeeded, the JIT's latency includes that one evaluator call per
|
|
59
|
+
run, and the cost of a run is estimated from list prices, not billed.
|
|
60
|
+
|
|
61
|
+
Measured so far, with the command that reproduces each:
|
|
62
|
+
|
|
63
|
+
| What | Result | Command |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| AppWorld facts: 457 function-calling tools, 256,659 characters of schema, train 90 / dev 57 tasks, scorer accepts the known answer | see the JSON | `python benchmarks/appworld_facts.py` |
|
|
66
|
+
| Three local models (gemma4:e4b, qwen3.5:9b, nemotron-3-nano:4b) on 10 AppWorld train tasks each | 0/30 passed | `python benchmarks/appworld_check1.py --models gemma4:e4b qwen3.5:9b nemotron-3-nano:4b` (inside the AppWorld venv) |
|
|
67
|
+
| Haiku 5.5 on 5 AppWorld scenarios x 3 tasks, plain agent vs agent-jit | 12/15 passed by both; agent-jit compiled 0 skills (no savings result), see the diagnosis | `python benchmarks/appworld_eval.py --llm haiku --scenarios 5 --systems plain jit --budget-usd 1.0`; details in [docs/appworld-results.md](docs/appworld-results.md) |
|
|
68
|
+
| Support-desk workload (36 requests, 6 types), gemma4:e4b, plain vs agent-jit | plain 31/36, 38,976 tokens; jit 33/36, 39% hit, 30,458 tokens (-22%); loose caches 8/36 | `python benchmarks/support_desk_eval.py --llm ollama --model gemma4:e4b`; details in [docs/support-desk-results.md](docs/support-desk-results.md) |
|
|
69
|
+
| Same workload on Haiku 5.5, 3 seeds, plain vs agent-jit | 108/108 for both; tokens 99,326 vs 75,016 on average (-24%, range -19% to -33%), but estimated dollars only about -6% (range -4.5% to -8%) because most tokens are cheap cache reads; about $0.04 per pass | `python benchmarks/support_desk_eval.py --llm haiku --budget-usd 0.15 --systems plain jit --seed 11` (also 12, 13) |
|
|
70
|
+
| Drift workload (mock policy): tools that do not validate, valid and invalid orders mixed after a warm-up | plain 36/36; agent-jit 36/36 (12/12 invalid requests stopped by a guard, 33% fallbacks); agent-jit with guards switched off 24/36, 12 wrong writes | `python benchmarks/drift_eval.py`; details in [docs/ablations.md](docs/ablations.md) |
|
|
71
|
+
|
|
72
|
+
Payback chart (Haiku, three seeds; cumulative net tokens, compile cost included, which is 0 here):
|
|
73
|
+

|
|
74
|
+
Regenerate with `python benchmarks/plot_payback.py`. The curves flatten once skills compile; the
|
|
75
|
+
dollar saving is smaller than this token view suggests (see the results doc).
|
|
76
|
+
|
|
77
|
+
Also: ablations of the safety rules in [docs/ablations.md](docs/ablations.md), a write-up in
|
|
78
|
+
[docs/blog-post.md](docs/blog-post.md), and details and caveats in
|
|
79
|
+
[docs/week1-appworld-checks.md](docs/week1-appworld-checks.md).
|
|
80
|
+
|
|
81
|
+
## Try it (no API key)
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install agent-jit-runtime # (import agent_jit) or, from a checkout: pip install -e ".[dev]"
|
|
85
|
+
python -m agent_jit.demo
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The demo runs a toy refund agent five times against a mock LLM (a deterministic script):
|
|
89
|
+
|
|
90
|
+
| Run | What happens |
|
|
91
|
+
|---|---|
|
|
92
|
+
| 1, 2 | The agent runs normally and is recorded. After run 2 the repeated pattern is compiled. |
|
|
93
|
+
| 3 | A router (one LLM call) picks the compiled skill; zero inner-loop LLM calls. |
|
|
94
|
+
| 4 | A guard fails *after* the refund ran. The agent resumes, asks to refund again, and the journal answers without executing. |
|
|
95
|
+
| 5 | A guard fails before any write. The agent finishes without refunding. |
|
|
96
|
+
|
|
97
|
+
The token counts it prints, including the final `stats` line, come from the mock script; they are
|
|
98
|
+
not measurements.
|
|
99
|
+
|
|
100
|
+
## How it works
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
request ──> router (1 LLM call) ──hit──> compiled skill ──guards ok──> answer
|
|
104
|
+
│ │
|
|
105
|
+
│ miss └─guard fails─> agent continues from synthetic
|
|
106
|
+
v tool history (journal blocks repeats)
|
|
107
|
+
plain agent ──> RecordingTools(JournaledTools(tools)) ──> traces (SQLite)
|
|
108
|
+
│
|
|
109
|
+
bind arguments, slice dead reads, synthesize guards, emit Python
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
1. **Record**: every run is stored as a trace (`tracer.py`, `store.py`).
|
|
113
|
+
2. **Bind**: each tool argument is traced to the request (a parameter), an earlier tool output (a
|
|
114
|
+
data dependency) or a constant seen in at least two traces (`provenance.py`). An argument that
|
|
115
|
+
cannot be traced makes compilation refuse.
|
|
116
|
+
3. **Slice**: failed reads and reads nothing depends on after the last write are dropped; a
|
|
117
|
+
successful read before a write is always kept (`slicer.py`).
|
|
118
|
+
4. **Guard**: invariants that held in every successful trace become checks (`guards.py`).
|
|
119
|
+
5. **Compile**: readable Python source, validated against a whitelist before it ever runs
|
|
120
|
+
(`compiler.py`).
|
|
121
|
+
6. **Run and fall back**: `runtime.py`, `router.py`, `core.py`.
|
|
122
|
+
|
|
123
|
+
Around that loop, milestone 2 adds four guards on *when* a skill may run:
|
|
124
|
+
|
|
125
|
+
- **Schema invalidation**: every tool's schema, effect and idempotency key are hashed
|
|
126
|
+
(`schema_hash`). A skill whose tools changed is no longer offered to the router, and traces
|
|
127
|
+
recorded under an older schema never feed a new compile (`Wrapped.disabled` says why).
|
|
128
|
+
- **Circuit breaker**: a skill that fell back on more than half of its recent runs (default: at
|
|
129
|
+
least 5 runs, window 10) is switched off for good (`stats.py`).
|
|
130
|
+
- **ROI gate**: a group is compiled only if its mean inner-loop tokens exceed the router's
|
|
131
|
+
per-request cost (`roi.py`); declined groups appear in `Wrapped.skipped`. The router cost is
|
|
132
|
+
`router_token_estimate`, else the mean seen so far, else `DEFAULT_ROUTER_TOKENS` (100). That
|
|
133
|
+
default is a placeholder, **not a measurement**: set the estimate for your own router.
|
|
134
|
+
- **Branches**: when two kinds of request start with the same tool but diverge later, one skill can
|
|
135
|
+
branch on a value read before they diverge (`branches.py`, `compile_branched`). A run whose value
|
|
136
|
+
matches no known branch stops and falls back. Each branch re-checks its own guards on the shared
|
|
137
|
+
steps before any of its tools run.
|
|
138
|
+
|
|
139
|
+
A generated skill (from the demo):
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
async def run(ctx, *, order_id):
|
|
143
|
+
s0 = await ctx.call(0, 'get_order', {'order_id': order_id}, GUARDS)
|
|
144
|
+
s1 = await ctx.call(1, 'get_customer', {'customer_id': ctx.get(s0, ('customer_id',), 'identity')}, GUARDS)
|
|
145
|
+
s2 = await ctx.call(2, 'refund_order', {'order_id': order_id, 'amount': ctx.get(s0, ('amount',), 'identity')}, GUARDS)
|
|
146
|
+
...
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Safety guarantees (and what they are not)
|
|
150
|
+
|
|
151
|
+
- Compiled code runs no further tool after a failed guard. What happens next is up to the agent
|
|
152
|
+
that takes over (in the demo's run 4 it asks to refund again, and the journal blocks the repeat).
|
|
153
|
+
Unannotated tools are treated as `write`; `irreversible` tools are never compiled.
|
|
154
|
+
- **The runtime does not knowingly repeat a mutating call within a run.** Each mutating call is
|
|
155
|
+
journaled before it runs. If its outcome is unknown (timeout, cancellation, unclassified error),
|
|
156
|
+
the run performs no further write and says a human must check.
|
|
157
|
+
- Tool output and trace data reach generated source only through `repr()` of validated literals, and
|
|
158
|
+
skills are re-checked against an AST whitelist at load time.
|
|
159
|
+
- The router can only choose a skill and copy values that literally appear in the request.
|
|
160
|
+
|
|
161
|
+
**This is not exactly-once.** See the limits below.
|
|
162
|
+
|
|
163
|
+
## Limits
|
|
164
|
+
|
|
165
|
+
- Not exactly-once: a crash can leave a call `unknown`, and resuming after a process crash is not
|
|
166
|
+
supported.
|
|
167
|
+
- A fallback agent that repeats a write with *different* arguments is not caught.
|
|
168
|
+
- A condition the traces never read cannot be guarded. Numbers are guarded only by type and sign,
|
|
169
|
+
so a threshold such as "under 30 days" read from a tool is not checked.
|
|
170
|
+
- With few traces a value can coincide by chance. Writes refuse the cases it can detect (a request
|
|
171
|
+
value that also appears in an earlier output, two output fields with the same value, a numeric
|
|
172
|
+
constant), but a coincidence across only two traces can still bind to the wrong source.
|
|
173
|
+
- An id written with a prefix (`ORD-9001` for tool value `9001`) binds only when every trace uses
|
|
174
|
+
the same prefix. Numbers written like `1,234` are not matched in requests, so those requests go
|
|
175
|
+
to the plain agent.
|
|
176
|
+
- Traces recorded before milestone 2 carry no schema hashes, so they are never used for compiling.
|
|
177
|
+
- Branching refuses when two different values both separate the groups (a coincidence is likelier
|
|
178
|
+
than a decision) or when a write happens before the branch value is read.
|
|
179
|
+
- Branches need a categorical discriminator: a boolean or a short, digit-free string read in a step
|
|
180
|
+
before the groups diverge. A request kind whose tool sequence is a strict prefix of another's
|
|
181
|
+
cannot be separated and is refused as ambiguous. The router runs a skill only for a request whose
|
|
182
|
+
wording (with parameter values masked) matches one it was learned from, and a branched skill with
|
|
183
|
+
a writing branch is refused unless all its groups were worded alike, so a paraphrase goes to the
|
|
184
|
+
plain agent. Fallback runs are never compiled.
|
|
185
|
+
- Loops over lists are not compiled. A *read* argument may be taken from a list item past the first
|
|
186
|
+
(for example the password of one account in a list of accounts); the item's fields are then guarded
|
|
187
|
+
so a reordered list fails a guard. This is refused unless some field of the item is identical in
|
|
188
|
+
every trace. The item is still found by position: if two items share that identifying value, the
|
|
189
|
+
guard cannot tell them apart (a known limitation). A *write* argument is never taken from a later
|
|
190
|
+
list item directly.
|
|
191
|
+
- A value the model computed itself (a maximum, a sum, a choice among items) is not traceable to any
|
|
192
|
+
tool output, so a step that passes it on is refused.
|
|
193
|
+
- Retried runs (a failed step followed by a retry) are not compiled.
|
|
194
|
+
- A request value that also appears in an earlier tool output is refused for writes (the source is
|
|
195
|
+
ambiguous), except when the output merely echoes the request value.
|
|
196
|
+
- Bookkeeping that fails after a run's tools already ran (an unsavable trace, a compile error) is
|
|
197
|
+
reported in `Wrapped.problems` / `Wrapped.refusals`, never raised.
|
|
198
|
+
- Skills live as long as the `Wrapped` object; one database file is assumed to serve one agent.
|
|
199
|
+
- A tripped circuit breaker is not re-armed by hand; only new evidence (a new request kind or a
|
|
200
|
+
schema change) produces a new skill. The router cost used by the ROI gate is an estimate until
|
|
201
|
+
real runs have been observed.
|
|
202
|
+
|
|
203
|
+
## Results
|
|
204
|
+
|
|
205
|
+
See the measured-results table under "Evaluation" above. Every number there comes from a script in
|
|
206
|
+
`benchmarks/` with its command; the compiler spends no tokens (it is deterministic Python).
|
|
207
|
+
|
|
208
|
+
## Development
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
pip install -e ".[dev]"
|
|
212
|
+
ruff check . && mypy --strict src tests && pytest
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Prior work
|
|
216
|
+
|
|
217
|
+
Closest published work, to be read and cited, not claimed missing: TraceCompiler (arXiv 2608.02680),
|
|
218
|
+
which compiles agent traces offline and states it has no runtime; ReTrace (2611.14492), AgentPRO
|
|
219
|
+
(2611.00628) and SkillCache (2611.10022). See [docs/prior-work-notes.md](docs/prior-work-notes.md).
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
Apache-2.0.
|