STATEK
API Reference
Context

Context

Context helpers expose the currently executing job or agent to tools and advanced helper code. Prefer explicit arguments in business logic when possible.

SymbolImport pathPurposeStability
get_current_jobstatek.utils or statekCurrent job lookupCore helper
get_current_agentstatek.utils or statekCurrent agent lookupAdvanced
get_current_agent_namestatek.utils or statekCurrent agent role lookupAdvanced
statek_printstatek.utils or statekContext-aware printCore helper
format_default_llm_reprstatek.utils or statekDefault LLM representationAdvanced
init_shared_contextstatek.shared_context or statekBind shared context to a jobProvisional
shared_context_set_varstatek.shared_context or statekStore a shared context variableProvisional
print_localsstatek.shared_context or statekPrint context valuesProvisional

Current execution helpers

def get_current_job() -> Job | None
def get_current_agent()
def get_current_agent_name() -> str | None

These functions read STATEK execution context set by job-step execution. They return None when called outside a STATEK job context.

from statek import get_current_job, tool
 
@tool
def current_console_size(**kwargs) -> int:
    job = get_current_job()
    return 0 if job is None else len(job.py_env.console or [])

Printing and formatting

FunctionSignatureReturnsDescription
statek_printstatek_print(*objects, sep=" ", end="\n", file=None, flush=False)NonePrints with STATEK-aware object formatting.
format_default_llm_reprformat_default_llm_repr(obj)strFormats objects for LLM-facing display.

Shared context

def init_shared_context(*args, read_only=False, **kwargs)
def shared_context_set_var(category, key, value, description, **kwargs)
def print_locals(category, *args, **kwargs)

Shared context supports provisional advanced patterns where selected values are available across jobs that initialize matching context bindings. Exact bindings are writable, broader subset bindings are merged for reads, and read_only=True exposes context while rejecting writes. It is easier to reason about explicit job locals, agent context, or tool parameters for ordinary application state.

from statek import ContextCategoryDict, init_shared_context, shared_context_set_var
 
init_shared_context("user")
 
preference = ContextCategoryDict().get("PREFERENCE")
shared_context_set_var(
    preference,
    "locale",
    "en-US",
    "User-approved locale preference.",
)

See Long-Term Memory for practical guidance and limitations.

Related APIs: Tools, Jobs, Security.