PrefectHQ / ControlFlow

🦾 Take control of your AI agents
https://controlflow.ai
Apache License 2.0
747 stars 53 forks source link

Add new compiler backend #203

Closed jlowin closed 4 months ago

jlowin commented 4 months ago

This is a large PR that restructures the entire orchestration backend without touching the user-facing objects.

Pipeline:

The key to this backend is that all activity is recorded as a sequence of events that can optionally be persisted. These events represent everything that's happened in the workflow. When it's time to run an agent, we compile the events into LLM messages appropriate for that agent. For example, that agent's own responses are given the assistant role, and other agents' responses are given the user role with a system preamble explaining who the speaker is. Anecdotally this is far superior to the current approach in which all agents share the assistant role.

In addition, the compilation only includes events that are relevant to the agent's current objective. This means that if an agent is selected to work on task A, and in the next invocation a different agent is selected to work on task B, and A and B are completely independent, then the second agent will not be shown any of the first agent's responses, because they have no bearing on its work.

In essence, we compile a specialized view of the workflow universe for every agent invocation.