agentleFS
salmandevsalmandev/everything-gemini/skills/dynamic-thinking-allocation/SKILL.md

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.

The file

Files
SKILL.md

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 TierTarget ComplexityThinking Token BudgetModel TargetPrimary Use Cases
Flash / NoneAST depth $\le 2$, single file edit0 (Off)Gemini 2.0 FlashMechanical formatting, directory listing, shell command dispatch, docstring typo fixes.
BalancedModerate AST refactor, multi-file unit tests2,048 - 4,096Gemini 2.5 Pro / FlashFunction signature refactor, API endpoint mocking, data model migration, SQL query optimization.
Deep ReasoningDistributed race conditions, consensus protocols8,192 - 16,384Gemini 3.8 ThinkingConcurrency bug root-cause analysis, consensus algorithms, eBPF filter generation, memory leak tracing.
Exhaustive FrontierNovel cryptographic implementations, OS kernels24,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 --json

Download now (ZIP)

Does 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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.