instructions
instructions
¶
Agent instruction resolution: layered merging with bundled defaults.
Resolves the instructions config key from the merged agent-config dict,
supporting flat strings, per-provider dicts, and lists with _inherit
splicing. Falls back to a bundled default that describes the standard
container environment.
Two independent layers control what a task receives:
- YAML
instructionskey — controls the inheritance chain via config stack. Uses_inheritin list form to splice the bundled default at that position. Absent/None ⇒ bundled default. - Standalone
instructions.mdfile inproject_root— always appended at the end of whatever the YAML chain resolved. Purely additive. If empty or absent, nothing is appended.
bundled_default_instructions()
¶
Read and return the bundled default instructions from package resources.
Source code in src/terok_agent/instructions.py
resolve_instructions(config, provider_name, project_root=None)
¶
Resolve instructions from a merged config dict.
Supports:
- Flat string: returned as-is
- Per-provider dict: uses :func:resolve_provider_value, falls back to _default
- List (with _inherit): splices bundled default at each _inherit sentinel
- Absent/None: returns bundled default
After resolving the YAML value, appends the contents of
project_root/instructions.md (if it exists and is non-empty).
Returns the final instructions text.
Source code in src/terok_agent/instructions.py
has_custom_instructions(config, project_root=None)
¶
Check if config has explicit (non-default) instructions.
Returns True when either the YAML instructions key is set or a
standalone instructions.md file exists under project_root.