Skip to main content

Top-level await Feature Breaking change

Agents and magic functions can now use top-level await in REPL environments without wrapping in asyncio.run(). This avoids event loop conflicts and results in cleaner, more intuitive async code. Prompting for magic functions and agents explicitly mention this capability. Please update any use of system, premise or task prompting the use of asyncio.run() to top-level await.

Top level return Feature Breaking change

Agents and magic functions can now use top-level return in REPL environments. Previously magic function invocations and calls to agents finished on assigning to the variable result in the REPL (or responding with only text if the return type is str or string in Python or TypeScript respectively). To avoid conflicts with agents naturally assigning intermediate values to the variable name result, top-level return is now the natural way for agents to complete a call. Please update any use of system, premise or task prompting the agent to assign to result to return to the user to top-level return.

JSON mode no longer supported Breaking change

The mode parameter is deprecated from both magic functions and agents for Python and TypeScript. All magic functions and agents now operate in "code" mode by default. Any use of mode="json" will raise a ComingSoon error.
  • Python
  • TypeScript
result = await agent.call("Do something", **scope, mode="json") # or mode="code"

@magic(mode="code")  # or mode="json"
def my_function(x: int) -> int:
    ...

Improvements Improvement

General

Automatic clean up agents and magic functions on program exit; graceful shutdown handling and proper SIGINT (Ctrl + C) handling.

TypeScript

The encoding of runtime objects for TypeScript has improved, specifically the handling of interfaces, classes, generics, unions, and intersections.

Python

Lambda expressions are now supported for the scope parameter for both magic functions and agents for Python.