Skip to content

API Reference parrot.metrics.context

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.metrics.context

View source

Per-task metric match ContextVar and tenant resolution (FEAT-756 M3, D3).

Alias MetricMatch

Re-exported from parrot.metrics.models.MetricMatch.

Function bind_metric_match

Bind match for the current task and return the reset token.

bind_metric_match(match: MetricMatch | None) -> Token

Parameter Type Default Description
match MetricMatch | None

Returns: Token

Function current_metric_match

Return the match bound to the current task, or None.

current_metric_match() -> MetricMatch | None

Returns: MetricMatch | None

Alias current_skill_tenant

Re-exported from parrot.skills.tenancy.current_skill_tenant.

Function reset_metric_match

Undo a prior :func:bind_metric_match call.

reset_metric_match(token: Token) -> None

Parameter Type Default Description
token Token

Function resolve_metric_tenant

Resolve and validate the first non-empty metric tenant candidate.

Resolution order is explicit tenant, ctx.kwargs["tenant"], the request-local skill tenant, and finally the supplied default.

explicit is for trusted host code only. The model-facing lanes never forward a tenant from tool arguments: MetricsToolkit and MetricRoutingMixin both call this with explicit=None, so their tenant comes from the request context, the skill tenant, or the default.

resolve_metric_tenant(explicit: str | None = None, ctx: Any | None = None, default: str | None = None) -> str | None

Parameter Type Default Description
explicit str | None None
ctx Any | None None
default str | None None

Returns: str | None

Alias validate_tenant_id

Re-exported from parrot.skills.tenancy.validate_tenant_id.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally