Skip to content

hud-evals/trampolines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trampolines

Async trampolines for composing agent loops via mutual recursion.

pip install trampolines
from trampolines import trampoline

async def coder(task):
    code = await call_llm(f"Write: {task}")
    return tester(code)

async def tester(code):
    result = await call_llm(f"Test: {code}")
    if result.passed:
        return code
    return coder(result.failures)

final = await trampoline(coder("implement quicksort"))

Run as a workflow

python -m trampolines run examples/adversarial_code_review.py

Examples

  • adversarial_code_review.py -- Two agents in the same HUD environment. One writes code, the other tries to break it. They bounce infinitely until the reviewer says LGTM.

How it works

The async analog of the trampoline pattern. Since async generators can't return values (PEP 525), we use plain async def coroutines instead. The return value's type is the signal:

  • Coroutine returned -- bounce (the trampoline awaits it)
  • Non-coroutine returned -- done (the trampoline returns it)

Runs indefinitely by default. Use timeout (seconds) or max_bounces as safety valves.

About

Async trampolines for composing agent loops via mutual recursion.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages