ToolContext (contracts/tool_runtime.py)

kongming-agent · src/core/contracts/tool_runtime.py · python · MIT
ai

Defines runtime contracts and value objects for tool execution in agent systems.

# Source: https://github.com/KtKID/kongming-agent | License: MIT | Copyright 2026 KtKID
# Provided via justclaw.it.com; keep this notice with the code.
"""Tool runtime protocols and value objects."""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import Any, Protocol, runtime_checkable

# ---------------------------------------------------------------------------
# Tool 相关支撑类型
# ---------------------------------------------------------------------------


@dataclass(frozen=True)
class ToolContext:
    """工具执行上下文。

    Attributes:
        run_id: 当前 run 的 id,便于工具在日志 / trace 里标识来源。
        session_id: 当前 session id。
        turn: 工具被调用所在的 turn,从 1 开始计数。
        call_id: 对应的 :class:`core.message.ToolCall.call_id`。
        metadata: 装配层注入的额外上下文(例如 cwd

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

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

Get a free API key