This module assembles the full system prompt for your Invoke agent by embedding:
- π Current date & time
- π§ Framework instructions & base prompt
- π€ Tool definitions from built-in, local or remote
agents.txt/agents.json
It supports:
- Built-in aliases (e.g.
"google-maps") - Bare file paths or URLs (auto-infers name from JSON metadata or filename)
- Explicit
{name: path}mappings - Optional
agents_map.yaml(only loaded when you donβt supply anagentslist)
from invoke_agent.context import build_context, load_agents_mapdef build_context(
base_prompt: str = '',
agents: Optional[Union[str, List[Union[str, dict]]]] = None
) -> strConstructs the agentβs system prompt by:
- Using
base_prompt(if provided), otherwise the built-inDEFAULT_CONTEXTblock. - Loading any integrations via
load_agents_map(source=agents). - Appending each integration under a
# {name}header.
-
Explicit list
ctx = build_context( base_prompt="You're my assistant.", agents=["google-maps", "./my_weather.json"] )
-
Auto-load
agents_map.yaml# If no `agents` arg is given and you have an `agents_map.yaml`, it will be used: ctx = build_context()
def load_agents_map(
source: Optional[Union[str, List[Union[str, dict]]]] = None
) -> Dict[str, str]Returns a mapping { name: agents_txt_content }, by:
- If
sourceis alist: iterate its entries. - Elif
sourceis astrpointing to a file: load that YAML. - Else (no
source): if./agents_map.yamlexists, load it; otherwise return{}.
Each entry in the list may be:
-
Built-in alias (e.g.
"google-calendar") -
Bare path/URL (e.g.
"./agents/foo.json","https://β¦/bar.txt")- Name is inferred from the JSON
"agent"field or the file basename.
- Name is inferred from the JSON
-
Explicit mapping
{ "my-calendar": "./calendar.json" }
If a resource is JSON, itβs passed through render_agents_txt() to produce human-readable text.
A built-in system prompt you can override by passing your own base_prompt. It includes:
- Current date & time
- Framework usage guidelines
- Example JSON call
- OAuth & error-handling instructions
- βDo not announce actions, just do them. Seek confirmation if unsure.β
| Feature | Behavior |
|---|---|
| π Built-in aliases | Fetches from https://invoke.network/api/agents-txt/{alias} |
| π Local & remote | Load .json/.txt files by path or URL; infer names automatically |
| π JSON β TXT | Auto-render agents.json schemas into human-readable form |
| ποΈ Optional YAML | Only reads agents_map.yaml when no agents argument given |
| π Time-aware | Embeds the current timestamp on each context build |
Note: If you want a completely custom system prompt, pass your own context string to InvokeAgentβbuild_context() will still append integrations afterward.