fix: bound autonomous loop token usage - #1987
Open
fablgen-agent wants to merge 1 commit into
Open
Conversation
|
Hello there, thank you for opening an PR ! 🙏🏻 The team was notified and they will get back to you asap. |
fablgen-agent
force-pushed
the
agent/autonomous-run-budget
branch
from
August 23, 2026 07:10
c2cbd12 to
16084d9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
max_run_tokensguard formax_loops="auto"max_subtask_iterationsandmax_subtask_loopsas validatedAgentconstructor parametersThe remaining estimated allowance is passed as the request
max_tokenscap. Provider-reported usage and billing remain authoritative: the local estimate deliberately excludes image, audio, cache, and hidden reasoning tokens.Fixes #1976
Rebase note
This branch is rebuilt on current
masterafter #1990. It preserves that PR's structured transcript, mutable-plan, and correctness changes; the budget now measures the structuredmessagespayload passed by the current implementation.Validation
pytest tests/agents/test_autonomous_loop.py tests/structs/test_agent.py::TestAutonomousAgentLoop -q -p no:randomly— 46 passedpytest tests/agents/ -q -p no:randomly— 300 passed, 5 failedupstream/master(four missing legacy error re-exports and one pre-existingimgs=Nonemock expectation), so the branch adds no failures to that suiteblack . --check --diff— 980 files unchangedruff check .— passedpython -m py_compile swarms/agents/autonomous_loop.py swarms/structs/agent.py tests/agents/test_autonomous_loop.py— passedgit diff --check— passedDisclosure
Prepared with AI coding assistance by the Fablgen Agent account. I reviewed the implementation and test results before updating the PR.