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
      • Prompts, Scripts, and Agents
      • The Agent Loop Step by Step
      • Agent Components
      • Agent Loop Simulator
      • When a Script Wins
    • Tool Use and Structured Output
    • Planning, Memory 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

‹What an Agent Is
  1. Topics
  2. AI Skills for VLSI Engineers
  3. Agents and Tool Use
  4. What an Agent Is
  5. Agent Loop Simulator

Tools, Workflows and Agents · Beginner to Intermediate

Agent Loop Simulator

A fake scripted agent loop with two tools, a step budget, and a log.

On this page

    What the simulator stands in for

    The program below replaces the model with a FAKE scripted decision function. Two fake tools stand in for real ones: a sensor read and a setting write.

    Treat the plan as a stand-in, not intelligence. It replays fixed choices so the loop mechanics can be checked exactly.

    The program

    The loop runs at most 6 steps, logs each action, and checks its own end state. The listing is schematic: no real model is called.

    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
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    import sys
    
    # FAKE scripted stand-in for a model: a fixed action plan, not a real model.
    PLAN = ["sense", "sense", "act", "finish"]
    SENSE_VALUES = [20, 42]
    STEP_BUDGET = 6
    
    reads = []
    applied = None
    log = []
    steps = 0
    stopped_clean = False
    
    sense_calls = 0
    step = 0
    while step < STEP_BUDGET:
        if step < len(PLAN):
            action = PLAN[step]
        else:
            action = "finish"
        log.append("step" + str(step) + ":" + action)
        steps += 1
        if action == "sense":
            reads.append(SENSE_VALUES[sense_calls % len(SENSE_VALUES)])
            sense_calls += 1
        elif action == "act":
            applied = reads[-1]
        elif action == "finish":
            stopped_clean = True
            break
        else:
            print("FAIL: unknown action " + action)
            sys.exit(1)
        step += 1
    
    if steps != 4:
        print("FAIL: steps " + str(steps))
        sys.exit(1)
    if reads != [20, 42]:
        print("FAIL: reads " + str(reads))
        sys.exit(1)
    if applied != 42:
        print("FAIL: applied " + str(applied))
        sys.exit(1)
    if len(log) != 4:
        print("FAIL: log size " + str(len(log)))
        sys.exit(1)
    if STEP_BUDGET - steps != 2:
        print("FAIL: budget left " + str(STEP_BUDGET - steps))
        sys.exit(1)
    if not stopped_clean:
        print("FAIL: stopped flag unset")
        sys.exit(1)
    print("PASS: 4 steps 2 reads applied 42 log 4 budget left 2")

    Reading the log

    The log holds one entry per step, in order. Four entries appear: two reads, one write, and the stop.

    The budget allows 6 steps and the run uses 4, so 2 remain. Each number here follows from the plan, the two sense values, and the budget constant in the code.

    Common mistakes

    Common pitfall

    Reading the PASS line as proof about a real model. The checks prove the loop mechanics only; a real decision function can still choose badly.

    Interview

    Likely probes: what the simulator proves and what it does not.

    • It proves loop mechanics: budget, logging, and state updates.

    • The fake plan stands in for a model; nothing here tests judgment.

    • Change the plan or the budget and predict the new log first.

    Check yourself How many tool calls does the run make, and what is the final applied value?

    Three calls: two sensor reads and one write. The applied value is 42, the second sense value.

    Check yourself The budget is cut to 3 with the same plan. Which step never runs?

    The finish step. Steps 0 to 2 use the budget, so the loop ends on the budget after the write with no clean stop.

    Related topics

    • When a script wins

    • Lint-and-fix loops

    Previous

    90 / 173

    Next: When a Script Wins

    Up next

    Up nextWhen a Script Wins

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Prompts, Scripts, and Agents
    • The Agent Loop Step by Step