{"record":{"id":"57265cfdc7461c4b","repo":"rohitg00/ai-engineering-from-scratch","slug":"managed-requirements-need-explicit-acceptance-of-t","errorCode":null,"errorMessage":"managed requirements need explicit acceptance of the current beta boundary","messagePattern":"managed requirements need explicit acceptance of the current beta boundary","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"certifications/claude/lessons/10-tool-use-and-agentic-loops/code/main.py","lineNumber":37,"sourceCode":"@dataclass(frozen=True)\nclass RuntimeNeeds:\n    \"\"\"Facts that decide how much agent-loop infrastructure to adopt.\"\"\"\n\n    open_ended: bool\n    supported_sdk: bool = True\n    needs_custom_wire_control: bool = False\n    needs_managed_sandbox: bool = False\n    needs_remote_durable_session: bool = False\n    accepts_managed_beta: bool = False\n\n\ndef choose_runtime(needs: RuntimeNeeds) -> str:\n    \"\"\"Choose a workflow, hand-written loop, Tool Runner, or managed agent.\"\"\"\n    if not needs.open_ended:\n        return \"deterministic-workflow\"\n    if needs.needs_managed_sandbox or needs.needs_remote_durable_session:\n        if not needs.accepts_managed_beta:\n            raise ValueError(\"managed requirements need explicit acceptance of the current beta boundary\")\n        return \"managed-agents\"\n    if needs.needs_custom_wire_control or not needs.supported_sdk:\n        return \"hand-written-loop\"\n    return \"sdk-tool-runner\"\n\n\n@dataclass(frozen=True)\nclass CapabilityNeeds:\n    \"\"\"Separate executable capability from optional reusable procedure.\"\"\"\n\n    reusable_procedure: bool = False\n    shared_standard_service: bool = False\n    provider_executed_builtin: bool = False\n    anthropic_schema_client_tool: bool = False\n\n\ndef choose_capability_surface(needs: CapabilityNeeds) -> dict[str, str]:\n    execution_flags = sum(","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/10-tool-use-and-agentic-loops/code/main.py#L19-L55","documentation":"choose_runtime raises ValueError('managed requirements need explicit acceptance of the current beta boundary') when RuntimeNeeds requests a managed sandbox or remote durable session but accepts_managed_beta is False. The function refuses to silently route workloads onto a beta-stage managed-agents runtime; the caller must opt in knowingly.","triggerScenarios":"choose_runtime(RuntimeNeeds(open_ended=True, needs_managed_sandbox=True, accepts_managed_beta=False)), or needs_remote_durable_session=True with accepts_managed_beta unset/False. Reached via decision_lab and tests test_managed_runtime_requires_explicit_beta_acceptance and test_runtime_choice_preserves_workflow_gate.","commonSituations":"Default-constructing RuntimeNeeds (accepts_managed_beta defaults False) while flipping sandbox/session flags; a decision-checklist tool where the user never ticked the beta-consent box; copying example needs objects from docs that predate the flag.","solutions":["Set accepts_managed_beta=True when the product decision to ride the beta managed-agents runtime has actually been made.","If beta risk is unacceptable, clear needs_managed_sandbox / needs_remote_durable_session so choose_runtime returns hand-written-loop or sdk-tool-runner instead.","Gate the managed-runtime option in UIs behind an explicit consent control that writes accepts_managed_beta.","Catch the ValueError in decision-lab callers and surface it as a decision-required prompt rather than a crash."],"exampleFix":"# before\nruntime = choose_runtime(RuntimeNeeds(open_ended=True, needs_managed_sandbox=True, accepts_managed_beta=False))\n# ValueError: managed requirements need explicit acceptance...\n\n# after\nruntime = choose_runtime(RuntimeNeeds(open_ended=True, needs_managed_sandbox=True, accepts_managed_beta=True))  # -> \"managed-agents\"","handlingStrategy":"type-guard","validationCode":"def ready_for_managed(needs: RuntimeNeeds) -> bool:\n    managed = needs.needs_managed_sandbox or needs.needs_remote_durable_session\n    return not managed or needs.accepts_managed_beta","typeGuard":"def is_runtime_choice_safe(needs: RuntimeNeeds) -> bool:\n    \"\"\"True when choose_runtime(needs) will not raise.\"\"\"\n    if not needs.open_ended:\n        return True\n    if needs.needs_managed_sandbox or needs.needs_remote_durable_session:\n        return needs.accepts_managed_beta\n    return True","tryCatchPattern":"try:\n    runtime = choose_runtime(needs)\nexcept ValueError:\n    # beta consent missing: prompt instead of crashing\n    if not ask_consent(\"managed runtime is in beta, proceed?\"):\n        needs.needs_managed_sandbox = needs.needs_remote_durable_session = False\n    needs.accepts_managed_beta = True\n    runtime = choose_runtime(needs)","preventionTips":["Make the beta-consent field required in any UI that exposes managed flags.","Document that accepts_managed_beta must be an explicit product decision.","Unit-test the decision table so flag combinations are intentional."],"tags":["python","runtime-selection","decision-gate","beta-opt-in"],"backgroundTag":"feature-flag-not-enabled","analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}