I wrote my own agent state machine in pretty much pure async Python (no libs). Running successfully in prod with very few issues.
I use the OpenAI messages spec, and have the messages be an append only list, to make it easy to reason about.
Don’t bother compacting histories imo. worse case just summarise and spin up a new agent with the context.
good luck!
Is this code open source?