Context
Context helpers expose the currently executing job or agent to tools and advanced helper code. Prefer explicit arguments in business logic when possible.
| Symbol | Import path | Purpose | Stability |
|---|---|---|---|
get_current_job | statek.utils or statek | Current job lookup | Core helper |
get_current_agent | statek.utils or statek | Current agent lookup | Advanced |
get_current_agent_name | statek.utils or statek | Current agent role lookup | Advanced |
statek_print | statek.utils or statek | Context-aware print | Core helper |
format_default_llm_repr | statek.utils or statek | Default LLM representation | Advanced |
init_shared_context | statek.shared_context or statek | Bind shared context to a job | Provisional |
shared_context_set_var | statek.shared_context or statek | Store a shared context variable | Provisional |
print_locals | statek.shared_context or statek | Print context values | Provisional |
Current execution helpers
def get_current_job() -> Job | None
def get_current_agent()
def get_current_agent_name() -> str | NoneThese 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
| Function | Signature | Returns | Description |
|---|---|---|---|
statek_print | statek_print(*objects, sep=" ", end="\n", file=None, flush=False) | None | Prints with STATEK-aware object formatting. |
format_default_llm_repr | format_default_llm_repr(obj) | str | Formats 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.