bu-agent-sdk is the Python agent framework behind BU.app from Browser Use. Its design position is that the value lies in the model, not in framework abstractions: an agent is a loop that sends messages to an LLM, executes the tool calls it returns, and repeats until an explicit exit. The library gives you that loop, a @tool decorator, and thin LLM clients, and little else.
Tools are async Python functions decorated with a description. Completion is explicit: a done tool raises TaskComplete, and requiredonetool=True prevents the agent from stopping just because a turn produced no tool calls. Each provider client is about 300 lines behind one BaseChatModel interface, so you can swap ChatAnthropic, ChatOpenAI, and ChatGoogle without touching agent code.
Context management is built in. Tools can be marked ephemeral=N so only the last N outputs (such as browser state or screenshots) stay in the conversation, and a CompactionConfig triggers automatic summarisation when the context approaches a threshold ratio of the window. An included example builds a sandboxed coding assistant with file, grep, edit, and todo tools in about 100 lines.
Features
- For-loop agent: Agent(llm=..., tools=[...]) with query() for a final result
- Tool decorator: @tool("description") on async functions, with typed parameters
- Done tool pattern: explicit completion through TaskComplete and requiredonetool
- Ephemeral messages: keep only the last N outputs of large tools
- Context compaction: auto-summarise at a configurable threshold of the context limit
- Dependency injection: FastAPI-style Depends with Annotated types for resources such as database or sandbox context
- Streaming events: query_stream() yields ToolCallEvent, ToolResultEvent, and FinalResponseEvent
- Provider clients: Anthropic, OpenAI, and Google behind one interface
- Examples: a sandboxed Claude Code-style assistant and a dependency-injection demo
