Tubie - A simple, zero dependencies, 200 lines minimal agent composing library

Tubie is an agent composing library for elixir, zero dependencies, the entire thing is under 300 lines.

A recent project needs some simple agentic workflow. I know Jido is out there, but I want something small enough to fit entirely in my head and coding agent’s context :wink:. Hence this little experiment.

Core ideas (Inspired by the Python library PocketFlow):

  • Single world state
  • Agent defines as function : state → state
  • some combinators for common use cases

That’s it.

Basic agent can be defined as a simple expression:

tool calling:

weather_agent =
  call_llm
  |> Tubie.with_retry(max: 3, wait: 1_000)
  |> Tubie.with_fallback(fn state, e ->
    Tubie.State.error(state, Exception.message(e))
  end)
  |> Tubie.branch(has_tool_calls?, %{
    tools: execute_tools,
    done:  &Tubie.State.halt/1
  })
  |> Tubie.loop(max: 10)

map reduce:

summarizer =
  Tubie.fan_out(map_agents, as: :partials)
  |> Tubie.and_then(reduce)

there are more examples in examples folder

It’s still pretty rough around the edges, your feedback is welcome ~


I firmly believe BEAM ecosystem is the best platform for building agentic systems. When things getting really big, my gut feels is reaching for OTP will be the best bet instead of reinventing too many wheels. But sometimes, you may want some simple and flexible handtool to test things out :slight_smile:

6 Likes