Skip to content

briefcase.correlation

Terminal window
pip install briefcase-ai[correlation]

Correlates multiple agents executed within one workflow context.

briefcase_workflow, get_current_workflow

from unittest.mock import Mock
from briefcase.correlation import briefcase_workflow, get_current_workflow
client = Mock()
with briefcase_workflow("ticket-triage", client) as workflow:
print(workflow.workflow_id)
workflow.register_agent("agent-1", "classifier")
workflow.register_agent("agent-2", "responder")
print(get_current_workflow() is workflow)
.workflow_id
briefcase_workflow(workflow_name, briefcase_client, workflow_id=None)
# yields BriefcaseWorkflowContext
# .register_agent(agent_id, agent_type)
get_current_workflow() -> Optional[BriefcaseWorkflowContext]

Trace propagation

from briefcase.correlation import (
TraceContextCarrier,
inject_trace_context,
extract_trace_context,
)
headers = inject_trace_context({})
extract_trace_context(headers)