Skip to navigation

Adaptive

View as MarkdownOpen in Claude

Use this reference for manual adaptive runtime APIs. For plugin-managed configuration, start with Adaptive Configuration.

Adaptive Configuration

An AdaptiveConfig combines state, telemetry, tool parallelism, hints, and ACG settings. Use AdaptiveRuntime to register the configured components before application work and shut them down afterward.

Manual API

Use the manual runtime API when an integration needs to own adaptive lifecycle directly instead of activating the top-level plugin component.

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(
subscriber_name="adaptive.telemetry",
learners=["tool_parallelism"],
),
tool_parallelism=nemo_relay.adaptive.ToolParallelismConfig(mode="observe_only"),
adaptive_hints=nemo_relay.adaptive.AdaptiveHintsConfig(
inject_body_path="nvext.agent_hints",
),
acg=nemo_relay.adaptive.AcgConfig(provider="passthrough"),
)
runtime = nemo_relay.adaptive.AdaptiveRuntime(adaptive_config.to_dict())
async def main() -> None:
await runtime.register()
try:
# Run instrumented application work here.
runtime.wait_for_idle()
finally:
await runtime.shutdown()
asyncio.run(main())

Expected outcome: Registration and shutdown complete without error. These examples do not print output.

Adaptive Cache Governor (ACG)

Manual API

Use the manual runtime API when an integration needs to own adaptive lifecycle directly instead of activating the top-level plugin component.

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=["acg"]),
acg=nemo_relay.adaptive.AcgConfig(provider="anthropic"),
)
runtime = nemo_relay.adaptive.AdaptiveRuntime(adaptive_config.to_dict())
async def main() -> None:
await runtime.register()
try:
# Run instrumented application work here.
runtime.wait_for_idle()
finally:
await runtime.shutdown()
asyncio.run(main())

Expected outcome: Registration and shutdown complete without error. These examples do not print output.

Adaptive Hints

Manual API

Use the manual runtime API when an integration needs to own adaptive lifecycle directly instead of activating the top-level plugin component.

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=["tool_parallelism"]),
adaptive_hints=nemo_relay.adaptive.AdaptiveHintsConfig(
inject_body_path="nvext.agent_hints",
),
)
runtime = nemo_relay.adaptive.AdaptiveRuntime(adaptive_config.to_dict())
async def main() -> None:
await runtime.register()
try:
# Run instrumented application work here.
nemo_relay.adaptive.set_latency_sensitivity(8)
finally:
await runtime.shutdown()
asyncio.run(main())

Expected outcome: Registration and shutdown complete without error. These examples do not print output.