https://www.boundaryml.com logo
Orchestration and state management with BAML
# help
l
Hi team, I am currently assessing BAML's role in the bigger picture of end-to-end agent management and evaluating how to integrate it with an orchestration manager, a state manager and so on. I don't want to be re-inventing the wheel while other partially-overlapping frameworks have solved this problem. Right now, I'm thinking about state management, which is a feature BAML offers no support for AFAIK. Therefore, I'm considering using Google's Agent Development Kit to leverage its catalogue of implementation for any sort of persistency and combine that with BAML. Something like this
Copy code
import asyncio
from datetime import datetime
from google.adk.sessions import DatabaseSessionService, Session
from server.agents.baml_client.async_client import b


async def main():
    # 1. Initialize ADK Session Service
    session_service = DatabaseSessionService(
        database_url="..."
    )

    # 2. Create or get a session for a user
    session = await session_service.get_or_create_session(...)

    # 3. Call BAML function with Guardrails
    result = await b.Guardrails(
        previous_messages=conversation_history,
        new_message=user_message
    )

    # 4. Process the result
    is_safe = result.is_safe
    response = result.response

    # 5. Update session state with the result
    session.state["message_count"] = session.state.get("message_count", 0) + 1
    session.state["last_message_time"] = datetime.utcnow().isoformat()
    session.state["last_message_safe"] = is_safe

    if not is_safe:
        session.state["guardrail_violations"] = (
            session.state.get("guardrail_violations", 0) + 1
        )

    # 6. Persist the updated session
    await session_service.update_session(session)
Have you given this any thought? What is your posture concerning this use case and, more broadly, BAML integration with other frameworks?
a
sorry we couldnt answer this earlier. That totally looks fine to me. We have had users combine baml with ADK before.
c
Similar to your example, I'm personally using LangGraph for workflow definition and durable execution (with a DB-based checkpointer), and BAML functions inside the LangGraph nodes for actual LLM calls @Luisda