openai / swarm

Educational framework exploring ergonomic, lightweight multi-agent orchestration. Managed by OpenAI Solution team.
MIT License
14.93k stars 1.38k forks source link

Add post_execute call #22

Closed eburke-openai closed 2 weeks ago

eburke-openai commented 4 months ago
Why/Context/Summary

NOTE: This is not fully fleshed out yet but the concept is shown.

What this PR does is allows us to think of an Assistant as "someone who does work" but how the work gets done is not important -- all assistants can hand off control and participate in the message stream.

Refer to this PR for usage.

1) Added the ability to run a post_execute method on any assistant. Changed the loop to have the concept of next_assistant. The chat completions and tools run as usual, but if the Assistant has a post_execute method, it will always be called and has the ability to create a different handoff.

2) Added ToolAssistant which only runs tools. This can be optimized but is not yet.

Test plan