Skip to content

Context methods reference

Templates use the Jinja object context (always available where templating is enabled).

context.local(name, …)

  • name — logical name matching context/<name>.md (nested paths use /).
  • description — optional; shown in the injected metadata block.
  • max_chars — optional; caps inlined characters. See Context for delegating vs plain agents.
  • mode — optional; auto, lazy, or full. Overrides the project default for this call. See Rendering mode.

context.confluence(name, …)

Fetches one Confluence page at compile time (a failed fetch warns in a default compile and fails under abt compile --live). Requires the optional dependency abt-core[confluence]:

uv pip install "abt-core[confluence]"

Credentials — profiles.yaml → credentials.atlassian: url (or server), username (or email), api_token. Same namespace used by the confluence exposure dispatcher, the atlassian package tools, and Jira sources/retrievers — see abt-atlassian-tools for the full example. Confluence Cloud only; self-hosted Server/Data Center is not supported.

Typical kwargs: page_id, space, plus description, max_chars.

context.github(name, …)

Fetches one file from a GitHub repository at compile time (a failed fetch warns in a default compile and fails under abt compile --live; e.g. a README or runbook). No optional dependency required (stdlib urllib/requests under the hood).

Credentials (checked in order) — inline token= kwarg on the call, then profiles.yaml → credentials.github.token, then the GITHUB_TOKEN (or GH_TOKEN) env var. A token is required; the call raises if none of the three is set. The token goes only to GitHub's API and content hosts: a download_url on another host is refused, and a redirect to another host is followed without it.

Kwargs: repo (e.g. "my-org/my-repo"), path (file path in the repo), optional ref (branch/tag/SHA, defaults to the repo's default branch), optional token, plus description, max_chars.

context.s3(name, …)

Downloads one S3 object as UTF-8 text at compile time (a failed fetch warns in a default compile and fails under abt compile --live). Typical kwargs: bucket, key, optional region, plus description, max_chars.

Credentials — uses boto3's standard credential resolution chain (env vars, ~/.aws/credentials, instance/task role). There is no profiles.yaml entry for this — unlike context.confluence/context.github, it's not routed through credentials.<namespace>.

Runtime files (delegating agents)

When the project is compiled, each context body is materialised on disk under:

  • target/context/local/ — context.local(...)
  • target/context/confluence/ — context.confluence(...)
  • target/context/github/ — context.github(...)
  • target/context/s3/ — context.s3(...)

For delegating agents, injected content_path uses /workspace/context/<provider>/…. Each run gets its own read-only copy of the context files of the manifest it was compiled from, so a run never reads another run's context, even when abt compile or an abt watch dispatch with different --vars rebuilds target/context/ in the meantime. target/context/ is the copy from the last compile, for local inspection.

Injected block shape

Rendered fragments are wrapped for clarity:

--- context: <name> ---
source: …
description: …
content_path: …   # delegating agent, when applicable
note: …          # e.g. content truncated
<body or empty>
--- end context ---

Rendering mode (context_mode)

Controls how {{ context.*() }} blocks are rendered into agent prompts at compile time.

Mode Behaviour
auto Default. Delegating agents get a content_path reference (plus the first max_chars characters, when set); plain agents and subagents get the content inlined. max_chars respected.
lazy Path and description only — no content inlined. Use when the agent should fetch context on demand via file tools.
full Full content always inlined — no content_path reference. Use when you want everything baked into the prompt regardless of agent type.

mode wins over max_chars. When mode is lazy or full, any max_chars= on the same call is ignored. Only auto respects max_chars.

Precedence

Per-call mode= kwarg > config.context_mode in abt.yaml > ABT_CONTEXT_MODE env var > auto.

Per-call override

{{ context.local('runbook', mode='lazy', description='On-call runbook') }}
{{ context.confluence('wiki', page_id='123', space='MOCK', mode='full') }}

Project-level default (abt.yaml)

config:
  context_mode: lazy   # auto | lazy | full

Lazy materialization (--lazy)

Each compile rewrites target/context/. --lazy skips that rewrite when the folder already exists: faster, but it can serve stale files. --no-lazy forces a rewrite.

Precedence: the --lazy/--no-lazy flag, then ABT_LAZY_CONTEXT, then flags.lazy_context in abt.yaml, then off.

# abt.yaml
flags:
  lazy_context: true

Don't confuse this with mode: lazy above. That setting controls how context appears in the prompt, not whether the files are rewritten.

Environment variables

Variable Purpose
ABT_CONTEXT_MODE Default rendering mode when not set in abt.yaml or per-call (auto | lazy | full).
ABT_LAZY_CONTEXT Default for --lazy (true/false). See Lazy materialization.
ABT_CONTEXT_FETCH_TIMEOUT Seconds for external fetch (default 60).
ABT_CONTEXT_DEFAULT_MAX_CHARS Global default when max_chars is omitted in the template (0 = no default).

Compile-time failures

External fetches retry with backoff. Under abt compile --live, repeated failure raises a hard error (E_CONTEXT_FETCH, naming the context); empty content counts as a failure. A default compile logs a warning instead and compiles the prompt without that section, so it succeeds without credentials or network access.