Skip to main content

Signature


Parameters

string
required
The agent’s name. Used in SPIFFE ID generation, Kubernetes resource naming, and observability.Must be kebab-case: research-analyst, content-crew, data-pipeline.
string
required
The tenant (organization) this agent belongs to. Maps to a Kubernetes namespace: tenant-{tenant}.
list[str]
default:"None"
Cloud resources this agent needs access to. Used by OPA policies to scope credential exchange.Examples: ["aws_s3", "gcp_bigquery", "azure_storage"]
bool
default:"False"
Enable subprocess role management. When True, child processes can declare different roles and get distinct SPIFFE identities within the same pod.
dict
default:"None"
Multi-region credential configuration.Example: {"aws": "us-west-2", "gcp": "us-central1"}
bool
default:"False"
Enable Agent-to-Agent communication. Starts the A2A bridge (HTTP server on :8080) that receives JSON-RPC messages from the A2A sidecar. Serves an Agent Card at /.well-known/agent.json.
list[dict]
default:"None"
A2A skill declarations for the Agent Card. Each skill has id, name, and description.
string
default:"None"
Human-readable description for the Agent Card. Visible to other agents during A2A discovery.
string
default:"None"
Agent version string. Included in Agent Card and OTel spans.

Basic Usage

Function Decorator

Class Decorator


What @hexr_agent Does

When you decorate a function or class with @hexr_agent:
1

Sets Agent Context

Calls HexrContext.set_agent_context() which:
  • Sets ContextVars (tenant, agent_name, framework, resources)
  • Writes a process context marker file to /tmp/hexr-context/
  • Registers the process with the Auto-Registrar
2

Initializes OpenTelemetry

Creates a TracerProvider and MeterProvider pointing at the OTel Collector. All subsequent SDK calls emit spans and metrics automatically.
3

Starts A2A Bridge (if a2a=True)

Starts an HTTP server on :8080 that:
  • Receives /execute calls from the A2A sidecar
  • Calls your function with the message content
  • Returns the result as a Task artifact
4

Wraps Execution

Every invocation of your function/class is wrapped with:
  • hexr.agent.invoke OTel span
  • hexr.agent.invocations metric counter
  • hexr.agent.duration histogram
  • Error capture and status propagation

Framework Detection

hexr build uses AST analysis (~2,900 lines) to auto-detect your agent framework: The detected framework is stored in HEXR_FRAMEWORK env var and included in all OTel spans.

A2A Agent Card

When a2a=True, your agent is discoverable by other agents via the A2A protocol:

Examples

Multi-Cloud Agent

CrewAI with A2A

Subprocess Support