Skip to main content

agent_context

Return conditional behavior from an Agent's current active definition. Call it only for context advertised by bootstrap and only when the component's load_when guidance applies.

Parameters​

{
"agent": "engineering/code-reviewer",
"component_keys": ["architecture"]
}
FieldTypeDescription
agentstringExact caller-relative Agent name returned by the selected bootstrap result.
component_keysstring[]One to twenty advertised conditional-context keys to load.

The response returns the requested conditional components in the agent definition's order. Use the caller-relative name from the same task's selected bootstrap result. A later Agent behavior update is visible here immediately because each call resolves the current active version. If a rename or update invalidates the address or a requested key, bootstrap again before retrying.

Response​

FieldTypeDescription
agentobjectIdentity of the current Agent version used for this response.
agent.namestringCanonical owner-qualified Agent display name.
agent.versionintegerActive immutable version read for this call.
componentsobject[]All requested conditional components in canonical definition order.
components[].keystringStable component key.
components[].load_whenstringGuidance describing when this conditional behavior applies.
components[].instructionsstringInstructions for the conditional behavior.

Example​

{
"agent": "engineering/code-reviewer",
"component_keys": ["architecture"]
}

Result:

{
"agent": {
"name": "engineering/code-reviewer",
"version": 7
},
"components": [
{
"key": "architecture",
"category_key": "quality",
"category_name": "Quality",
"name": "Architecture guidance",
"description": "Guidelines for architectural decisions.",
"load_when": "The task involves architecture or subsystem boundaries.",
"instructions": "Prefer the established subsystem boundary."
}
]
}

components contains all and only the requested conditional components, in the definition's canonical order rather than the order of component_keys. Always-on components are already included by bootstrap and cannot be requested here.

Errors​

ErrorCause
invalid_paramsInput has a missing, non-string, or empty Agent name; invalid keys; unknown fields; an empty/duplicate key list; or more than 20 keys.
capability_deniedThe credential lacks Agents.
agent_context_unavailableAfter capability checks, the qualified Agent name is malformed, missing, or hidden, or requested conditional context is unavailable.
method_not_foundThe tool is absent or deprecated.
internal_errorAn unexpected server error occurred.

agent_context_unavailable does not reveal whether the Agent or a requested key is unavailable. The same error is returned for an always-on key. It is an isError tool result, returns no partial result, and does not guess a replacement name or key. Continue without that context or bootstrap again.

Notes​

  • agent_context is an authenticated system tool and does not require Tools or a tool-policy entry. Returning Agent content requires Agents and current Agent visibility.
  • Always-on behavior is already included in bootstrap; request only conditional context here.
  • The server rechecks the current credential's visibility and resolves the active version for every call. It does not keep task/session state.
  • If a rename or behavior update makes the requested context unavailable, continue without that conditional context or call bootstrap again before retrying.