HintBlock, configured via the injection_config parameter of Agent(...).
The injection covers three dimensions, each with its own timing rule:
How Injection Works
Each injected field is wrapped as<key>value</key>, and all fields are joined and placed into the template (a <system-reminder> wrapper by default). A typical injected hint looks like:
Example Injected Hint
- The injection is not ephemeral: it is appended to the persistent context on purpose, so the agent can perceive how time elapses and what it did at each step, building a sense of time.
- The hint is attached as a
HintBlockinstead of mutating the system prompt, so prompt caching still works while the agent stays aware of the changing state. - Only information that changes within a conversation is injected. Fixed information (the agent’s identity, standing instructions) belongs in the system prompt.
emit_hint_event is enabled, reply_stream also yields a HintBlockEvent, so a frontend can render the injected hint.
Configure Injection
Pass anInjectionConfig to the agent constructor to tune the injection behavior:
InjectionConfig:
context_buffer_ratio must be smaller than the trigger_ratio of the context config, so that the context usage is injected before the compression happens. Otherwise the agent constructor raises a ValueError.Inject Custom Fields
Beyond the built-in dimensions,extra_fields injects developer-defined information, such as sensor readings or deployment metadata:
Customize the Template
Thetemplate field controls how the injected fields are presented to the LLM. It must contain the {runtime_state} placeholder, which is replaced by the joined <key>value</key> fields: