Docker Compose Generator¶
The Docker Compose generator converts a UML Deployment model into Docker Compose output ready
for docker compose up. The generator writes docker-compose.yml; the web
editor returns it in a ZIP, which for a full project also holds the baked agent
build contexts. It is the
runtime handoff for the multi-agent system deployment path: the instance count authored on a
BPMN agentic lane flows through the Deployment model and becomes a real
deploy.replicas: N in the generated Compose file.
Mapping — UML Deployment → docker-compose.yml¶
UML Deployment element |
docker-compose.yml |
|---|---|
|
Top-level document ( |
|
Service entry with |
|
Service entry with |
|
Service entry with |
|
|
|
Project-level agent resolver key used to bake BAF build contexts |
|
Not a service (the Component an Artifact manifests, shown on the diagram); dependencies on it are dropped |
|
Named network under |
|
Service joins the node’s network; |
|
Shared bridging network |
|
|
|
|
|
|
|
Not mapped (design-level concept; no Compose equivalent) |
Basic Usage¶
from besser.BUML.metamodel.uml_deployment import (
Artifact, DeploymentModel, DeploymentRelation, Locality, Node, NodeKind,
)
from besser.BUML.metamodel.structural import Multiplicity
from besser.generators.docker_compose import DockerComposeGenerator
# Build a minimal deployment model
node = Node("AgentRuntime", kind=NodeKind.EXECUTION_ENVIRONMENT)
advisor = Artifact("advisor", locality=Locality.LOCAL)
gateway = Artifact("llm_gateway", locality=Locality.EXTERNAL)
dr = DeploymentRelation(advisor, node, multiplicity=Multiplicity(1, 3))
dr2 = DeploymentRelation(gateway, node)
model = DeploymentModel(
"agentic_swarm",
nodes={node},
artifacts={advisor, gateway},
relationships={dr, dr2},
)
gen = DockerComposeGenerator(model, output_dir="generated/")
gen.generate()
This produces generated/docker-compose.yml:
# Generated by BESSER DockerComposeGenerator from a UML Deployment model.
services:
advisor:
build: ./advisor
networks: [agent_runtime]
deploy:
replicas: 3
llm_gateway:
image: llm_gateway:latest
networks: [agent_runtime]
networks:
agent_runtime: {} # kind: executionEnvironment
Service names are derived from the artifact names ("Code Tester" and
"CodeTester" both become code_tester). Two artifacts that map to the same
service name make generate() raise ValueError; rename one of them.
WME Generator Key¶
When using the online editor, select docker_compose as the generator type
for a DeploymentDiagram. The response is a ZIP (docker_compose.zip)
holding docker-compose.yml, the baked agent build contexts (project
generation only) and the BESSER_GENERATION.md provenance file.
Multi-Agent System Baking¶
When the generator is invoked through the /generate-output-from-project
endpoint (i.e. as part of a full project that includes one or more
AgentDiagram entries), each LOCAL Artifact whose agentModelRef field
resolves to an AgentDiagram in the project receives a fully baked build
context: <svc>/<AgentName>.py + <svc>/config.yaml (via the BAF generator) and
a <svc>/Dockerfile that installs the selected BAF dependency groups and runs
the agent script. The service name and the build-context directory are both
derived from _safe_service_name(artifact.name), so build: ./<svc> in
the compose file points at the correct directory automatically. The
deploy.replicas: N value (from the BPMN lane multiplicity) scales each
agent to N instances, so docker compose up --build launches a swarm of
exactly the size authored on the BPMN lane. LOCAL artifacts with no
agentModelRef (hand-drawn or unlinked) keep build: ./<svc> with no
Dockerfile baked — the user supplies their own build context.
Agent image dependencies¶
Generated Dockerfiles install besser-agentic-framework[extras,llms]==4.5.1
by default (the release the BAF generator’s templates target). These groups retain API LLM providers, RAG and the framework’s optional
speech, visualization and database functionality without installing every local
machine-learning backend. The same selection applies to ordinary and A2A agents.
The generator inspects the rendered agent’s constructor calls before writing its Dockerfile, so it follows configuration overrides, state-specific classifiers and personalized graphs emitted by the BAF template:
A local
LLMHuggingFaceaddstorch.LLMHuggingFaceAPIandLLMOllamause remote inference and do not add a local backend.SimpleIntentClassifierConfigurationaddstorchfor the default or explicitpytorchframework, ortensorflowfor that explicit framework. Multiple emitted configurations retain the union of their dependency groups.A dynamic classifier framework or unpacked constructor arguments conservatively include both backends. Provider imports, comments and strings alone do not cause local backends to be installed.
Thus extras,llms covers API-based agents, including A2A/governance and
LLM-based intent classification, but it is not sufficient for all local-model
or classical-classifier configurations. Local PyTorch installations can still
be large, including GPU libraries selected by pip. Arbitrary third-party
libraries used in authored tools/custom code must be added to the Dockerfile by
the user. GUI packaging requirements and external model/database services remain
separate deployment concerns.
Agent databases¶
A Deployment model describes where agents run, not an application with its own
data: the generator bakes no web app, no class diagram and no database, and
mounts no volume into the agents. A DBReply action with the default
database (db_selection_type='default') queries db1 under db.sql in the
agent’s config.yaml, which therefore keeps the YOUR-DB-* placeholders of a
standalone agent (BESSER Agentic Framework (BAF) Generator); a configYaml saved in the editor is used as
written. A db-stereotyped artifact (a Database capability) is an externally
hosted service without connection details, so it is neither a service in the
Compose file nor wired into db1. Fill in db1 (or the db.sql entry a
custom selection names) in each agent’s config.yaml before
docker compose up. This differs from the Full Web App Generator, whose agents
query the generated backend’s SQLite database.
Tag-driven A2A wiring¶
When the Web Modeling Editor annotates the Agent diagram with explicit
agent-to-agent (A2A) tags, the bake uses those tags as the primary wiring
contract. a2a:out lines on an AgentState description identify ordered
outbound sends, and a2a:in on a when_intent_matched transition name
identifies inbound handlers. Each out-edge can carry a kind
(delegates, supervises, revises, collaborates) that shapes how
the requester frames the task for that peer and how the reply is folded back;
order sequences multi-peer sends. A peer with no kind is a plain
channel. The transport is unchanged in all cases (the BAF POST /a2a
JSON-RPC platform); kind and order affect only the generated message
wording and call sequence. Multi-round review loops are expressed as additional
modeled edges (one a2a:out/a2a:in pair per round), so the generated code
stays one request/response per edge. For older diagrams with no a2a: tags,
the bake can still fall back to the previous to_<peer> / from_<peer>
state-name convention.
Each build context is rendered once by the BAF generator. A2A transport and governance extend the authored agent rather than overwriting its script, so states, transitions, GUI assets, and personalization remain available. Pure entries retain their human platform, workers run the A2A server, and hybrid agents run both. Peers without an A2A server are removed before generation.
Governed merge runtime¶
When the project also contains Agentic BPMN, the deployment path attaches
governanceDsl from each governed merging gateway to the Agent diagram linked
from the owning lane. A2A flow tags bind producer messages to the gateway
that receives them, so a merge owner can dispatch each incoming candidate to the
correct governed merge state. Voting policies bake BESSER’s deterministic tally
engine into the owner agent once and reuse it for each governed merge; non-voting
policies use the generated governance instruction directly. If the policy
requires human input, the generated runtime pauses the merge and surfaces the
candidate slate for the human-facing entry agent to complete.
Ports, bind addresses and security¶
Bind addresses. Inside a baked container the websocket and Streamlit servers listen on
0.0.0.0, because a server bound tolocalhostthere cannot be reached through published ports. (A standalone BAF agent keepslocalhost; see thebind_hostparameter of the BAF generator.) SavedconfigYamlsettings are kept, except that both hosts are forced to0.0.0.0and the ports are validated.Published ports. Only human-facing (entry) agents publish ports: the Streamlit UI (container
5000, host5001) and the websocket server (8765), or only the websocket for a websocket-platform agent. When two entry agents would claim the same host port, the next free one is used.A2A server. Workers and hybrid agents run BAF’s A2A server (container port
8000unless the saved config sets another) and peers call it by service name on the Compose networks. It is not published to the host, and itsPOST /a2aendpoint is unauthenticated: keep the Compose networks private and do not publish or expose port8000.LLM fallback. An A2A agent answers a request whose target state produces no result with its LLM, prompted with the first
LLMReplyprompt of the agent (or a role-based default). An agent without an authored LLM falls back toLLMOpenAI(gpt-4o-mini), so set the OpenAI API key in itsconfig.yaml. A voting merge whose producers resolve to no running service also falls back to a single LLM merge instead of a vote.