PIXELBANKv9.1.0
Menu

Should the Agent Loop Continue

Problem Statement

Decide whether a ReAct-style agent loop should take another step, given step and budget guards.

Background

The loop continues only if all hold: the goal is not yet done, the step count is below max_steps, and tokens used are below max_tokens. Any single violation stops the loop.

Your Task

def should_continue(done, steps, tokens, max_steps, max_tokens):

Return True if the loop should continue, else False.

Input Format

  • done (bool), steps (int), tokens (int), max_steps (int), max_tokens (int).

Output Format

  • A boolean.

Sample

print(should_continue(False, 3, 100, 10, 1000))

Output:

True

Example:

Input:
print(should_continue(False, 3, 100, 10, 1000))
Output:
True
Reasoning:
  • Check if the goal is complete: Since done is False, the condition not done evaluates to True, allowing the loop to potentially continue.
  • Verify the step limit: Compare the current steps against the maximum, calculating 3<103 < 10, which is True because the agent has not exhausted its step budget.
  • Verify the token limit: Compare the tokens used against the maximum, calculating 100<1000100 < 1000, which is True because the agent has not exhausted its token budget.
  • Combine the conditions: The loop continues only if all guards pass, so we evaluate True and True and True, resulting in True.
  • The final output is True

Constraints:

  • Continue only if not done and steps < max_steps and tokens < max_tokens.
  • Any failed condition returns False.
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.