microsoft / microsoft/agent-framework
Python: [Feature]: Support Agent factories in Foundry Hosting Responses API
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 2.3k
- Avg merge
- 2d 45m
- Merged PRs (30d)
- 358
Description
### Description
`ResponsesHostServer` from `agent_framework_foundry_hosting` accepts a single agent instance, which is then shared across all requests. This raises a number of issues, particularly when using a `WorkflowAgent`:
* The server can only handle one request at a time, as the same workflow cannot run concurrently.
* If the workflow ends up in a failed state, the server must be restarted.
* If the workflow is waiting for input, it cannot accept any other requests.
* Any state in the executors is shared between requests. This is particularly problematic when a new conversation is started, as there is no checkpoint state and `on_checkpoint_restore` is not called.
Request to make `ResponsesHostServer` also accept a callable that produces a `SupportsAgentRun` instance, so a fresh agent/workflow can be produced on each request, without state being shared.
### Code Sample
```py
def create_workflow() -> WorkflowAgent:
return (
WorkflowBuilder(name="Workflow", start_executor=StartExecutor())
...
.build()
.as_agent()
)
def main():
server = ResponsesHostServer(create_workflow)
server.run()
```
### Language/SDK
Python
Contributor guide
Assessment
This issue has not been assessed yet.