Price tool schemas by JSON density and compute them once
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 38/100
Direzione di ricerca
Start in account_tools() in src/agent/run.rs, which sums tool name, description and serialized parameter lengths, then read the chars_per_token calibration in src/context/budget.rs. Move the schema sizing into a value computed once when Core is built, and add a separate JSON density constant so prose calibration can't affect it. Done when the first-call estimate is within 8% of usage.prompt_tokens, no schema serde_json::to_string remains in run_loop, and a unit test pins the constant.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
account_tools() divides the serialized schema length by chars_per_token, which is calibrated on prose and defaults to 3.5. JSON keys, quotes and type names tokenize closer to 2.5-2.6 characters per token, so the 24 schemas are booked at roughly 2.3k tokens when they cost closer to 3.3k. The undercount delays compaction until the server rejects the request or truncates it.
The same function also re-serializes all 24 schemas with serde_json::to_string on every loop iteration, which is pure allocation churn.
Evidence
src/agent/run.rs,account_tools(): sumsname.len() + description.len() + serde_json::to_string(&tool.parameters).len()and callsestimate_char_len.src/context/budget.rs: onechars_per_tokenfor all text, calibrated from prose.- The schema JSON is static for the life of the process.
Proposal
Compute tool_specs_chars and tool_specs_tokens once when Core is built. Use a separate json_chars_per_token constant (2.6) or, when /tokenize is available, tokenize the serialized tools array once at startup and store the exact count. Add the fixed term to the assembled estimate instead of recomputing it. Keep prose calibration separate so it cannot move the JSON estimate.
Acceptance criteria
- On the full profile, first-call
|estimated - usage.prompt_tokens| / prompt_tokens < 0.08. - No
serde_json::to_stringof tool schemas remains insiderun_loop. -
/tokenize-capable engines use the measured count; others use the JSON constant. - A unit test pins the JSON density constant and the fixed-term behavior.
References
- Lingua principale
- Rust
- Stelle
- 0
- Fork
- 0
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di GotinhaAzul/LocalHarness
-
area: ux bug priority: P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
GotinhaAzul/LocalHarness#198 ·
-
area: tools area: ux enhancement priority: P2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 56/100
GotinhaAzul/LocalHarness#201 ·
-
area: ux bug priority: P2
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
GotinhaAzul/LocalHarness#200 ·
-
area: ux bug priority: P2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
GotinhaAzul/LocalHarness#199 ·
-
area: ux enhancement priority: P2
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
GotinhaAzul/LocalHarness#197 ·
Tutte le issue di GotinhaAzul/LocalHarness
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
state:needs triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
zed-industries/zed#67561 ·
I maintainer di solito rispondono entro 1 giorno
-
bug has: workaround PR welcome! T: CI/CD
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
chore priority:low ready
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
jdrouet/catapulte#882 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100