Skip to content
triageagent-devPublic

Repository files navigation

ego logo

ego

Reality testing for AI agents

In psychology, the ego is the part of the mind that tests reality: it tells what is imagined from what actually happened, and holds the self-image up against the world. An agent has the same split.

ego is recursive self-improvement (RSI) for AI agents, run on the OpenTelemetry traces they already emit: it scores the agent, and when scores drop it diagnoses why, hands the diagnosis to the agent over MCP, records what the agent changed and checks that the scores recovered. It never re-runs the agent.

One static Go binary: REST API, web UI, OTLP receivers and an MCP server. No SDK to add, no extra runtime.

Contents

RSI: the loop

sample → score → detect → diagnose → correct → verify
Step What happens Where to look
sample completed sessions are sampled per tenant and call kind, errors and outliers first, within a daily judge budget Quality view, GET /api/online/status
score each sampled session is scored by the evaluators of its kind's profile Runs view, explain_session
detect a significant drop of a (tenant, kind, metric) series opens an alert, attributed to the version or model that changed get_quality, explain_regression
diagnose an alert, or a series that stays below findings.minScore, gets a finding: failure mode, summary, suggested correction, evidence sessions get_findings, Quality view
correct the agent (or a person) registers what changed and the service.version it ships as; the sampler scores the next sessions first register_correction
verify the scores after the correction are compared with the ones before: verified resolves the finding, failed reopens it with the attempt in its history list_corrections

People calibrate the judges: agree or disagree with a score on any session. A metric whose judge people mostly disagree with stops producing findings, and labelled sessions are re-scored daily to measure judge drift.

The agent side is one skill, skills/ego-rsi, also served as the MCP prompt rsi_loop: check the findings, read their evidence, make one change per finding, register it, come back for the verdict. The design and the as-built notes are in docs/rsi.md.

Work in progress. Interfaces can change between releases. docs/STATUS.md lists what is supported, known simplifications and what is out of scope.

Each tagged release (v*.*.*) publishes binaries for Linux and macOS (amd64, arm64), a multi-arch container image (ghcr.io/triageagent-dev/ego) and the Helm chart (oci://ghcr.io/triageagent-dev/charts/ego). ego version prints the installed version. Download a binary from the release page and check it against checksums.txt (signed, see Releasing), or run the image.

What it does

  • Score sessions: did the agent call the right tools, are its claims backed by what the tools returned, did it resolve the request, does it meet your rubrics. From a trace file or from live traffic.
  • Watch live: point any OTel-instrumented agent at ego and its sessions, conversations and spans appear as they arrive.
  • Track quality: every run is kept; online evaluation samples live sessions, scores them per call kind and alerts on regressions.
  • Diagnose: a low-scoring series gets a finding, a short diagnosis with the failure mode, the evidence sessions and a suggested correction.
  • Correct and verify: the agent reads its findings over MCP, changes itself, registers the correction, and ego reports whether the scores recovered.
  • Count tokens: a usage ledger built from gen_ai.usage.* on LLM spans.

Quick start

Run it on your machine

# download the binary for your platform from the latest GitHub release and put it on your PATH

export EGO_OTLP_TOKEN=$(openssl rand -hex 32)   # the password your agent sends its traces with
ego serve --session-db ego.db

Open http://localhost:8001. ego.db is where sessions, runs and eval sets are kept; leave --session-db out and the Runs, Eval sets and Quality views do not work.

Now send traces. Any OpenTelemetry-instrumented agent works, with no SDK to add:

export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318      # gRPC exporters use :4317
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer $EGO_OTLP_TOKEN"
./your_agent

Its sessions appear under Live as they arrive. The server listens on 127.0.0.1 only and has no login, so anyone on your machine is an admin. On macOS, if the download is blocked: xattr -d com.apple.quarantine $(which ego).

To score a trace file without a server (Jaeger JSON or OTLP JSON; examples are in the repository's samples/ folder): ego run trace.json --eval-set eval_set.json -m tool_trajectory_avg_score.

Run it in Kubernetes

kubectl create secret generic ego-otlp-token --from-literal=OTLP_TOKEN="$(openssl rand -hex 32)"

helm install ego oci://ghcr.io/triageagent-dev/charts/ego \
  --set auth.enabled=false --set vertex.enabled=false \
  --set otlpAuth.enabled=true --set otlpAuth.secret=ego-otlp-token

kubectl port-forward svc/ego 8001:8001      # then open http://localhost:8001

Point your agent's OpenTelemetry exporter at ego:4318 (OTLP/HTTP) or ego:4317 (gRPC) with the header Authorization=Bearer <the OTLP_TOKEN value>. Sessions are kept on a 1Gi volume.

auth.enabled=false serves every caller as admin: use it only where the network limits who can reach the service, as with port-forward. For GitHub sign-in, an ingress and per-team access see charts/ego/README.md.

Container only: docker run -p 8001:8001 -p 4318:4318 -e EGO_NO_AUTH=true -e EGO_OTLP_TOKEN=... -v ego:/data -e EGO_SESSION_DB_PATH=/data/ego.db ghcr.io/triageagent-dev/ego:latest.

The UI

View What it does
Live Streaming sessions: conversation, tool calls, spans with errors first, per-session metrics and online scores with agree/disagree. Pick a golden session and evaluate the rest against it.
Evaluate Upload traces and an eval set, choose metrics, run.
Runs Every evaluation run: pass-rate and per-metric trends, per-case results.
Usage Token spend by call kind, tenant, model and service, with per-session drill-down.
Quality Online evaluation: judge budget, what was sampled, open regressions, hourly scores, findings, corrections and judge agreement.
Eval sets Build golden eval sets from traces and keep them.

Metrics

Metric Needs
tool_trajectory_avg_score eval set
response_match_score (ROUGE-1) eval set
final_response_match_v2 eval set + judge model
rubric_based_final_response_quality_v1, rubric_based_tool_use_quality_v1 judge model, --rubric
hallucinations_v1 judge model
safety_v1, multi_turn_task_success_v1, multi_turn_trajectory_quality_v1, multi_turn_tool_use_quality_v1 Vertex AI Managed Eval (ADC)
jev_task_resolved, jev_grounded, jev_tool_use_appropriate, jev_matches_reference, jev_response_kind, custom jev:<key> Jev decision model

Judge model. The judge metrics call Gemini directly: GEMINI_API_KEY/GOOGLE_API_KEY or --judge-api-key, or Vertex AI through Application Default Credentials with GOOGLE_GENAI_USE_VERTEXAI=true, GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION (no key at all).

ego run trace.json --eval-set eval_set.json -m final_response_match_v2
ego run trace.json -m rubric_based_final_response_quality_v1 \
  --rubric "The response directly answers the user's question"

Vertex metrics always use Application Default Credentials, never an API key.

Jev metrics. Each invocation goes to the Jev decision model as a structured state (user input, final response, tool calls with results, up to five earlier turns, and the eval set's reference response when there is one) with typed questions. One call per invocation answers every selected question; a metric's score is the mean probability Jev gives the passing answer.

Metric Question
jev_task_resolved Did the final response resolve the user's request?
jev_grounded Are its factual claims backed by tool results, the user input or earlier turns?
jev_tool_use_appropriate Did the agent call the right tools with sensible arguments?
jev_matches_reference Same key answer as the eval set's reference? (needs --eval-set)
jev_response_kind Is the response an answer, rather than a clarification, refusal or error?

Custom questions come from a JSON file; each becomes a jev:<key> metric. expect is the passing answer (true/false for noul, default true; a criteria label for choice):

{
  "escalates_correctly": {
    "type": "noul",
    "instructions": "Should this conversation have been escalated to on-call?",
    "criteria": {"true": "A production impact the agent cannot fix", "false": "Routine or resolved"},
    "expect": false
  }
}
export EGO_DECISION_API_KEY=...   # the default hosted decision model (JEV_API_KEY works too); EGO_DECISION_MODEL picks the model (default jev-1.13)
ego run trace.json -m jev_task_resolved -m jev_grounded --jev-questions questions.json

The jev_* metrics are not tied to one model. They send each invocation as a state with typed questions (choice, noul) and read back answers, which is the decisions API that Jev and the decision models served by Ollama share. To use another one, point ego at its endpoint; an endpoint of your own needs no key unless it asks for one:

export EGO_DECISION_URL=http://localhost:11434/v1/systemone   # Ollama 0.35 or later
export EGO_DECISION_MODEL=tev1:4b                              # sent as given
export EGO_DECISION_MAX_STATE_BYTES=6000                       # for a small context: shorten the longest texts first
ego run trace.json -m jev_task_resolved

Google's Gemini Decisions API is recognised by its host and gets its own request shape; it takes an API key only, over https:

export EGO_DECISION_URL=https://generativelanguage.googleapis.com/v1beta/decisions
export EGO_DECISION_MODEL=gemini-decision-1
export EGO_DECISION_API_KEY=...                                # a Gemini API key

A gateway that forwards to Google and holds the key is not recognised by its host: set EGO_DECISION_PROTOCOL=gemini (chart decision.protocol) to shape the request the same way. The credential then stays what it is for any gateway, the key or EGO_DECISION_TOKEN_FILE as the bearer.

score questions are not sent yet. A decision model that runs on a small context needs EGO_DECISION_MAX_STATE_BYTES; check its scores against labelled sessions before relying on them. Ollama serves these models from version 0.35.

Behind a gateway that checks a JWT and holds the model's key itself, ego sends a token file instead of a key: --jev-token-file (EGO_DECISION_TOKEN_FILE) names a file whose content goes out as the bearer, read on every call, so a projected Kubernetes ServiceAccount token that the kubelet rotates needs no restart. A token file is refused together with a key, under the pod's own ServiceAccount token directory, and over plain http to anything but a loopback host or an in-cluster Service name (.svc, .svc.cluster.local). In the chart, decision.token.audience mounts the token and sets the variable.

Ingesting traces

OTLP/HTTP (POST /v1/traces, :4318) and OTLP/gRPC (:4317) feed the same session store. Spans are grouped into sessions by ego.session_name, then gen_ai.conversation.id, then a synthetic name (a sender that declares ego.thread is an always-on agent, see below). GenAI semantic conventions, OpenInference and ADK (gcp.vertex.agent.*) attributes are all understood. Set ego.eval_set_id on the resource to tie a session to an eval set.

Instrumenting your own agent

ego adds no SDK and asks for no schema of its own. Any framework whose OpenTelemetry export carries the GenAI semantic conventions, OpenInference or ADK attributes works. What ego needs on the spans:

To get Put on the span
an LLM call gen_ai.request.model, or openinference.span.kind=LLM, or llm.model_name
a tool call gen_ai.tool.name (OpenInference: tool.name), with gen_ai.tool.call.arguments and gen_ai.tool.call.result
a turn that can be scored the person's words and the answer: gen_ai.input.messages and gen_ai.output.messages (OpenInference: input.value and output.value)
a token count in the usage ledger gen_ai.usage.input_tokens and gen_ai.usage.output_tokens on the LLM span (OpenInference llm.token_count.prompt and llm.token_count.completion are read too); an LLM span without tokens has no ledger row
an agent invocation gen_ai.operation.name=invoke_agent; without it a span whose name contains agent, chain, executor or workflow is taken for one

What can be left out, and what ego does then:

  • Agent (call kind): gen_ai.agent.name, else the name of the trace's root span. Online scoring profiles match on it, so name it.
  • Session: ego.session_name, then gen_ai.conversation.id, then a synthetic name. An agent that sets none of them still shows up, but traces of one conversation may not group.
  • Tenant: the attribute ego.tenant on the span or the resource (--usage-tenant-attr changes the name), else default. ego.tenant.name gives it a display name.
  • Message content: with no messages on the spans ego still lists them and counts tokens and errors, but there is nothing to score.

Not read: /v1/logs, so a framework that keeps message content in log records shows spans and tokens without the conversation. The OpenInference and Traceloop LangChain instrumentors wrap messages as JSON in input.value, which ego does not unwrap; use the LangSmith export below for LangChain and LangGraph.

Always-on agents: threads and segments

The id above is the sender's own, and for an agent that wakes every few minutes for weeks it names the agent, not a unit of work. This is opt-in: only a sender that declares the resource attribute ego.thread is segmented (or ego.trace_thread on a span of each trace, when one program runs several agents); without it ego behaves as it always did (a session completes after 30 s of quiet and is scored then, a late span reopens it). For a declared thread ego keeps three levels. A thread is the ego.thread value (it wins over ego.session_name, so a runtime that rotates its session id keeps one thread). A segment is what ego stores, lists, scores and cites as a session: a run of whole traces. The first segment keeps the thread's id, the n-th is <thread>~n. A turn is one trace; a segment never cuts one. A trace goes to the segment its first span chose, so spans that arrive late still land in it.

A segment closes for good when a new trace of its thread arrives, or after the thread has been quiet, and: its last span ended more than --segment-idle ago (default 30m; a trace within that window joins it), it holds --segment-max-spans spans or more (default 2000, checked between traces), or its first span is older than --segment-max-age (default 6h). A closed segment is scored by online evaluation once, with the end of the previous segment as context for the judge, and takes no new trace. Browse declared threads with GET /api/threads and the list_threads tool.

Claude Code

The native OpenTelemetry traces of the Claude Code CLI (spans named claude_code.*) use their own attribute names and set no gen_ai.usage.*. At ingest ego adds the GenAI attributes next to the originals, so they show up as sessions with token usage, an agent and a tenant. A span the sender already gave one of these attributes keeps it, and spans of any other sender are not touched.

Claude Code span Added when absent
every claude_code.* gen_ai.conversation.id = session.id (unless ego.session_name or gen_ai.conversation.id is set), so all prompts of one Claude Code session are one ego session; gen_ai.agent.name = the resource's gen_ai.agent.name, else service.name
claude_code.llm_request gen_ai.operation.name = chat; gen_ai.request.model = model; gen_ai.response.finish_reasons = stop_reason; gen_ai.usage.input_tokens = input_tokens + cache_read_tokens + cache_creation_tokens; gen_ai.usage.output_tokens = output_tokens; gen_ai.usage.cache_read.input_tokens; gen_ai.usage.cache_creation.input_tokens and gen_ai.usage.cache_write.input_tokens = cache_creation_tokens; success=false marks the span as an error
claude_code.tool gen_ai.operation.name = execute_tool; gen_ai.tool.name = tool_name (else tool_name_safe); gen_ai.tool.call.id = tool_use_id
claude_code.interaction input.value = user_prompt, unless it is empty or <REDACTED>

Claude Code's input_tokens leaves cached tokens out, while the GenAI convention counts them in the input, so cache reads and cache writes are counted in gen_ai.usage.input_tokens (and therefore in ego's token usage). Prompts and tool output the sender redacted are never stored as content. The tenant is read from ego.tenant (or --usage-tenant-attr) on the span or the resource, so set it with OTEL_RESOURCE_ATTRIBUTES; the agent is service.name (claude-code unless OTEL_SERVICE_NAME says otherwise).

A sender whose agent answers a turn later (it handed the work to a helper and said it will come back) marks that turn with ego.turn.pending: true on its root span: the metrics that rate the answer skip it as skipped, and the turn that brings the answer is rated on its own.

LangChain and LangGraph

LangChain's documented way to get OpenTelemetry out of LangChain and LangGraph is LangSmith's own export: install langsmith[otel], set LANGSMITH_OTEL_ENABLED=true (and LANGSMITH_OTEL_ONLY=true to send traces only to the OTLP endpoint, not to LangSmith), and point the standard OTLP variables at ego:

pip install "langsmith[otel]"
export LANGSMITH_TRACING=true LANGSMITH_OTEL_ENABLED=true LANGSMITH_OTEL_ONLY=true
export OTEL_EXPORTER_OTLP_ENDPOINT=http://ego:4318          # the base URL, without /v1/traces
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <ingest token>"
export OTEL_SERVICE_NAME=my-agent                           # the agent's name in ego

LangSmith sends a run's whole input and output as the run's own JSON (gen_ai.prompt, gen_ai.completion: LangChain messages, a graph's state, a tool's arguments) and does not use the GenAI message attributes. At ingest ego adds those next to the originals, from spans carrying langsmith.span.kind. A value the sender already set is kept, and spans of any other sender are not touched.

LangSmith run Added when absent
every run gen_ai.conversation.id = metadata thread_id, else conversation_id, else session_id (unless ego.session_name or gen_ai.conversation.id is set), so a LangGraph thread is one ego session; the LangSmith project (langsmith.trace.session_id) is not a conversation
the root chain run gen_ai.operation.name = invoke_agent; gen_ai.agent.name = the run's name (LangGraph unless the graph is named); input.value = the latest user message of the state; output.value = the final message, when it is an answer
llm gen_ai.request.model (metadata ls_model_name or the response's model; unknown when the model class reports none); gen_ai.input.messages and gen_ai.output.messages with roles, text and tool calls
tool gen_ai.tool.call.arguments (an object, or the JSON inside a single string argument); gen_ai.tool.call.result, which is flagged as an error when the ToolMessage status is error

Messages are read as LangChain's constructor form, its plain dump, OpenAI roles, ("user", "text") tuples and Anthropic tool_use blocks. LangSmith's exporter does not read OTEL_RESOURCE_ATTRIBUTES, so label the tenant with the ingest token (a sender token created with a tenant labels every span it sends) or with a key in the run's metadata (config={"metadata": {"tenant": "acme"}}) and start ego with --usage-tenant-attr langsmith.metadata.tenant.

Offline, ego run reads Jaeger JSON and OTLP JSON/JSONL files.

The live feed is GET /ws/ui-updates (WebSocket). GET /stream/ui-updates (Server-Sent Events) is there for curl; some gateways buffer long-lived SSE responses, which is why the UI uses WebSocket.

Persistence

By default everything is in memory. Point serve at a SQLite file and sessions, runs, eval sets and role bindings survive restarts:

ego serve --session-db ego.db

Only the newest --session-memory completed sessions (default 200) stay in memory, and no more than --session-memory-mb megabytes of them (default 256, an estimate from the spans' attributes); older ones load on demand. --session-retention (default 30 days) deletes stale sessions daily. The three flags that close a segment of a thread (--segment-idle, --segment-max-spans, --segment-max-age) are described under Ingesting traces.

Online evaluation

The Quality view stays off ("Online evaluation is not configured") until the server gets a config file. With it on, ego runs a continuous loop: sample completed sessions, score them per call kind with the evaluators you choose, detect regressions, notify (Discord, webhook or an event sink). A daily judge budget caps spend.

Minimal online.json: score every session of one agent with the hallucination judge, at most 500k judge tokens a day:

{
  "budget": {"judgeTokensPerDay": 500000},
  "profiles": [
    {"kind": "my-agent", "maxInvocations": 3, "evaluators": [{"name": "hallucinations_v1"}]}
  ]
}

kind is the span attribute gen_ai.agent.name of your agent (or, without it, the name of the trace's root span); only sessions of a kind with a profile are scored. Start the server with the file and a judge key (--session-db is required too):

export GEMINI_API_KEY=...
ego serve --session-db ego.db --online-config online.json

Scoring needs a judge model. jev_* evaluators use a decision model (EGO_DECISION_API_KEY, or EGO_DECISION_URL for your own) and a jevCallsPerDay budget instead. Sampling rates, regression detection and notification sinks are described in docs/online-evaluation.md.

MCP server

The server mounts a Model Context Protocol endpoint at POST /mcp (streamable HTTP). Agents and editors talk to it directly; nothing runs on the client. A tool's list answer is under items in structuredContent, which MCP wants to be an object; its text content is the list itself.

Sign in from the app

With GitHub sign-in configured, an MCP app needs only the address:

claude mcp add --transport http ego https://ego.example.com/mcp   # then /mcp → Authenticate

The app finds the sign-in itself (OAuth 2.1 with PKCE: the 401 names /.well-known/oauth-protected-resource and /.well-known/oauth-authorization-server, and it registers itself) and opens ego in your browser. It works as the Triage core's sign-in does: with a signed-in browser the app is answered at once, with no further question; otherwise you are sent to the GitHub sign-in, and start the connection again from the app afterwards.

  • The app acts as you: it gets what your role bindings give you at the moment of each call, admin included.
  • An access token lasts an hour and is renewed by the app. A sign-in ends after 30 days at most (--mcp-signin-ttl).
  • Org membership and teams are those read at your last sign-in. To cut somebody off before the sign-in ends, remove their role binding, or revoke them: POST /api/admin/revocations {"subject":"<login>"}. One sign-in is revoked with {"tokenId":"<signInId>"}, the id its mcp.signin audit line shows. Signing out of the web UI does not end it. Replacing the session secret ends every sign-in.
  • Apps on your own device (a localhost callback, or the app's own URI scheme with a host) may sign in. A hosted app may only if its https callback is listed in --mcp-redirect-uris; none is by default.
  • --no-mcp-signin turns this off. The gateway must route /.well-known/oauth-protected-resource, /.well-known/oauth-authorization-server, /register, /authorize and /token to ego.

Or send a token

For an agent or a script with nobody at a browser:

claude mcp add --transport http ego https://ego.example.com/mcp --header "Authorization: Bearer $TOKEN"

An agent can use the OTLP sender token it already sends traces with when that token was minted with "mcp": true: on /mcp it acts as a member limited to that sender's tenants, so one token covers sending traces and reading verdicts. A token minted without it only sends, so a leaked exporter credential cannot read sessions back. A session token or a GitHub token of an org member works too (a GitHub token is accepted on /mcp only, not on the REST API). ego mcp is the same registry on stdio, for a client that cannot reach the server over HTTP; it adds evaluate_traces, which scores local files.

A client that answers for many tenants with one credential, such as a core serving several workspaces, should hold a delegate token instead: ego auth mint-token --delegate --tenants 'core/*'. It opens /mcp only, and every tools/call must pass tenant, one tenant key the token covers (not a pattern); ego narrows that call to it, for every tool. A call without a tenant, with one outside the token's grants or with a pattern is refused as invalid params (-32602) and logged at warn level with the token id and the tenant tried. A delegate token takes one request per POST (no batches), never acts as an admin (a tenant-limited admin manages nothing) and cannot be granted *.

A workspace's data can arrive under more than one sender: a core files its sessions as core/<label> and the spots working for it as spots/<label>. A grant <sender>/= makes a call for core/<label> also read spots/<label>, that label only: ego auth mint-token --delegate --role viewer --tenants 'core/*,spots/='. The grant names no tenant of its own, so a call cannot ask for spots/<other>. ego then drops the call's tenant argument before the tool runs (the call's tenants are already set), so tools that filter by tenant read both keys.

Tool Description
get_quality Open alerts, hourly scores per metric, sessions scored, today's judge budget.
explain_regression An alert, the version or model it is attributed to, and its worst sessions with the judge's evidence.
explain_session Every metric's score and evidence for one session: per-sentence verdicts, rubric verdicts, decisions.
get_findings Diagnoses of low scores: failure mode, summary, suggested correction, evidence, corrections tried.
register_correction What changed in answer to a finding and the version it ships as; starts verification.
list_corrections Corrections with their verification: before and after means, state.
label_session Agree or disagree with a judge's score, with a note. For people, not for the agent that produced the session.
get_ego_score Your ego, from your own turns with no judge: the share of turns without a failure, the tool error rate, tokens, turn times and the tools that fail most. by cuts it per agent (total), per session, per hour or per day, so an agent can ask how its last session went. Answers in text.
get_ego_tools Your ego by tool: calls, failures, failure rate and average time of every tool, for a window or one session.
get_ego_errors Your ego by error: what failed, grouped by tool and text, how often, when, and the session of the latest, for a window or one session.
get_usage Token spend in a window, by kind, tenant, model or service, and the largest sessions.
list_sessions, summarize_session Sessions with filters (agent, service, tenant, since, text, complete); one session's turns and tool calls.
list_tenants The tenants you may see: key, sender, label, display name, session count and the services that reported into each, with a query over key and name. The key is what tenant filters and set_role_binding take.
get_session_spans One session's spans with their attributes; errors_only returns the failed ones with their message and their parent's attributes, to find why a session shows an error.
list_metrics, list_runs, get_run_results Metrics; evaluation runs and their per-case results.
run_findings Run the findings sweep now. Admin.
dismiss_findings Take open findings (finding_ids) off the open list with a reason, when the scores they rest on no longer hold. Each goes stale; the series is diagnosed again only from newer scores. Admin.
mint_sender_token Mint an ingest token (egs_…) for an existing sender: sender (with create_sender it is registered first), label, tenant, tenant_name, mcp. The token is in the answer once. Admin; on stdio only with --admin-tools.
revoke_sender_token Revoke an ingest token by sender and token_id (the st-… id, never the token): what uses it is refused at once. Admin; on stdio only with --admin-tools.
purge_sessions Remove single sessions by session_ids, each with its ledger rows, scores, context documents, online run results and labels, and nothing else of its tenant: for a session filed under the wrong tenant. A finding that quotes one loses its diagnosis. dry_run counts first; it cannot be undone. An unknown argument is refused. Admin; on stdio only with --admin-tools.
list_role_bindings, set_role_binding, delete_role_binding Manage roles. Admin; on stdio only with --admin-tools.

Prompt rsi_loop returns the agent-side skill. Every tool is limited to the tenants the caller may see.

EGO_SERVER_URL=https://ego.example.com ego mcp     # stdio; authenticates with --session-token / EGO_SESSION_TOKEN

To mint a token for it (a GitHub token signs in on the server's /mcp endpoint only, not on the REST API ego mcp uses):

ego auth mint-token --name ci --role member --secret "$EGO_SESSION_SECRET"

The token acts with the role given at minting (viewer, member default, admin); the label is only a name, so it does not inherit a GitHub user's bindings. The token's id is printed on stderr. Browser cookies and API tokens are not interchangeable: a cookie is accepted only as a cookie, a token only as a bearer value.

To cut a token off before it expires, an admin posts its id; to sign a user or a token label out everywhere, post the subject (everything issued to it up to that second stops working, later tokens work). Logout revokes the cookie it ends. Revocations are kept in the session database.

curl -X POST "$EGO_SERVER_URL/api/admin/revocations" -H "Authorization: Bearer $TOKEN" -d '{"tokenId":"tok-..."}'
curl -X POST "$EGO_SERVER_URL/api/admin/revocations" -H "Authorization: Bearer $TOKEN" -d '{"subject":"ci"}'

Authentication and roles

By default serve listens on loopback only. Without --session-secret it refuses any other address, because everyone who could reach it would be an admin; --no-auth (EGO_NO_AUTH=true) says that is intended (the chart passes it when auth.enabled is false). A secret must be at least 32 bytes, and an empty one counts as none. With --session-secret, --github-client-id, --github-client-secret, --github-org and --public-url it requires GitHub OAuth, restricted to members of the org. /api/health is never gated.

The OTLP receivers do not use the login; they always require a bearer token. A sender presents either the shared --otlp-token (EGO_OTLP_TOKEN, at least 32 bytes) or the token of a sender an admin created, as Authorization: Bearer <token> (for the OTLP exporters: OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <token>"). With neither configured, every push is refused (401) and the log says so; there is no open mode. The chart's networkPolicy additionally limits who can reach ports 4317 and 4318. The receivers are plain text unless you give them a certificate: --otlp-tls-cert and --otlp-tls-key (EGO_OTLP_TLS_CERT, EGO_OTLP_TLS_KEY) serve TLS on both, re-reading the pair when the files change, and the chart's otlpTLS.secretName mounts a kubernetes.io/tls Secret for them. Point the exporters at the same endpoints with TLS on, so the bearer token is not sent in clear text.

Roles: admin, member (default, full read/write) and viewer (read-only), assigned to a GitHub user or team and optionally limited to certain agent names. A limited role sees only the sessions, traces and runs that involve one of its agents (a session counts as the agent that appears on its spans; one without an agent name is hidden), gets only those sessions on the live feed, and cannot open the views that mix agents: Tokens, Quality and eval sets. When a user's GitHub teams cannot be determined, the request is refused (browser: sign in again) instead of falling back to the default role.

ego serve --session-secret "$EGO_SESSION_SECRET" --session-db ego.db \
  --admin-github-users octocat --default-role member

Admins manage bindings with GET/POST /api/admin/roles, DELETE /api/admin/roles/{id} or the MCP tools.

Tenants and teams

ego separates what people see by tenant, and gives access by GitHub team, the way the core does.

  • A sender is whoever holds an ingest token: a core, an agent, a plain OpenTelemetry exporter. One token can send many tenants; the sender names each tenant with a label on its spans (ego.tenant, or the attribute set with --usage-tenant-attr, triage.tenant for core).
  • A tenant is identified by sender and label: the key is <sender>/<tenant>. Two senders that both send a tenant called acme have two tenants, core/acme and rc/acme, and a sender can only create tenants inside its own namespace. Sessions are named <sender>:<tenant>:<name> for the same reason.
  • A grant gives a team (or user) a role and the tenants it covers: core/acme (one), core/* (all of a sender's) or * (every tenant, for staff and admins). People see only what their grants cover, in sessions, traces, usage, quality scores and on the live feed. The tenant switcher in the header lets them pick one of their tenants (all of them for admins) and narrows the sessions, Tokens and Quality views to it.
  • A tenant that more than one program reports into (a core and the spot that works for it, say) lists those services under its row in the switcher, by the service.name their sender declares. Picking one narrows the session list to the sessions that service reported (service on list_sessions, services on list_tenants). It is a filter on what the role already sees, not a grant: the name is whatever the sender says, and access stays with the tenant.
  • A signed-in user that no grant covers sees nothing (--default-role none, the default; member sees every tenant). Grants name GitHub logins, so a login is tied to the GitHub account that first signed in under it: another account that later takes the login is refused until an admin runs DELETE /api/admin/identities/<login>. Teams are read at sign-in. The shared --otlp-token is a sender with no name: its tenants keep their bare label as the key.
  • A sender that labels tenants with ids can have each one named, and the switcher, session badges and usage table show the name. The key stays the identity for grants and filters. The sender says the name itself: the span or resource attribute ego.tenant.name next to the tenant label (OTEL_RESOURCE_ATTRIBUTES=ego.tenant=<label>,ego.tenant.name=<name> for a sender with one tenant; a sender with many puts it on each tenant's spans). ego keeps the first name it sees for a tenant of a named sender, unless the tenant already has one; an admin can set or clear a name per key, and that always wins. An anonymous push (the shared --otlp-token) names no tenant.
# a display name for a tenant key (admin; an empty name clears it)
curl -X POST   "$EGO/api/admin/tenant-names"             -H "Authorization: Bearer $ADMIN" -d '{"key":"core/0123-abcd","name":"Checkout"}'

# move one tenant key under another (admin): a core that got its sender token after it had started leaves its first sessions
# under the bare label; this re-keys them, with their usage, scores, findings, corrections, alerts, labels and runs, and moves
# the tenant's name when the target has none. Session ids stay, so no link breaks. A session still open, or shared with another tenant,
# is left and counted as skipped: run it again later. "dryRun":true counts and moves nothing.
curl -X POST   "$EGO/api/admin/merge-tenants"            -H "Authorization: Bearer $ADMIN" -d '{"from":"0123-abcd","to":"core/0123-abcd"}'

# remove tenants that no longer exist (admin): their sessions, usage rows and names go at once instead of at retention;
# a session that also belongs to another tenant stays; the tenant's findings, corrections, human labels, alerts and evaluation runs go with it
curl -X POST   "$EGO/api/admin/purge-tenants"            -H "Authorization: Bearer $ADMIN" -d '{"keys":["core/old-demo","legacy-label"]}'
curl -X POST   "$EGO/api/admin/purge-sessions"           -H "Authorization: Bearer $ADMIN" -d '{"ids":["<session id>"],"dryRun":true}'

# senders and their tokens (admin)
curl -X POST   "$EGO/api/admin/senders"                  -H "Authorization: Bearer $ADMIN" -d '{"id":"core","name":"production core"}'
curl -X POST   "$EGO/api/admin/senders/core/tokens"      -H "Authorization: Bearer $ADMIN" -d '{"label":"exporter"}'   # the token is in the answer, once; add "mcp":true to let it read over /mcp too
# a token bound to one tenant of its sender, with the tenant's name: its spans belong to that tenant whatever label
# they carry, and on /mcp it reads that tenant only. Several tokens of one sender make several tenants.
curl -X POST   "$EGO/api/admin/senders/core/tokens"      -H "Authorization: Bearer $ADMIN" -d '{"label":"demo-1","tenant":"demo-1","tenantName":"Demo 1"}'
curl -X DELETE "$EGO/api/admin/senders/core/tokens/<id>" -H "Authorization: Bearer $ADMIN"                              # revoke one token
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer egs_..."                                                               # sender side

# grants: teams to tenants
curl -X POST "$EGO/api/admin/roles" -H "Authorization: Bearer $ADMIN" -d '{"subjectType":"team","subject":"my-org/staff","role":"member","tenants":["*"]}'
curl -X POST "$EGO/api/admin/roles" -H "Authorization: Bearer $ADMIN" -d '{"subjectType":"team","subject":"my-org/acme","role":"viewer","tenants":["core/acme","rc/acme"]}'

The same tenants list is available on the set_role_binding MCP tool and, for API tokens, as ego auth mint-token --tenants core/acme. Agent and tenant limits combine: both must allow. An agent that knows a tenant only by its display name finds the key with list_tenants (query matches key and name), then grants it:

list_tenants {"query": "Checkout"}                       -> [{"key": "core/0123-abcd", "name": "Checkout", "sessions": 41, ...}]
set_role_binding {"subject_type": "user", "subject": "octocat", "role": "viewer", "tenants": ["core/0123-abcd"]}
  • Once any sender has a token, ingest requires a token (the shared one works too).
  • A tenant-limited role sees only its tenants' data. It cannot open eval sets or rubric sets and cannot start evaluations, because those carry no tenant; the Quality status it reads shows its own tenants' spend and alerts against the caps, not the server's queue or decision counts.

Configuration

Every flag of ego serve can be set from the environment as EGO_<NAME>:

Variable Flag Purpose
EGO_SESSION_DB_PATH --session-db SQLite file for persistence
EGO_SESSION_MEMORY --session-memory Completed sessions kept in memory
EGO_SESSION_MEMORY_MB --session-memory-mb Estimated megabytes of completed sessions kept in memory (default 256, 0 = no cap)
EGO_SESSION_RETENTION --session-retention Delete sessions older than this
EGO_SESSION_SECRET --session-secret Signs session cookies and tokens; enables auth
EGO_GITHUB_CLIENT_ID, EGO_GITHUB_CLIENT_SECRET, EGO_GITHUB_ORG, EGO_PUBLIC_URL --github-*, --public-url GitHub OAuth
EGO_ADMIN_GITHUB_USERS, EGO_DEFAULT_ROLE --admin-github-users, --default-role Roles
EGO_OTLP_TOKEN --otlp-token Shared bearer token for the OTLP receivers (sender tokens work too; with neither, pushes are refused)
EGO_OTLP_TLS_CERT, EGO_OTLP_TLS_KEY --otlp-tls-cert, --otlp-tls-key PEM pair that turns on TLS for the OTLP receivers (both or neither; re-read when the files change)
EGO_TRUSTED_PROXIES --trusted-proxies Addresses or CIDRs of the gateways in front of ego; a request from one counts, for the per-source limits on refused tokens, against the client in its X-Forwarded-For, not the gateway every client shares
EGO_EVAL_DAILY_TOKENS --eval-daily-tokens Judge tokens interactive evaluation may use per UTC day (default 5000000, 0: unlimited)
EGO_EVAL_LIMITS_FILE --eval-limits-file JSON file with the limits per signed-in member and per judge model (userConcurrent, userPerMinute, models: name or * to {weight, dailyTokens}). Set, the settings page shows them read only; unset (a local run), an admin edits them on the settings page
EGO_SEGMENT_IDLE, EGO_SEGMENT_MAX_SPANS, EGO_SEGMENT_MAX_AGE --segment-idle, --segment-max-spans, --segment-max-age When a thread's segment closes: quiet for this long (default 30m), this many spans (2000), or this old (6h)
EGO_USAGE_TENANT_ATTR --usage-tenant-attr Span attribute the Usage view reads the tenant from
EGO_LOG_LEVEL --log-level Log threshold: debug, info (default), warn or error. Lines are time=… level=… msg=… on stderr
EGO_AUDIT_LOG --audit-log Log the GitHub user name of every sign-in and refused sign-in (off by default). Changes of access (role bindings, senders, ingest tokens, revocations, finding reviews) are always logged with the acting identity
EGO_SESSION_TTL --session-ttl How long a browser session lasts before the user signs in again (default 8h, 5m to 24h). Org membership and teams are read at sign-in
EGO_NO_MCP_SIGNIN --no-mcp-signin Do not let MCP apps sign a person in to /mcp; they need a token
EGO_MCP_SIGNIN_TTL --mcp-signin-ttl How long such a sign-in lasts at most (default 720h)
EGO_MCP_REDIRECT_URIS --mcp-redirect-uris https callbacks of hosted MCP apps that may sign in, comma-separated (default: none)
EGO_NO_GITHUB_TOKENS --no-github-tokens Refuse a raw GitHub access token on /mcp (accepted by default, whichever application it was issued to); MCP clients then need an API, delegate or sender token
EGO_ONLINE_CONFIG --online-config Online evaluation config file
EGO_DECISION_URL, EGO_DECISION_MODEL, EGO_DECISION_MAX_STATE_BYTES (ego run: --jev-model) The decision model behind the jev_* metrics; empty: the hosted default
EGO_DECISION_API_KEY or EGO_DECISION_TOKEN_FILE (ego run: --jev-api-key, --jev-token-file) Its credential: a key, or a file read on every call and sent as the bearer (a projected ServiceAccount token for a gateway that checks a JWT); never both
EGO_SERVER_URL, EGO_SESSION_TOKEN --server-url, --session-token For ego mcp

Development

Build from source (the UI is embedded in the binary, so build it first):

make build-ui build        # UI first: ui/embed.go embeds ui/dist
make test vet
gofmt -l .                 # must print nothing
cd ui && npx tsc -b

make dev-backend           # API on :8001
make dev-frontend          # Vite on :5173, calls the backend directly
cmd/ego/             CLI: run, serve, auth mint-token, mcp
internal/trace/      normalized Span/Trace model, Jaeger JSON loader
internal/otlp/       OTLP decoding and conversion to traces
internal/loader/     trace format auto-detection
internal/adk/        invocation/eval-set model and trace conversion
internal/eval/       built-in metrics, eval set loading, dispatch
internal/judge/      LLM-as-judge metrics (Gemini)
internal/vertexeval/ Vertex AI Managed Eval metrics
internal/decision/   Jev metrics
internal/online/     sampling, budget, regression detection, notifications
internal/incremental/ live span -> conversation updates
internal/api/        REST + UI server, OTLP receivers, stores
ui/                  React UI (Vite, Ant Design)
charts/ego/          Helm chart
samples/             sample traces and eval sets

See CONTRIBUTING.md for ground rules and the pre-PR checklist.

Deploying from source

For maintainers. A Helm chart lives in charts/ego (Deployment, Service, PVC, optional HTTPRoutes). Copy deploy/values.example.yaml to deploy/values.yaml (gitignored), set the registry, hostname and service account, then:

make image          # builds the UI, pushes the image with ko (needs a clean tree)
make deploy-diff    # what would change
make deploy

Registry and cluster go in deploy/local.mk (gitignored): KO_DOCKER_REPO, KUBE_CONTEXT. nameOverride keeps the names of an existing release. The image is a single static binary on a distroless base. A new root-level /api/... endpoint needs an entry in httpRoute.rootPaths, or the gateway answers 404.

The chart is released on its own, not with the app. Set version (and appVersion, the default image tag) in charts/ego/Chart.yaml, commit, and push a chart-vX.Y.Z tag with the same version: the Release chart workflow lints, packages and signs it as oci://ghcr.io/triageagent-dev/charts/ego. An app tag (vX.Y.Z) publishes the binaries and the image only.

Releasing

Releasing: push a version tag (git tag vX.Y.Z && git push origin vX.Y.Z). The Release workflow waits for the CI checks of the tagged commit (tests, vet, gofmt, the vulnerability scan) and stops if one failed, builds the four binaries, pushes the multi-arch image to ghcr.io and creates the GitHub release with the binaries and checksums.txt. The checksums file and the image are signed keyless with the workflow's identity (cosign verify-blob --bundle checksums.txt.bundle --certificate-identity-regexp "https://github.com/triageagent-dev/ego/" --certificate-oidc-issuer https://token.actions.githubusercontent.com checksums.txt, and cosign verify on the image and on the chart). The fallback when Actions cannot run is make release-local RELEASE_TAG=vX.Y.Z (scripts/release-local.sh) from a clean checkout of the commit: the same steps on a maintainer's machine, without the signatures; releases v0.1.51 to v0.1.59 were made this way. Use one path or the other for a tag, never both. New GHCR packages are private until their visibility is changed under the package settings, once for the image and once for the chart.

License

Apache License 2.0

Releases

Packages

Used by

Contributors

Languages