MCPcopy Index your code
hub / github.com/AI45Lab/Code / main

Function main

sdk/python/tests/test_parallel_budget.py:31–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29
30
31def main() -> None:
32 workspace = tempfile.mkdtemp(prefix="a3s-code-python-parallel-budget-")
33 agent = Agent.create(INLINE_CONFIG)
34
35 opts = SessionOptions()
36 opts.permission_policy = PermissionPolicy(default_decision="allow")
37 opts.workspace_backend = LocalWorkspaceBackend(workspace)
38
39 session = agent.session(workspace, opts)
40
41 # No budget -> the plain list of outcome dicts (unchanged behavior).
42 plain = session.parallel([])
43 assert plain == [], f"no budget -> plain list, got {plain!r}"
44
45 # With a budget -> {outcomes, budget}. Empty fan-out takes no LLM path.
46 budgeted = session.parallel([], budget_tokens=50000)
47 assert budgeted["outcomes"] == [], f"empty specs -> empty outcomes, got {budgeted!r}"
48 assert (
49 budgeted["budget"]["consumed_tokens"] == 0
50 ), f"no spend yet, got {budgeted['budget']!r}"
51 assert (
52 budgeted["budget"]["limit_tokens"] == 50000
53 ), f"limit reflected in the ledger, got {budgeted['budget']!r}"
54
55 session.close()
56 print("python sdk parallel budget overload ok")
57
58
59if __name__ == "__main__":

Callers 1

Calls 7

SessionOptionsClass · 0.50
PermissionPolicyClass · 0.50
createMethod · 0.45
sessionMethod · 0.45
parallelMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected