Run the standard SDK-CLI lifecycle. Loads ``.env``, parses args with the caller's parser factory, configures stderr logging, initialises OTEL tracing under *service_name*, auto-fills ``args.run_id`` with a UUID4 when the user omitted ``--run-id``, seeds the ambient run context so th
(
service_name: str,
build_parser: Callable[[], argparse.ArgumentParser],
run_coro: Callable[[argparse.Namespace], Awaitable[None]],
)
| 128 | |
| 129 | |
| 130 | def run_sdk_cli( |
| 131 | service_name: str, |
| 132 | build_parser: Callable[[], argparse.ArgumentParser], |
| 133 | run_coro: Callable[[argparse.Namespace], Awaitable[None]], |
| 134 | ) -> None: |
| 135 | """Run the standard SDK-CLI lifecycle. |
| 136 | |
| 137 | Loads ``.env``, parses args with the caller's parser factory, configures |
| 138 | stderr logging, initialises OTEL tracing under *service_name*, auto-fills |
| 139 | ``args.run_id`` with a UUID4 when the user omitted ``--run-id``, seeds |
| 140 | the ambient run context so the root span gets |
| 141 | ``agent.run_id`` / ``agent.scenario_id`` attributes, and runs *run_coro* |
| 142 | to completion via :func:`asyncio.run`. |
| 143 | """ |
| 144 | from dotenv import load_dotenv |
| 145 | |
| 146 | from observability import init_tracing, set_run_context |
| 147 | |
| 148 | load_dotenv() |
| 149 | args = build_parser().parse_args() |
| 150 | setup_logging(args.verbose) |
| 151 | init_tracing(service_name) |
| 152 | if getattr(args, "run_id", None) is None: |
| 153 | args.run_id = str(uuid.uuid4()) |
| 154 | set_run_context(run_id=args.run_id, scenario_id=getattr(args, "scenario_id", None)) |
| 155 | asyncio.run(run_coro(args)) |
no test coverage detected