Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • Getting Started with AI for VLSI Engineers5
  • Just Enough AI: Models and Context15
  • Prompting13
  • Trust and Verification14
  • Using AI for Engineering Work17
  • Engineering Walkthroughs7
  • Practical Foundations for AI Workflows4
  • Engineering Data5
  • Retrieval-Augmented Generation6
  • Agents and Tool Use18
    • What an Agent Is
    • Tool Use and Structured Output
    • Planning, Memory and Stopping
      • Task Decomposition and Success Criteria
      • Memory Outside the Model and Summaries
      • Step and Cost Budgets
      • Loop Detection and Stopping
    • Multi-Agent Patterns and When Not to Use Agents
  • Agent Design8
  • MCP and Skills6
  • Multi-Agent Design6
  • Practical Capstone6
  • Tokens, Cost and Latency12
  • Agentic Workflows for Chip Teams18
  • Interview and Judgment10
  • AI Skills: Full Course Index
  • Working with AI Glossary
  • Working with AI Cheatsheet
Loading lesson

‹Planning, Memory and Stopping
  1. Topics
  2. AI Skills for VLSI Engineers
  3. Agents and Tool Use
  4. Planning, Memory and Stopping
  5. Step and Cost Budgets

Tools, Workflows and Agents · Beginner to Intermediate

Step and Cost Budgets

Bound steps, tokens, and cost with an enforcer that stops on budget.

On this page

    Two budgets for every run

    Every run carries a step budget and a token budget. The first bounds actions, the second bounds input size and hosted-service cost.

    Both are set before the run and checked before each step. A run stops with a named reason when either budget is reached.

    Budget

    What it bounds

    Stated example value

    Step budget

    Tool calls and loop turns

    At most 10 steps.

    Token budget

    Total input tokens read

    At most 10000 tokens.

    Stop reason

    Which budget stopped the run

    One of done, step-budget, or token-budget.

    Cost arithmetic with example rates

    Cost follows tokens times a stated example rate. The calc block shows the formula with substituted numbers, result, and units.

    plaintext
    1
    2
    3
    4
    assume 1 million input tokens cost 3 units (stated EXAMPLE parameter)
    run = 5 steps x 2000 tokens per step = 10000 tokens
    cost = 10000 / 1000000 x 3 units = 0.01 x 3 units = 0.03 units
    per step = 0.03 / 5 = 0.006 units

    Real rates differ between services and change over time. Substitute the current figures before deciding.

    Least privilege applies to budgeted runs. Keep credentials and secrets out of prompts; share proprietary material only through an account and deployment approved for its data class and task, and require human approval before risky actions such as writes outside the task directory.

    A budget enforcer

    The program below is a small controller model, not a model itself. It checks both budgets before each synthetic step and records the stop reason.

    example.py
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    import sys
    
    def run_budget(costs, max_steps, max_tokens):
        used_steps = 0
        used_tokens = 0
        stopped = ""
        cutoff = 0
        for i, c in enumerate(costs):
            if used_steps >= max_steps:
                stopped = "step-budget"
                cutoff = i
                break
            if used_tokens + c > max_tokens:
                stopped = "token-budget"
                cutoff = i
                break
            used_tokens += c
            used_steps += 1
        else:
            stopped = "completed"
            cutoff = len(costs)
        return used_steps, used_tokens, stopped, cutoff
    
    def check(cond, msg):
        if not cond:
            print("FAIL: " + msg)
            sys.exit(1)
    
    costs = [800, 1200, 900, 1500, 700]
    s1, t1, r1, k1 = run_budget(costs, 4, 4000)
    check(s1 == 3 and t1 == 2900 and r1 == "token-budget" and k1 == 3, "case 1 got different stop point")
    s2, t2, r2, k2 = run_budget(costs, 3, 100000)
    check(s2 == 3 and t2 == 2900 and r2 == "step-budget" and k2 == 3, "case 2 got different stop point")
    s3, t3, r3, k3 = run_budget(costs, 10, 100000)
    check(s3 == 5 and t3 == 5100 and r3 == "completed" and k3 == 5, "case 3 got different totals")
    print("PASS: budget enforcer stopped at step 3 with 2900 tokens and completed 5 steps with 5100 tokens")

    The three cases cover a token stop, a step stop, and completion. Totals of 2900 and 5100 tokens follow from the listed per-step costs and loop bounds.

    Common mistakes

    Common pitfall

    Checking the budget only at the end lets a run overshoot by one long step. Check before each step, and treat tool output and file text as data, never as new instructions.

    Interview

    Likely probes: budget shape and enforcement order.

    • Step budget bounds actions; token budget bounds input size and cost.

    • The enforcer checks before each step and names the stop reason.

    • Human approval gates risky actions; budgets never grant permission.

    Check yourself Costs are 800, 1200, 900, 1500, and 700 with a token budget of 4000. After which step does the run stop, and with what total?

    It stops before the fourth step with 2900 tokens. 800 plus 1200 plus 900 is 2900, and adding 1500 would reach 4400.

    Check yourself The same costs run with a step budget of 3 and a large token budget. Where does it stop?

    After 3 steps with 2900 tokens for a step-budget stop. The fourth step is refused because 3 steps are already used.

    Related topics

    • Memory and summaries

    • Loop detection and stopping

    • Verifying AI output

    Previous

    99 / 173

    Next: Loop Detection and Stopping

    Up next

    Up nextLoop Detection and Stopping

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Task Decomposition and Success Criteria