Skip to main content
Every local routing step passes its candidate agents through seven sequential gates before Hivenet Router ranks and selects one. The gates answer a series of increasingly specific questions:
  1. Does any agent serve the requested model?
  2. Is the agent and its backend healthy?
  3. Does it serve the required workload capability?
  4. Does its metadata match the policy?
  5. Has it already failed this request within the current step?
  6. Does it have free declared capacity?
  7. Does it pass the configured live metric thresholds?
Policy If a gate removes every remaining agent, that policy step is exhausted. The capacity gate is the exception: when otherwise eligible agents exist but are full, Hivenet Router can wait in the per-model capacity queue before advancing to the next fallback step.
Ranking happens after the seven gates. The current least-loaded strategy orders only the agents that survive the entire funnel.

Gate summary

The first six gates always apply. Gate 7 applies only when the policy step contains:

Gate 1: Model filter

The model filter creates the initial candidate pool. Hivenet Router loads agents registered for the exact model name supplied by the client:
Model matching is exact and case-sensitive. This request does not match an agent registered as:

When the gate drains the pool

Gate 1 fails when no local agent is registered for the requested model. Later local fallback steps cannot recover by selecting a different model. The requested model remains fixed throughout the local policy chain. An external provider fallback may still run for an eligible language-model chat request because it can deliberately substitute its configured provider model.

Diagnose it

List the operator model catalog:
Check the model registered by each agent:

Fix it

  • Start an agent for the requested model.
  • Correct the client’s model name.
  • Pin the intended model with the agent’s --model setting.
  • Give several backend implementations the same public model name when they should participate in one fallback chain.

Gate 2: Health

An agent passes the health gate only when both of these states are healthy:
The router tracks the agent’s connection and heartbeat state. The agent reports whether its local inference backend passed the latest backend health check.

When the gate drains the pool

Gate 2 fails when every agent serving the model is:
  • disconnected
  • marked unhealthy by the router
  • reporting an unhealthy inference backend
  • or some combination of these states

Diagnose it

Check the health summary:
Inspect the two health fields separately:

Fix it

  • Check the agent process and logs.
  • Test the inference backend’s health endpoint locally.
  • Confirm that the agent can reach the router’s gRPC and libp2p ports.
  • Confirm that the agent can reach the router’s advertised libp2p address.
  • Check firewall, NAT, container, and network-policy changes on the outbound agent-to-router path.
  • Verify that the router and agent use the same JWT secret.

Gate 3: Capability

Each agent registers one capability:
The request endpoint determines the required capability.

When the gate drains the pool

Gate 3 fails when agents exist for the model name, but none serve the required workload type. For example, an agent registered as:
cannot serve:
even if the request uses the same model name.

Diagnose it

Fix it

  • Start the agent with the correct --capability.
  • Use llm, embedding, or reranker exactly.
  • Send the request to the endpoint that matches the agent capability.
  • Use distinct public model names when one set of weights is exposed for different workload types.

Gate 4: Static match

The match gate applies the policy step’s static metadata filters.
Every non-empty field must match. All comparisons are exact and case-sensitive.

Supported fields

For tags, the agent must contain every tag listed by the policy. It may contain additional tags.

When the gate drains the pool

Gate 4 fails when no remaining agent satisfies every configured field. A common cause is incomplete agent metadata. For example, a policy may require:
while the registered agent reports an empty engine value.

Diagnose it

The policy_exhausted log includes the actual and required values. For example:
This means two candidates reported an empty engine while the policy required vllm. Inspect live metadata:

Fix it

  • Correct the policy value.
  • Correct the agent metadata.
  • Check capitalization and punctuation.
  • Remove a filter that does not express a real operational requirement.
  • Add a later fallback step with deliberately relaxed filters.

Gate 5: Previous failures

The previous-failures gate removes agents that already produced a forwarding failure during the current policy step. This prevents Hivenet Router from repeatedly choosing the same unsuccessful agent while other candidates remain.

Scope of the exclusion

The failed-agent set belongs to one request and one policy step. It resets when Hivenet Router advances from:
to a fallback step, or from one fallback step to the next. An agent that failed in the primary step may therefore become eligible again in a later step when the policies overlap.

When the gate drains the pool

Gate 5 drains the pool when every otherwise eligible agent has already failed during the current step. This can happen before max_tries is reached when the number of eligible agents is smaller than the configured attempt budget. For example:
After both agents fail once, no untried agent remains in the step.

Diagnose it

Search router logs using the request ID. Look for forwarding errors before the final exhaustion line:
The exhaustion reason may contain:

Fix it

This gate normally describes the result of earlier failures rather than a configuration problem. Investigate:
  • backend errors
  • agent disconnections
  • backend overload
  • network failures
  • request incompatibility across engines
Also check whether later fallback steps overlap completely with the current step. An overlapping fallback may retry the same agents.

Gate 6: Capacity

The capacity gate compares the agent’s active request count with its declared capacity. An agent passes when:
It fails when:
Capacity is configured on the agent:

When the gate drains the pool

Gate 6 fails when every remaining agent has used all its declared slots. This does not necessarily mean the backend is broken. It may be healthy and serving its current workload normally.

Queue behavior

When eligible agents exist but are full, Hivenet Router can place the request in the per-model capacity queue before advancing to a fallback step. The default queue depth is:
Configure it:
Disable it for immediate fallback:

Diagnose it

Inspect active requests and capacity:
The exhaustion log may contain:

Fix it

  • Add more agents for the model.
  • Increase --capacity only when the backend and hardware can support more concurrency.
  • Lower request duration or backend queue pressure.
  • Configure a fallback step with additional infrastructure.
  • Disable or reduce queueing when fast failover is preferable.
Agents must declare a positive capacity. The router rejects agent authentication when capacity is zero or negative.
For streaming responses, Hivenet Router releases the capacity slot when response headers arrive, while backend generation can continue. Gate 6 therefore limits routing admission rather than the complete lifetime of active streams.

Gate 7: Dynamic metric thresholds

The exclude_if gate evaluates live operational metrics.
An agent fails Gate 7 when it violates any configured rule.

Operators

Each field must define exactly one operator: Valid:
Invalid:
Unknown fields and rules with zero or several operators are rejected when the policy loads.

Available gate fields

Universal signals

Engine signals

Hardware signals

For multi-GPU agents, Hivenet Router evaluates the highest reported GPU temperature, compute utilization, and VRAM utilization.

Missing metrics pass

A gate is skipped when the selected metric is unavailable for an agent. For example:
does not exclude an Ollama agent that reports no KV-cache metric.
Missing data passes the gate.Do not use a metric gate by itself when the presence of that metric is a hard requirement.
Combine an engine filter with an engine-specific metric:
Or use metadata tags to identify agents with a known observability profile:

Metrics that begin without history

Some values are unavailable when an agent first registers. These include:
  • success_rate
  • srtt
  • consecutive_failures
  • TTFT and ITL values before the backend has completed requests
A new agent therefore passes gates using those fields until the router or backend has collected enough data. For example:
does not exclude a new agent with no request history. This avoids treating missing history as failure, but it also means a newly registered agent can receive production traffic before it has established a track record. Use static tags, staged rollout, or a separate policy when new agents need a controlled warm-up period.

Practical gate patterns

Preserve headroom

Use the live capacity ratio before the hard capacity limit:
This stops assigning new work after 80% of declared capacity is in use. It preserves headroom but may increase queueing or fallback activity.

Avoid backend queues

This routes away as soon as the backend scheduler reports queued requests. It is strict. A short-lived queue of one request can drain the step immediately. A more tolerant policy is:

Protect the KV cache

This can reduce cache pressure and preemptions on engines that report the metric. Use an engine match when the policy depends on this signal:

Route away from high latency

The threshold is in milliseconds. SRTT includes the router-agent request path and backend response timing observed by Hivenet Router. It is not a pure network-latency measurement.

Protect response quality during instability

Success rate is a broader historical signal. Consecutive failures reacts more quickly to a recent failure streak. Using both can protect against persistent and sudden instability.

Avoid hot GPUs

The appropriate threshold depends on the GPU model, cooling, ambient conditions, and your operational policy. Do not copy one temperature threshold across unrelated hardware without testing.

Avoid VRAM pressure

This uses total device VRAM use reported by the agent host. It differs from:
which measures the inference engine’s allocated cache pressure when that engine reports it.

Combine system pressure signals

Because the rules use OR behavior, violating any one threshold excludes the agent.

Strict and relaxed steps

A useful fallback design starts with protective gates and relaxes them deliberately.
This gives the router three levels:
  1. healthy vLLM agents with low pressure
  2. vLLM agents under moderate pressure
  3. any healthy local agent serving the model

Diagnose policy exhaustion

Hivenet Router writes one policy_exhausted warning when the entire local policy chain is exhausted. It does not emit that warning when an earlier step fails but a later fallback succeeds. An example log resembles:
Each part of reason follows this shape:
The example says:
  • the primary step lost two agents because their engine metadata did not match
  • the relaxed step lost two agents because their region metadata did not match
  • the last-resort step lost two agents because their KV-cache use violated the configured gate
The tried=3/3 field refers to exhausted policy steps recorded in the diagnostic, not to three backend forwarding attempts.
A step exhausted by forwarding failures reports:

Correlate a request

Supply a UUID request ID:
Search the router logs:
With Docker Compose:
Enable more policy detail:

Monitor exhausted policies

Inspect the policy-exhaustion counter:
PromQL:
A sustained increase can indicate:
  • missing or incorrect model registrations
  • unhealthy agents
  • capability mismatches
  • incorrect metadata
  • insufficient capacity
  • overly strict metric gates
  • repeated backend failures
Use logs to identify the exact gate. The metric reports that the chain was exhausted, not why.

Test gates safely

Test one rule at a time in a controlled environment. A practical process is:
  1. Record the current value through /admin/routing-table.
  2. Add one gate with a threshold that should pass.
  3. Reload the policy.
  4. Send a request and confirm normal routing.
  5. Change the threshold so the test agent should fail.
  6. Confirm that a fallback agent serves the request.
  7. Inspect the exhaustion diagnostics when no fallback is available.
  8. Restore the intended threshold.
For example, inspect cache use:
Then test a threshold slightly below the observed value. Avoid arbitrary impossible gates in shared production environments. A temporary test tag is usually easier to understand and reverse.

Common mistakes

Using percentage values from 0 to 100

Incorrect:
Correct:

Treating SRTT as seconds

Incorrect for a 500-millisecond threshold:
Correct:

Depending on an unavailable metric

This rule does not protect an Ollama pool:
Ollama agents do not report that value, so they pass.

Setting several operators

Invalid:
Each gate accepts one operator.

Making the primary policy too strict

A policy that combines many narrow filters and gates may drain under normal variance. Use fallback steps to express what can be relaxed and in what order.

Using health gates as alert thresholds

A routing threshold decides whether an agent receives the current request. It is not automatically the right threshold for paging an operator. For example, routing away from a GPU at 82°C may be sensible without treating every short 82°C reading as an incident. Keep routing policy and alerting policy separate.

Next steps

Prometheus metrics

Observe the live metrics used by routing gates.

Hardware metrics

Understand GPU, CPU, and memory values reported by agents.

Engine metrics

Review cache, queue, TTFT, ITL, and throughput signals from supported engines.