شعار Token Budget Gate

Token Budget Gate

المجتمع
chrono-meta
token-budget-gate

Estimates token cost before a multi-step task and outputs a 4-tier Green/Yellow/Orange/Red gate verdict. Records actual vs. estimated after completion when a mechanical usage source exists. Triggers on "token budget", "how much will this cost", "will this be expensive", "estimate tokens", before long multi-agent tasks.

نظرة عامة

الناشرchrono-meta
المستودعforge-harness
اسم المهارةtoken-budget-gate
النجوم
32
التفريعات
1
الملفات المرفقة
تعليمات فقط
الترخيصMIT
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • مكتفية بذاتها

    كل ما يحتاجه النموذج موجود في التعليمات — لا ملفات إضافية لمزامنتها.

  • مفتوحة المصدر

    نشرها chrono-meta على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي Token Budget Gate في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى «الإضافات» ثم «المهارات».
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/chrono-meta/forge-harness/tree/main/plugins/fh-commons/skills/token-budget-gate
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات ← المهارات ← إضافة مهارة ← من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/chrono-meta/forge-harness.git /tmp/forge-harness
mkdir -p .claude/skills
cp -r /tmp/forge-harness/plugins/fh-commons/skills/token-budget-gate .claude/skills/token-budget-gate
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل Token Budget Gate في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج مهارة Token Budget Gate تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط Token Budget Gate بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

    تتضمن مطالبة النظام الاسم والوصف فقط. وتُجلب التعليمات عند أول طلب ذي صلة، لذا لا تستهلك تعليمات المهارة أي توكنات ما دامت المهارة غير مستخدمة.

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.md الذي يُحمّله النموذج. اقرأه قبل التثبيت — فالمهارة عبارة عن تعليمات سيتبعها نموذجك.

token-budget-gate — Pre-Task Token Cost Gate

Multi-step and multi-agent tasks can silently consume large token budgets. This skill estimates cost before execution, outputs a gate verdict, and calibrates estimates against actual usage after completion — preventing surprise overruns without blocking legitimate work.

FH context: FH default execution tier is standard (~15K tokens). This skill gates against accidental full (~30K) or max (~60K+) consumption on tasks that could be handled lighter.


Triggers

  • /token-budget-gate
  • "token budget", "token cost", "how expensive", "will this use a lot of tokens"
  • "estimate tokens", "token estimate before we start"
  • Before invoking: agent-composer, sim-conductor, steel-quench (max-tier skills)
  • Automatically proposed when task description contains: multi-agent, parallel dispatch, full suite, all files, entire codebase

Gate Thresholds (defaults — user-configurable)

SignalVerdictAction
Estimated < 10K tokens🟢 GREENProceed without comment
10K–30K tokens🟡 YELLOWProceed with notice — suggest lighter approach if one exists
30K–60K tokens🟠 ORANGEConfirm before proceeding — present scope reduction options
> 60K tokens🔴 REDBlock + require explicit approval — present mandatory reduction

Custom threshold: user can set TOKEN_BUDGET_MAX=N in conversation or .claude/settings.json.


Execution Steps

Step 1. Parse Task Description

Extract task dimensions:

DimensionLow (×1)Medium (×2)High (×4)
File scope1–3 files4–10 files11+ files / whole codebase
Agent count0 (inline)1–2 agents3+ agents / parallel
Step depth1–3 steps4–8 steps9+ steps
IterationNone1 round2+ rounds (wave/loop)
Output sizeShort answerMedium docFull report / deck

Step 2. Estimate Token Cost

Base estimates per task type:

Task TypeBase EstimateNotes
Single file edit2KRead + edit + verify
Code review (1 PR)5KDiff + analysis + comments
Skill creation (1 SKILL.md)8KDesign + write + CATALOG update
Agent dispatch (1 agent)10KContext card + agent overhead
Parallel dispatch (3 agents)25K3× agent + orchestration
sim-conductor full run30KAll 5 simulation axes
steel-quench 4-wave50KAll waves + prescriptions
Full harvest-loop cycle40K8-step pipeline + PRs

Apply dimension multipliers from Step 1 to the base estimate.

Calibration override (read leg): if .claude/token_calibration/log.tsv exists and holds ≥1 row for this task type, derive the base as median(actual_i / mult_i) over its rows — each row's mult column records the dimension-multiplier product that was in effect, so dividing recovers a dimension-neutral base. Never use raw actual as the base: actual already contains that run's multipliers, and re-applying this run's multipliers on top double-counts scope. The table above is the uncalibrated default; measured local data outranks it. State which source the estimate used (base: table (uncalibrated) or base: calibration log, n={rows}).

Final formula:

Estimated = base × file_multiplier × agent_multiplier × iteration_multiplier

Round to nearest 1K.


Step 3. Output Gate Verdict

## Token Budget Gate

Task: {one-line task description}
Estimated cost: ~{N}K tokens
Threshold: {user max or default}

Verdict: 🟡 YELLOW — within budget but consider lighter approach

Breakdown:
  Base (skill creation): 8K
  × 2 agents: ×2 = 16K
  × 1 iteration: ×1 = 16K
  Total: ~16K

Lighter alternative:
  → Inline (no agent dispatch): ~8K (-50%)
  → Single agent, not parallel: ~12K (-25%)

Proceed? (y to continue / n to adjust scope)

For 🟢 GREEN: output one line only — "Token estimate: ~{N}K — GREEN, proceeding."


Step 4. Proceed / Adjust

  • GREEN / YELLOW + user confirms: proceed, note start marker
  • ORANGE: present scope reduction table, wait for user selection
  • RED: present mandatory reduction — do not proceed until user explicitly approves

Scope reduction options table (ORANGE/RED):

OptionReductionTrade-off
Drop parallel → sequential-30%Slower, same quality
Reduce agent count (3→1)-50%Less parallelism
Narrow file scope-40%Shallower coverage
Use lighter skill variant-60%Fewer waves/probes
Split into 2 sessions-50%/sessionNo quality loss

Step 5. Post-Task Calibration (offered, not required)

After task completion, if user says "how much did that cost" or "calibrate":

Actual must come from a mechanical source — the user pasting /cost output, or budget.spent() in a Workflow context. A model cannot read its own token consumption by introspection; a reconstructed number written into the log poisons every future estimate that reads it (the read leg in Step 2). No mechanical source available → render Actual: UNMEASURED and write no row.

## Calibration

Estimated: ~16K tokens
Actual: ~{actual}K tokens   (source: /cost paste | budget.spent() | UNMEASURED)
Error: {+/-N}%   (omit when UNMEASURED)

Write calibration data (only when Actual is mechanically sourced):

bash
mkdir -p .claude/token_calibration/
# mult = this run's dimension-multiplier product (Step 1) — stored so the read leg can divide it
# back out; a log without it makes every future estimate double-count scope.
printf '%s\t%s\t%s\t%s\t%s\n' "{task_type}" "{estimated_k}" "{actual_k}" "{mult}" "$(date +%F)" \
  >> .claude/token_calibration/log.tsv

Recorded rows feed the Step 2 calibration override for the same task type (no model training — local record only).


Done When

  • Gate verdict output (GREEN/YELLOW/ORANGE/RED) with estimated cost breakdown, naming the estimate's base source (table-uncalibrated or calibration log) — mandatory-pass
  • For ORANGE/RED: scope reduction options presented and user decision recorded — mandatory-pass
  • Any calibration row written this run carries a mechanically-sourced actual (pasted /cost or budget.spent()); no mechanical source → Actual: UNMEASURED, no row — mandatory-pass

(Post-task calibration is an offer in Step 5, not a completion condition — a completion condition marked "optional" is not a completion condition.)


Chains

Upstream (proposed before these skills):

  • → agent-composer (multi-agent orchestration)
  • → sim-conductor (5-axis simulation)
  • → steel-quench (4-wave adversarial review)
  • → harvest-loop (8-step pipeline)

Downstream:

  • No mandatory chain — gate verdict is the output; task execution follows user decision

External anchor (independent convergence)

arXiv:2606.27009 (Semantic Early-Stopping for Iterative LLM Agent Loops, 2026-06-25, verified 2026-06-27) measures −38% tokens by stopping iterative agent loops on semantic convergence instead of a fixed iteration cap — external evidence that the largest avoidable spend in loop-shaped work is over-iteration, the cost class this gate exists to flag. Caveat (provenance-honest): the same paper found judge-gated stopping counterproductive (judging cost outweighs the saving), so the saving is real only when the convergence signal is cheap. Pairs with convergence-loop (the stop-rule side of the same finding).

الأسئلة الشائعة

ماذا تفعل مهارة الذكاء الاصطناعي Token Budget Gate؟

Estimates token cost before a multi-step task and outputs a 4-tier Green/Yellow/Orange/Red gate verdict. Records actual vs. estimated after completion when a mechanical usage source exists. Triggers on "token budget", "how much will this cost", "will this be expensive", "estimate tokens", before long multi-agent tasks.

لماذا تستخدم Token Budget Gate على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة Token Budget Gate عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت Token Budget Gate في TypingMind؟

في TypingMind، افتح «الإضافات»، ثم «المهارات»، ثم اختر «التثبيت من GitHub» والصق https://github.com/chrono-meta/forge-harness/tree/main/plugins/fh-commons/skills/token-budget-gate. يقرأ TypingMind ملف SKILL.md الخاص بالمهارة ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام Token Budget Gate؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع Token Budget Gate؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام Token Budget Gate معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي Token Budget Gate مجانية؟

نعم. نشرها chrono-meta على GitHub بموجب ترخيص MIT. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا الإخبارية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇