akernel-runtime 0.1.0__py3-none-any.whl
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.
- akernel_runtime-0.1.0.dist-info/METADATA +270 -0
- akernel_runtime-0.1.0.dist-info/RECORD +40 -0
- akernel_runtime-0.1.0.dist-info/WHEEL +5 -0
- akernel_runtime-0.1.0.dist-info/entry_points.txt +2 -0
- akernel_runtime-0.1.0.dist-info/licenses/LICENSE +201 -0
- akernel_runtime-0.1.0.dist-info/licenses/NOTICE +4 -0
- akernel_runtime-0.1.0.dist-info/top_level.txt +1 -0
- context_kernel/__init__.py +4 -0
- context_kernel/__main__.py +5 -0
- context_kernel/agent_reports.py +188 -0
- context_kernel/benchmarks.py +493 -0
- context_kernel/budget.py +72 -0
- context_kernel/cli.py +2953 -0
- context_kernel/context.py +161 -0
- context_kernel/evals.py +347 -0
- context_kernel/global_memory.py +126 -0
- context_kernel/loop.py +1617 -0
- context_kernel/marketplace.py +194 -0
- context_kernel/marketplace_data/skills/context_budget.json +27 -0
- context_kernel/marketplace_data/skills/context_compaction.json +27 -0
- context_kernel/marketplace_data/skills/edit_file.json +27 -0
- context_kernel/marketplace_data/skills/index.json +66 -0
- context_kernel/marketplace_data/skills/long_task_planning.json +27 -0
- context_kernel/marketplace_data/skills/multi_file_bugfix.json +28 -0
- context_kernel/memory.py +515 -0
- context_kernel/models.py +144 -0
- context_kernel/planner.py +155 -0
- context_kernel/policy.py +271 -0
- context_kernel/project.py +317 -0
- context_kernel/providers.py +1264 -0
- context_kernel/report_costs.py +375 -0
- context_kernel/runner.py +78 -0
- context_kernel/skills.py +318 -0
- context_kernel/state_writer.py +108 -0
- context_kernel/storage.py +171 -0
- context_kernel/tasks.py +549 -0
- context_kernel/text.py +42 -0
- context_kernel/tokenizer.py +22 -0
- context_kernel/tools.py +544 -0
- context_kernel/verifier.py +77 -0
context_kernel/budget.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .models import Budget
|
|
4
|
+
from .tokenizer import estimate_tokens
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
DEFAULT_PROFILE = "balanced"
|
|
8
|
+
|
|
9
|
+
PROFILES = {
|
|
10
|
+
"lean": {
|
|
11
|
+
"default_total": 700,
|
|
12
|
+
"reserve_ratio": 0.24,
|
|
13
|
+
"runtime_ratio": 0.10,
|
|
14
|
+
"memory_ratio": 0.42,
|
|
15
|
+
"runtime_max": 110,
|
|
16
|
+
"min_reserve": 90,
|
|
17
|
+
},
|
|
18
|
+
"balanced": {
|
|
19
|
+
"default_total": 1200,
|
|
20
|
+
"reserve_ratio": 0.20,
|
|
21
|
+
"runtime_ratio": 0.12,
|
|
22
|
+
"memory_ratio": 0.50,
|
|
23
|
+
"runtime_max": 160,
|
|
24
|
+
"min_reserve": 120,
|
|
25
|
+
},
|
|
26
|
+
"deep": {
|
|
27
|
+
"default_total": 2400,
|
|
28
|
+
"reserve_ratio": 0.18,
|
|
29
|
+
"runtime_ratio": 0.12,
|
|
30
|
+
"memory_ratio": 0.58,
|
|
31
|
+
"runtime_max": 260,
|
|
32
|
+
"min_reserve": 180,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def profile_names() -> list[str]:
|
|
38
|
+
return sorted(PROFILES)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def default_budget(profile: str = DEFAULT_PROFILE) -> int:
|
|
42
|
+
return _profile(profile)["default_total"]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def allocate_budget(request: str, total: int | None = None, profile: str = DEFAULT_PROFILE) -> Budget:
|
|
46
|
+
settings = _profile(profile)
|
|
47
|
+
total = total or int(settings["default_total"])
|
|
48
|
+
if total < 300:
|
|
49
|
+
raise ValueError("Budget must be at least 300 tokens for the MVP runner.")
|
|
50
|
+
|
|
51
|
+
request_tokens = min(max(estimate_tokens(request), 80), total // 4)
|
|
52
|
+
reserve = max(int(settings["min_reserve"]), int(total * settings["reserve_ratio"]))
|
|
53
|
+
runtime = min(int(settings["runtime_max"]), max(60, int(total * settings["runtime_ratio"])))
|
|
54
|
+
remaining = total - request_tokens - reserve - runtime
|
|
55
|
+
memory = max(60, int(remaining * settings["memory_ratio"]))
|
|
56
|
+
skills = max(60, remaining - memory)
|
|
57
|
+
|
|
58
|
+
return Budget(
|
|
59
|
+
profile=profile,
|
|
60
|
+
total=total,
|
|
61
|
+
request=request_tokens,
|
|
62
|
+
runtime=runtime,
|
|
63
|
+
memory=memory,
|
|
64
|
+
skills=skills,
|
|
65
|
+
reserve=reserve,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _profile(profile: str) -> dict[str, float | int]:
|
|
70
|
+
if profile not in PROFILES:
|
|
71
|
+
raise ValueError(f"Unknown budget profile: {profile}. Expected one of: {', '.join(profile_names())}")
|
|
72
|
+
return PROFILES[profile]
|