Skip to content

symfonic.diagnostics.checks.check_chat_model_resolution

check_chat_model_resolution

agent.get_chat_model('action') audit (v7.16, item 5).

Closes the silent-fail trap where role_models['action'] is misconfigured (e.g. set to None programmatically) and background workers calling agent.get_chat_model('action') receive None instead of a bound chat model -- a TypeError minutes later when the worker tries to invoke the LLM.

We exercise the resolver the same way an adopter background worker would: call agent.get_chat_model('action') and verify the return value is non-None. If the call itself raises, that's an ERROR as well because the worker would crash on the same call path.

check_chat_model_resolution async

check_chat_model_resolution(
    agent: SymfonicAgent,
) -> list[CheckResult]

Verify agent.get_chat_model('action') resolves to a bound model.

Source code in src/symfonic/diagnostics/checks/check_chat_model_resolution.py
async def check_chat_model_resolution(
    agent: SymfonicAgent,
) -> list[CheckResult]:
    """Verify ``agent.get_chat_model('action')`` resolves to a bound model."""
    try:
        model = agent.get_chat_model("action")
    except Exception as exc:  # noqa: BLE001 -- audit must not crash
        return [
            CheckResult(
                name="chat_model_resolution.raised",
                severity=Severity.ERROR,
                message=(
                    "agent.get_chat_model('action') raised "
                    f"{type(exc).__name__}: {exc}"
                ),
                fix_hint=(
                    "Inspect FrameworkConfig.role_models['action'] and the "
                    "ModelProvider binding.  Background workers calling "
                    "agent.get_chat_model('action') will crash on the same "
                    "path."
                ),
            ),
        ]

    if model is None:
        return [
            CheckResult(
                name="chat_model_resolution.none",
                severity=Severity.ERROR,
                message=(
                    "agent.get_chat_model('action') returned None -- "
                    "background workers using this path will crash with "
                    "AttributeError on the next invoke()."
                ),
                fix_hint=(
                    "Verify FrameworkConfig.role_models['action'] (if set) "
                    "and FrameworkConfig.agent.model resolve to a valid "
                    "ModelConfig.  See ``resolve_model_config`` for the "
                    "fallback chain."
                ),
            ),
        ]

    return []