Skip to navigation

Use Adaptive Hints when downstream model calls or provider adapters can safely receive guidance metadata from the adaptive runtime.

Adaptive hints register as LLM request intercepts. Lower numeric priority values run earlier in the intercept chain. The plugin sets the default priority relative to other middleware rather than as a standalone importance score.

plugins.toml Example

Add the following Adaptive Hints configuration to plugins.toml:

version = 1
[[components]]
kind = "adaptive"
enabled = true
[components.config]
version = 1
agent_id = "planner"
[components.config.state.backend]
kind = "in_memory"
[components.config.telemetry]
subscriber_name = "adaptive.telemetry"
learners = ["latency_sensitivity"]
[components.config.adaptive_hints]
priority = 100
break_chain = false
inject_header = true
inject_body_path = "nvext.agent_hints"

The latency_sensitivity learner produces request scheduling hints from completed agent runs. The tool_parallelism learner produces tool execution plans instead. This configuration allows later request intercepts to continue running.

Plugin Configuration

Use plugin configuration when the application should let NeMo Relay own the Adaptive Hints request-intercept lifecycle. The following examples configure and activate Adaptive Hints through each supported language binding.

validate() resolves the same configuration layers as initialize() without loading plugin code or acquiring the activation lease. Use Python/Rust validate_exact(), Node.js validateExact(), or Go ValidateExact() when only the supplied static configuration should be checked. For complete layering rules, refer to Configure.

import asyncio
import nemo_relay
adaptive_config = nemo_relay.adaptive.AdaptiveConfig(
agent_id="planner",
state=nemo_relay.adaptive.StateConfig(
backend=nemo_relay.adaptive.BackendSpec.in_memory(),
),
telemetry=nemo_relay.adaptive.TelemetryConfig(learners=["latency_sensitivity"]),
adaptive_hints=nemo_relay.adaptive.AdaptiveHintsConfig(
inject_body_path="nvext.agent_hints",
),
)
plugin_config = nemo_relay.plugin.PluginConfig(
components=[nemo_relay.adaptive.ComponentSpec(adaptive_config)]
)
report = nemo_relay.plugin.validate(plugin_config)["config"]
if any(diagnostic["level"] == "error" for diagnostic in report["diagnostics"]):
raise RuntimeError(report["diagnostics"])
async def main() -> None:
async with nemo_relay.plugin.activate(plugin_config):
# Run instrumented application work here.
pass
asyncio.run(main())

Learning From Completed Runs

Run managed model calls inside an agent scope. The learner updates hints asynchronously after the agent scope completes.

The examples use an in-memory backend with no initial history. The first run has no learned hints. Later runs can receive hints after learning finishes. The state is not retained across adaptive runtime restarts.

Manual API

To supply latency guidance before any runs have completed, set a value on the active scope before calling the model:

  • Python: nemo_relay.adaptive.set_latency_sensitivity(8).
  • Node.js: adaptive.setLatencySensitivity(8).
  • Rust: nemo_relay_adaptive::set_latency_sensitivity(8)?.

For manual runtime construction and lifecycle examples, refer to Manual API.

Fields

The following table describes Adaptive Hints settings:

FieldDefaultNotes
priority100Request intercept priority. Lower values run earlier.
break_chainfalseWhether this intercept stops later request intercepts.
inject_headertrueWhether to add adaptive hints as request header metadata.
inject_body_pathnvext.agent_hintsDot-separated JSON body path for request-body hint injection. Missing objects along the path are created. The body is left unchanged if a parent value is not an object.

Disable break_chain unless the adaptive hint should be the final request transform. Adjust priority only when adaptive hints need to run before or after known application middleware.

Expected Output

When learned or manual hints are available, the example configuration adds them to the x-nemo-relay-adaptive-agent-hints header and nvext.agent_hints in the request body. The hints do not replace the application callback or change the returned value by themselves. Downstream code must explicitly interpret the metadata before behavior changes.

Common Configuration and Runtime Issues

  • Unknown adaptive hint fields when unknown fields are treated as errors.
  • inject_body_path does not match the request shape expected by downstream provider adapters.
  • Hint injection is enabled before downstream model paths can consume or ignore the metadata safely.