HintBlock, configured via the injection_config parameter of Agent(...).
The injection covers four dimensions, each with its own timing rule:
The
context_buffer_ratio behind the context usage dimension lives in the context config; the other three dimensions are governed by InjectionConfig.
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 on InjectionConfig is deprecated; use the field of the same name in the context config instead. Passing it here still works and overrides the value from the context config, along with a DeprecationWarning.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: