class AgentContext
Bases:BaseModel
Central structure for managing prompt extension.
AgentContext unifies all the contextual inputs that shape how the system
extends and interprets user prompts. It combines both static environment
details and dynamic, user-activated extensions from skills.
Specifically, it provides:
- Repository context / Repo Skills: Information about the active codebase,
- Runtime context: Current execution environment (hosts, working directory, secrets, date, etc.).
- Conversation instructions: Optional task- or channel-specific rules that constrain or guide the agent’s behavior across the session.
- Knowledge Skills: Extensible components that can be triggered by user input to inject knowledge or domain-specific guidance.
Properties
current_datetime: datetime | str | Noneload_public_skills: boolload_user_skills: boolmarketplace_path: str | Nonesecrets: Mapping[str, SecretValue] | Noneskills: list[Skill]system_message_suffix: str | Noneuser_message_suffix: str | None
Methods
get_formatted_datetime()
Get formatted datetime string for inclusion in prompts.- Returns: Formatted datetime string, or None if current_datetime is not set. If current_datetime is a datetime object, it’s formatted as ISO 8601. If current_datetime is already a string, it’s returned as-is.
get_secret_infos()
Get secret information (name and description) from the secrets field.- Returns: List of dictionaries with ‘name’ and ‘description’ keys. Returns an empty list if no secrets are configured. Description will be None if not available.
get_system_message_suffix()
Get the system message with repo skill content and custom suffix. Custom suffix can typically includes:- Repository information (repo name, branch name, PR number, etc.)
- Runtime information (e.g., available hosts, current date)
- Conversation instructions (e.g., user preferences, task details)
- Repository-specific instructions (collected from repo skills)
- Available skills list (for AgentSkills-format and triggered skills)
- Parameters:
llm_model– Optional LLM model name for vendor-specific skill filtering.llm_model_canonical– Optional canonical LLM model name.additional_secret_infos– Optional list of additional secret info dicts (with ‘name’ and ‘description’ keys) to merge with agent_context secrets. Typically passed from conversation’s secret_registry.
- AgentSkills-format (SKILL.md): Always in
<available_skills>(progressive
- Legacy with trigger=None: Full content in
<REPO_CONTEXT>(always active) - Legacy with triggers: Listed in
<available_skills>, injected on trigger
get_user_message_suffix()
Augment the user’s message with knowledge recalled from skills. This works by:- Extracting the text content of the user message
- Matching skill triggers against the query
- Returning formatted knowledge and triggered skill names if relevant skills were triggered
model_config = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].class BaseTrigger
Bases:BaseModel, ABC
Base class for all trigger types.
Methods
model_config = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].class KeywordTrigger
Bases:BaseTrigger
Trigger for keyword-based skills.
These skills are activated when specific keywords appear in the user’s query.
Properties
keywords: list[str]type: Literal[‘keyword’]
Methods
model_config = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].class Skill
Bases:BaseModel
A skill provides specialized knowledge or functionality.
Skill behavior depends on format (is_agentskills_format) and trigger:
AgentSkills format (SKILL.md files):
- Always listed in
<available_skills>with name, description, location - Agent reads full content on demand (progressive disclosure)
- If has triggers: content is ALSO auto-injected when triggered
- With triggers: Listed in
<available_skills>, content injected on trigger - Without triggers (None): Full content in
<REPO_CONTEXT>, always active
Properties
MAX_DESCRIPTION_LENGTH: ClassVar[int] = 1024PATH_TO_THIRD_PARTY_SKILL_NAME: ClassVar[dict[str, str]] = (configuration object)allowed_tools: list[str] | Nonecompatibility: str | Nonecontent: strdescription: str | Noneinputs: list[InputMetadata]is_agentskills_format: boollicense: str | Nonemcp_tools: dict | Nonemetadata: dict[str, str] | Nonename: strresources: SkillResources | Nonesource: str | Nonetrigger: Annotated[KeywordTrigger | TaskTrigger, FieldInfo(annotation=NoneType, required=True, discriminator=‘type’)] | None
Methods
extract_variables()
Extract variables from the content. Variables are in the format (variable).get_skill_type()
Determine the type of this skill.- Returns: “agentskills” for AgentSkills format, “repo” for always-active skills, “knowledge” for trigger-based skills.
get_triggers()
Extract trigger keywords from this skill.- Returns: List of trigger strings, or empty list if no triggers.
classmethod load()
Load a skill from a markdown file with frontmatter. The agent’s name is derived from its path relative to skill_base_dir, or from the directory name for AgentSkills-style SKILL.md files. Supports both OpenHands-specific frontmatter fields and AgentSkills standard fields (https://agentskills.io/specification).- Parameters:
path– Path to the skill file.skill_base_dir– Base directory for skills (used to derive relative names).strict– If True, enforce strict AgentSkills name validation. If False, allow relaxed naming (e.g., for plugin compatibility).
match_trigger()
Match a trigger in the message. Returns the first trigger that matches the message, or None if no match. Only applies to KeywordTrigger and TaskTrigger types.model_config = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].model_post_init()
This function is meant to behave like a BaseModel method to initialise private attributes. It takes context as an argument since that’s what pydantic-core passes when calling it.- Parameters:
self– The BaseModel instance.context– The context.
requires_user_input()
Check if this skill requires user input. Returns True if the content contains variables in the format (variable).to_skill_info()
Convert this skill to a SkillInfo.- Returns: SkillInfo containing the skill’s essential information.
class SkillKnowledge
Bases:BaseModel
Represents knowledge from a triggered skill.
Properties
content: strlocation: str | Nonename: strtrigger: str
Methods
model_config = (configuration object)
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].init()
class TaskTrigger
Bases:BaseTrigger
Trigger for task-specific skills.
These skills are activated for specific task types and can modify prompts.
Properties
triggers: list[str]type: Literal[‘task’]

