PlatformContext

PlatformContext is the single object injected into every tool function at runtime. It provides access to knowledge retrieval, governance logging, and session state.

from proxima_sdk import PlatformContext

Signature

class PlatformContext:
    knowledge: KnowledgeClient
    governance: GovernanceClient
    session: SessionContext
    agent_id: str
    user_id: str

Usage pattern

Every tool function receives ctx as its second argument:

def my_tool(params: dict, ctx: PlatformContext) -> dict:
    # Query knowledge
    results = ctx.knowledge.query(params["question"])

    # Log for audit
    ctx.governance.log_action("my_tool_called", metadata={"query": params["question"]})

    return {"answer": results.answer}

ctx.knowledge

See KnowledgeClient for full reference.

ctx.governance

ctx.governance.log_action(action: str, metadata: dict = {}) -> None

Writes an immutable audit record. Called automatically for all tool invocations — call explicitly for business-level events.

ctx.session

ctx.session.id          # str — current session ID
ctx.session.history     # list[dict] — conversation turns
ctx.session.get(key)    # Any — retrieve session variable
ctx.session.set(key, value)  # store session variable
ℹ

PlatformContext is always injected by the platform. Never instantiate it directly in production code — use mock_context() for testing.