LLMCallContext (llm/call_context.py)

software-agent-sdk · openhands-sdk/openhands/sdk/llm/call_context.py · python · MIT
ai, AI / Agents

Provides immutable LLM call context and utilities to apply context to provider options.

# Source: https://github.com/OpenHands/software-agent-sdk | License: MIT | Copyright 2026 OpenHands contributors
# Provided via justclaw.it.com; keep this notice with the code.
"""Conversation-owned context applied to LLM calls at execution time."""

from __future__ import annotations

from collections.abc import Iterator, MutableMapping
from contextlib import contextmanager
from contextvars import ContextVar
from dataclasses import dataclass, replace
from typing import Any


@dataclass(frozen=True)
class LLMCallContext:
    """Immutable runtime values that follow LLM calls for one conversation.

    The context belongs to the conversation, not to an :class:`LLM`. Explicitly
    passing it to an LLM call remains the preferred path. A scoped current value
    covers internal components whos

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key