def test_supervisor_functional_workflow() -> None:
    """Test supervisor workflow with a functional API agent."""
    model = FakeModel(
        messages=iter([AIMessage(content="Mocked response")]),
    )

    # Create a joke agent using functional API
    @task
    def generate_joke(messages: List[BaseMessage]) -> BaseMessage:
        """Generate a joke using the model."""
        return model.invoke([SystemMessage(content="Write a short joke")] + list(messages))

    @entrypoint()
    def joke_agent(state: Dict[str, Any]) -> Dict[str, Any]:
        """Joke agent entrypoint."""
        joke = generate_joke(state["messages"]).result()
        messages = add_messages(state["messages"], joke)
        return {"messages": messages}

    # Set agent name
    joke_agent.name = "joke_agent"

    # Create supervisor workflow
    workflow = create_supervisor(
        [joke_agent], model=model, prompt="You are a supervisor managing a joke expert."
    )

    # Compile and test
    app = workflow.compile()
    assert app is not None

    result = app.invoke({"messages": [HumanMessage(content="Tell me a joke!")]})

    # Verify results
    assert "messages" in result
    assert len(result["messages"]) > 0
    assert any("joke" in msg.content.lower() for msg in result["messages"])
Test supervisor workflow with a functional API agent.
tests/test_supervisor_functional_api.py