AI-Engineer-Foundation / agent-protocol

Common interface for interacting with AI agents. The protocol is tech stack agnostic - you can use it with any framework for building agents.

Home Page:https://agentprotocol.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Step POST should immediately return

ryanpeach opened this issue · comments

Is your feature request related to a problem? Please describe.

You should not have to wait on a step to complete when you request its execution. What if the connection is broken? What if it takes a long time? Etc.

Describe the solution you'd like

Step can return a status "Running" until its done.

Looking at the code as it is at the moment, it doesn't seem like it's implemented this way.

I would use the flask after_request decorator rather than awaiting the _step_handler. Just change its state from created to running then move on. You could add an option to force wait.

This way the client is not actually locked into the processing of the step.

https://flask.palletsprojects.com/en/2.3.x/api/#flask.Flask.after_request

step = await _step_handler(step)

NVM, it seems after_request doesn't actually run "in the background". I wonder how to trigger such behavior in an API server, if its even possible.

Oh, sorry, of course. So actually what the implementor of the API would do is do this themselves. They would overload _step_handler to push the step to a queue like Celery, or a K8sJob, or SQS, or whatever kind of queue/processing system they have, and then return immediately. Then on repeated posts they would check the step id if it exists for the status.