dynamic-thinking-allocation
Skill2 starsChanged 28 days agoApache-2.0View on GitHub
Profiles cognitive task complexity and dynamically routes between low-latency Gemini Flash and Gemini 3.8 Extended Thinking reasoning budgets.
In this repository108 other files it gives its agents.
- AGENTS.mdAGENTS.md
- everything-gemini-maintainerSkill
- adversarial-fuzz-generatorSkill
- agent-evalsSkill
- ai-first-engineeringSkill
- alloydb-omni-vectorSkill
- apache-kafka-streamsSkill
- api-craftsmanSkill
- architecture-designerSkill
- argon-3d-game-engineSkill
- argon-3d-scene-architectSkill
- argon-procedural-asset-generatorSkill
- argon-visual-critique-loopSkill
- argo-workflowsSkill
- autonomous-incident-healerSkill
- axum-web-serviceSkill
- bigquery-vector-searchSkill
- browser-qa-testerSkill
- chromadb-vector-storeSkill
- cilium-ebpf-networkingSkill
- clickhouse-analyticsSkill
- cloud-deploy-canarySkill
- cloudflare-r2-object-storageSkill
- cloudflare-workersSkill
- cloud-run-agentsSkill
- context-cachingSkill
- context-distillation-compressorSkill
- context-warmerSkill
- continuous-learningSkill
- cost-oracle-finopsSkill
- cross-repo-swarm-syncSkill
- cve-remediation-orchestratorSkill
- database-architectSkill
- dataproc-spark-analyticsSkill
- dbt-transformationSkill
- debezium-cdcSkill
- devops-pipelineSkill
- distributed-rate-limitingSkill
- docker-compose-orchestratorSkill
- duckdb-local-olapSkill
- ebpf-microvm-sandboxSkill
- ebpf-sandbox-enforcerSkill
- elephant-goldfish-modelSkill
- envoy-ai-gatewaySkill
- ephemeral-swarm-orchestratorSkill
- fastapi-productionSkill
- fullstack-nextjsSkill
- game-audio-synthesizerSkill
- game-studioSkill
- gemini-function-callingSkill
- gemini-groundingSkill
- gemini-live-audio-transcriberSkill
- gemini-live-multimodalSkill
- gemini-live-screen-visionSkill
- gemini-multimodalSkill
- genetic-prompt-cross-pollinatorSkill
- git-craftsmanSkill
- github-opsSkill
- google-axSkill
- google-flow-orchestratorSkill
- The first 60 shown.
The file
Files
Dynamic Thinking Allocation & Extended Reasoning Engine
Configures, profiles, and orchestrates dynamic "thinking token" budgets for Google Gemini 3.8 models, automatically determining the optimal cognitive depth between high-speed tool plumbing and deep architectural reasoning.
1. Architecture: Cognitive Complexity Router
┌─────────────────────────────────────────────────────────────────────────────┐
│ DYNAMIC THINKING ALLOCATION ROUTING MATRIX │
│ │
│ ┌────────────────────────┐ │
│ │ Incoming Agent Turn / │ │
│ │ Architectural Task │ │
│ └───────────┬────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ Cognitive Profiler (Entropy, Dependency Depth, AST Complexity) │ │
│ └───────────┬─────────────────────────┬───────────────────────────────┘ │
│ │ │ │
│ Score < 30 │ 30-70 │ Score > 70 │
│ ▼ ▼ ▼
│ ┌──────────────────────┐ ┌──────────────────────┐ ┌───────────────────┐ │
│ │ Level 1: FLASH │ │ Level 2: BALANCED │ │ Level 3: DEEP │ │
│ │ (Thinking: 0 tokens) │ │ (Thinking: 2k-4k) │ │ (Thinking: 8k-24k)│ │
│ │ • Tool plumbing │ │ • Bug diagnosis │ │ • Distributed ref │ │
│ │ • CLI invocations │ │ • Schema validation │ │ • Concurrency fix │ │
│ │ • Log grepping │ │ • Test authoring │ │ • Cryptography │ │
│ └──────────────────────┘ └──────────────────────┘ └───────────────────┘ │
│ │ │ │ │
│ └─────────────────────────┼─────────────────────────┘ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ Model API Execution (Google GenAI SDK / Antigravity Engine) │ │
│ │ • `config.thinking_config = {"thinking_budget": targetTokens}` │ │
│ │ • Pre-allocated spend caps monitored via `budget-guard` │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘2. Dynamic Thinking Budget Allocation Rules
| Cognitive Tier | Target Complexity | Thinking Token Budget | Model Target | Primary Use Cases |
| Flash / None | AST depth $\le 2$, single file edit | 0 (Off) | Gemini 2.0 Flash | Mechanical formatting, directory listing, shell command dispatch, docstring typo fixes. |
| Balanced | Moderate AST refactor, multi-file unit tests | 2,048 - 4,096 | Gemini 2.5 Pro / Flash | Function signature refactor, API endpoint mocking, data model migration, SQL query optimization. |
| Deep Reasoning | Distributed race conditions, consensus protocols | 8,192 - 16,384 | Gemini 3.8 Thinking | Concurrency bug root-cause analysis, consensus algorithms, eBPF filter generation, memory leak tracing. |
| Exhaustive Frontier | Novel cryptographic implementations, OS kernels | 24,576 (Max) | Gemini 3.8 Thinking (Max) | Post-quantum cryptographic migration, compiler backend optimization, distributed deadlock resolution. |
3. Implementation with Google GenAI SDK
from google import genai
from google.genai import types
def configure_thinking_session(task_complexity_score: float, client: genai.Client) -> genai.Chat:
"""Configures dynamic thinking token budget based on task entropy."""
if task_complexity_score > 0.8:
# Deep architectural reasoning
model_name = "gemini-3.8-thinking"
thinking_budget = 16384
elif task_complexity_score > 0.4:
# Balanced analytical tasks
model_name = "gemini-2.5-pro"
thinking_budget = 4096
else:
# Low-latency tool plumbing
model_name = "gemini-2.0-flash"
thinking_budget = 0
config = types.GenerateContentConfig(
temperature=0.2 if thinking_budget > 0 else 0.7,
thinking_config=types.ThinkingConfig(
thinking_budget=thinking_budget
) if thinking_budget > 0 else None,
)
return client.chats.create(model=model_name, config=config)4. CLI Inspection & Profiling
# 1. Profile a task's cognitive complexity and recommend thinking budget
everything-gemini thinking profile "Resolve distributed Spanner deadlock across 3 microservices"
# 2. Benchmark thinking token expenditure in dry-run mode
everything-gemini thinking budget --level deep --dry-run
# 3. Output structured thinking allocation matrix
everything-gemini thinking --jsonDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

