rohitg00/ai-engineering-from-scratch · error · ProtocolViolation

task result requires ttlMs

Error message

task result requires ttlMs

What it means

Error "task result requires ttlMs" thrown in rohitg00/ai-engineering-from-scratch.

Source

Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:313

            isinstance(total, bool) or not isinstance(total, int) or total < len(values)
        ):
            raise ProtocolViolation("completion.total must be an integer at least values length")
        has_more = completion.get("hasMore")
        if has_more is not None and not isinstance(has_more, bool):
            raise ProtocolViolation("completion.hasMore must be a boolean")

    if result_type != "task":
        return
    if method != "tools/call":
        raise ProtocolViolation("task result is valid only for tools/call")
    required_strings = ("taskId", "status", "createdAt", "lastUpdatedAt")
    for field in required_strings:
        if not isinstance(result.get(field), str) or not result[field]:
            raise ProtocolViolation(f"task result requires non-empty {field}")
    if result["status"] not in {"working", "input_required", "completed", "cancelled", "failed"}:
        raise ProtocolViolation("task result has an unknown status")
    if "ttlMs" not in result:
        raise ProtocolViolation("task result requires ttlMs")
    ttl_ms = result["ttlMs"]
    if ttl_ms is not None and (
        isinstance(ttl_ms, bool) or not isinstance(ttl_ms, int) or ttl_ms < 0
    ):
        raise ProtocolViolation("task result ttlMs must be null or a non-negative integer")
    poll_interval = result.get("pollIntervalMs")
    if poll_interval is not None and (
        isinstance(poll_interval, bool) or not isinstance(poll_interval, int) or poll_interval < 0
    ):
        raise ProtocolViolation("task result pollIntervalMs must be a non-negative integer")


def select_era(
    observation: dict[str, Any],
    policy: str,
    legacy_allowed: bool = False,
    legacy_evidence: dict[str, Any] | None = None,
) -> str:

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:313 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26). Data as JSON: /api/errors/6c995e76c778617f. Report an issue: GitHub.