agents icon indicating copy to clipboard operation
agents copied to clipboard

Support for function calls that does not wait for the response

Open msaelices opened this issue 8 months ago • 2 comments

The proposal is to be able to define a function like this one:

import time
class TestFunctionContext(llm.FunctionContext):
    @llm.ai_callable(wait_for_response=False)
    def long_function(self):
        # simulate a long running task
        time.sleep(10)

msaelices avatar Mar 25 '25 13:03 msaelices

⚠️ No Changeset found

Latest commit: 9769a54ac944bc3bce027fa7e8ce2b4d1318b812

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Mar 25 '25 13:03 changeset-bot[bot]

It seems like you could achieve this by tracking the task yourself; e.g.

    def __init__(self):
      self._tasks = set()
    @llm.ai_callable(wait_for_response=False)
    def long_function(self):
        # simulate a long running task
        task = asyncio.create_task(time.sleep(10))  #wrap your long function in a task.
        self._tasks.add(task)
        task.add_done_callback(self._tasks.discard)

martin-purplefish avatar Mar 27 '25 18:03 martin-purplefish

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 22 '25 12:07 CLAassistant