Skip to content

Graphrt 0.4.0

Choose a tag to compare

@BimaPangestu28 BimaPangestu28 released this 20 Nov 22:49
· 178 commits to main since this release

Evaluation lands: graphrt eval runs datasets against a workflow with deterministic, trajectory, retrieval and judge assertions, where a judge is an ordinary graphrt workflow. graphrt serve can score sampled production runs online, take human feedback and export scores as OpenTelemetry events, and spans now follow the OpenTelemetry GenAI semantic conventions with presets for Langfuse, LangSmith, Braintrust, Opik, Phoenix and MLflow. Also new: end user JWT verification and per user rate limits for serve. Contains breaking changes, see Changed (Breaking).

Changed (Breaking)

  • OpenTelemetry span names: the run span is invoke_workflow {workflow} (was workflow {workflow}) with gen_ai.operation.name=invoke_workflow, and is kind INTERNAL unless it continues a caller's traceparent (then SERVER, as before)
    • Model nodes are chat {model} (was the node title, now in graphrt.node.title)
    • Agents are invoke_agent {title} with gen_ai.operation.name=invoke_agent (was chat).
  • system-one spans report gen_ai.operation.name=chat (was the non-standard classify, now graphrt.operation.kind=classify).
  • gen_ai.system is deprecated in favor of gen_ai.provider.name. Both are emitted for this release, gen_ai.system will be removed in the next.
  • tool_call / tool_result progress no longer appear as span events on the agent span (they are execute_tool spans). model_request progress never becomes a span event.
  • graphrt-otel API: OtelConfig::capture_content: bool is replaced by OtelConfig::capture: CaptureMode. AttrValue is #[non_exhaustive]. RunRecord and the CLI's ServiceOptions have new public fields (construct them with RunRecord::running / ..Default::default()).

Added

  • Online evaluation: graphrt serve --evaluators <file> (cargo feature online-eval, on by default, not in the IoT build) scores a deterministic sample of finished runs with the assertions of graphrt eval that need no expected answer (judge workflows, regex, contains*, starts-with, is-json, json-schema, latency, tokens, trajectory:*), validated at startup.
    • Evaluators filter on workflow, run status, tags and metadata.
    • Sampling hashes the run id with the evaluator name.
    • Runs are queued after their response to a bounded pool (concurrency, queue)
    • A full queue drops and counts (graphrt.eval.dropped).
    • Without --evaluators nothing runs and runs pay only an empty Option check (serve throughput within noise).
    • Scores, online evaluation, presets and the uploader add about 98 KiB to the default min-size binary and nothing to the IoT build.
    • graphrt_eval::online holds the config, sampling and evaluation.
    • examples/evals/online replays the reference judges offline.
    • See docs/evals.md#online-evaluation.
  • Run scores (cargo feature scores): GET /v1/runs/{id}/scores, and POST /v1/runs/{id}/feedback for human feedback {name, value, comment?, user?} (number, boolean or text values).
    • Scores are stored next to the run (runs/<id>/scores.json, or in memory, bounded by --max-runs and the TTL) with deterministic ids, so a repeated score replaces the earlier one.
    • With --verify-jwt, an end user's token may give feedback on the user's own runs only, as that user.
  • evaluate {name} spans: every score (online, human, and each assertion of graphrt eval) becomes a span in the evaluated run's trace, under its root span, with a gen_ai.evaluation.result event (gen_ai.evaluation.name, .score.value, .score.label, .explanation), plus a graphrt.eval.score histogram by evaluator.
    • Names live in graphrt_otel::semconv.
  • Vendor presets: --otel-preset <name> (or GRAPHRT_OTEL_PRESET) for langfuse, langsmith, braintrust, opik, phoenix and mlflow fills the traces endpoint, auth and routing headers (Langfuse Basic auth and x-langfuse-ingestion-version: 4, x-bt-parent, x-mlflow-experiment-id...) and resource attributes (opik.project_name, openinference.project.name) from each vendor's own environment variables, and turns the metrics push off.
    • Small static tables in graphrt_otel::preset.
  • graphrt serve --langfuse-scores (cargo feature langfuse) uploads online and human scores to Langfuse's /api/public/scores with the run's trace and root observation ids and the score's deterministic id, through the egress policy, with retries.
  • graphrt eval --otel exports one trace per test run with langfuse.experiment.* attributes (a Langfuse experiment over OTLP, with the Braintrust preset and BRAINTRUST_PARENT=experiment_id:<id>, a Braintrust experiment) and an evaluate span per assertion. It used to ignore --otel.
  • graphrt-otel: EventTracer::with_span_attributes, with_root_attributes and with_root_span_id. TraceId::from_hex / SpanId::from_hex. OtelConfig::export_metrics and preset. graphrt-eval: EngineTarget::engine and env.
  • graphrt serve --verify-jwt INPUT (cargo feature jwt, on by default) verifies the token of a header-mapped input as a JWT: ES256 / RS256 keys from a JWKS (--jwt-jwks-url, refreshed in the background and on unknown kid) and/or an HS256 secret (--jwt-secret-env), with exp, nbf, --jwt-issuer and --jwt-audience checks and a required sub.
    • A valid token may start runs (POST /v1/workflows/{name}/runs only, of workflows that declare the input, others are 403) without the API key and sets sys.user_id.
    • An invalid one is 401.
    • --user-rate-limit N allows N runs per minute per sub (429 with Retry-After).
    • The server refuses --verify-jwt on a non-loopback address without an API key.
    • No new crates.
    • About 33 KiB of binary.
  • examples/supabase-chatbot: a multi-user chatbot backend for apps signed in with Supabase Auth: agent with the supabase plugin in user_rpc mode and tool_context, memory from sys.history, a sample schema with RLS and an isolation test, a distroless container and Fly.io / Cloud Run / VPS notes.
  • graphrt serve --input-header INPUT=HEADER maps a request header (leading Bearer stripped) to a secret start input of new, streamed and resumed runs, so an app can send a user's JWT next to the serve API key.
    • The value is masked everywhere and never stored.
    • Resumes must send the header again.
    • A missing header for a required input is 401, the same input in the body 400, and a non-secret declaration fails at startup.
  • agent_thought progress events carry streamed (whether the turn's text was streamed).
  • docs/serving.md documents the SSE format, the response event and how retry / on_error policies hold back live answer text.
  • agent node tool_context: per-run values (e.g. the end user's JWT) sent to one provider's tools beside the arguments, as a new context field of the plugin protocol's tool.call ({"secrets": {name: string}}).
    • Only plugins with permissions.secrets that the operator trusts receive it.
    • Other providers fail the node with tool_context_denied.
    • The values are never shown to the model or recorded, and are masked in tool results, logged arguments and node errors.
    • Hosts announce the tool_context feature in initialize.
  • Plugin SDKs pass the context as the tool handler's second argument (TypeScript (args, context), Python (args, context) for two-parameter handlers, Rust ToolCall::context). Existing handlers keep working.
  • NodeContext::observe_secret lets a node register plaintext it handles as a run secret, so later node error messages are scrubbed.
  • OpenTelemetry: agent tool calls are execute_tool {tool} child spans (gen_ai.tool.name, gen_ai.tool.call.id, error status for failed or denied calls). knowledge-retrieval nodes are retrieval spans with gen_ai.retrieval.top_k. gen_ai.provider.name, gen_ai.agent.name and gen_ai.response.finish_reasons.
  • OpenTelemetry content capture follows OTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENT (NO_CONTENT default, SPAN_ONLY, EVENT_ONLY, SPAN_AND_EVENT).
    • With it on, the run span carries the run input and output (graphrt.run.input / output and langfuse.observation.input / output), model spans gen_ai.system_instructions and gen_ai.input.messages / gen_ai.output.messages as structured values, tool spans their arguments and result, retrieval spans the query and document ids.
    • Values stay masked and capped at 4 KB.
  • graphrt_core::node::CaptureContent service: when registered (the CLI does so while content capture is on), llm nodes report their rendered messages as model_request progress, agents add result text to tool_result progress and knowledge-retrieval adds its query to the node metadata. Nothing extra is built without it.
  • POST /v1/workflows/{name}/runs accepts metadata, session_id, user_id and tags.
    • They are stored on the run record and stamped on every span (session.id, user.id, gen_ai.conversation.id, langfuse.session.id, langfuse.user.id, langfuse.trace.tags, langfuse.trace.metadata.*).
    • graphrt run gets --session-id, --user-id, --tag and --metadata.
  • RunRecord gains trace_id and span_id (root span of the latest traced execution), metadata, session_id, user_id, tags, and inputs, kept (secrets masked) only with the new graphrt serve --store-inputs.
  • graphrt-otel: semconv module with every attribute name, CaptureMode, RunContext, EventTracer::{capture, with_context, content_limit, root_span_id}, Span::is_run_root, AttrValue::Structured.
  • docs/observability.md: setups for Langfuse v4, Phoenix, Opik, MLflow, LangSmith and Braintrust.
  • graphrt eval <file.eval.yaml>: evaluate a workflow against test cases and gate CI on the pass rate.
    • Eval files use Promptfoo's tests / assert / defaultTest shape plus JSONL datasets.
    • Assertions cover outputs (equals, contains and its variants, regex, starts-with, is-json, json-schema, transform paths), latency and tokens budgets, agent trajectories (trajectory:tool-used, tool-sequence, tool-args-match, step-count, from the run's tool-call events) and retrieval quality (retrieval:recall-at-k, precision-at-k, mrr), each negatable with not- and weighted (weight: 0 reports only).
    • The workflow is compiled once and tests run in-process and concurrently (-j), with --filter, --trials (alias --repeat), per-test --timeout-ms, --output JSON results (report schema_version: 2) and --junit XML.
    • A failed gate exits with the new exit code 5 (--fail-exit-code).
    • Feature eval, on by default.
    • Not in the small-device build.
    • See docs/evals.md.
  • LLM judges as graphrt workflows: {type: judge, workflow: judges/x.yaml} runs the judge on the test's output, vars, expected, retrieved contexts and tool trajectory (plus inputs), and reads verdict: pass|fail|unknown or a 0..1 score with reasoning.
    • unknown: fail (default) or exclude (reported, not scored or gated).
    • Each judge is compiled once and runs inside its test under -j.
    • Its workflow fingerprint, verdict, reasoning and tokens are recorded with the result (summary.judge_usage totals them).
    • --judge-model PROVIDER/NAME overrides the judges' models.
    • --model never does.
  • examples/evals/judges: reference judges for faithfulness, answer relevance, goal success and refusal (binary, single criterion, with an unknown option) and a System One refusal judge. examples/evals/judged runs them offline on a RAG workflow from replay cassettes.
  • --trials N: per test case unbiased pass@k (1 - C(n-c,k)/C(n,k)) and pass^k (C(c,k)/C(n,k)) in cases and summary.trials. gate: {pass_hat_k, k} gates on the mean pass^k.
  • --baseline results.json: compare with an earlier --output file. Metric means and per-test pass rates regress only beyond gate.baseline tolerances (tolerance 0.05, test_tolerance 0, per-metric metrics), improvements and changed judge fingerprints are reported, and any regression fails the gate.
  • Judge calibration: a suite with calibration: evaluates a judge workflow against human labels in expected (new verdict assertion) and reports agreement, TPR, TNR, Cohen's kappa and the confusion matrix, with min_kappa / min_tpr / min_tnr gates (examples/evals/calibration).
  • gate.failures in the JSON results and gate: FAILED (...) on the terminal name every unmet gate condition.
  • graphrt-eval crate: the same harness as a library, for cargo test, with an Assertion trait and registry for custom assertion types, a JudgeLoader for judge assertions, and the stats (pass@k, pass^k, agreement), baseline and calibration modules.
  • kind: replay providers: serve model responses from recorded cassettes (keyed by a hash of the normalized request, streamed delta by delta), record them from an upstream provider (mode: record), or both (mode: auto, a response cache).
    • GRAPHRT_REPLAY_MODE overrides the mode.
    • Works with eval, run and serve (--providers).
    • Feature replay of graphrt-llm and graphrt-cli.
  • schema/eval-v1.schema.json: JSON Schema of eval files.
  • examples/evals: offline suites for the hello and branching workflows, an agent judged on its tool trajectory from committed cassettes, and retrieval metrics over a committed knowledge store.

Changed

  • agent streams the text of every turn token by token, including turns that may still call tools, so the final answer of a tool-using agent no longer arrives as one chunk after the model finished.
    • Tool-call arguments are never streamed as text.
    • Text a turn streams before its tool calls (a preamble such as "Let me check.") is now part of the text output, separated from later text by a blank line, so the streamed text always equals text.
    • stream_tool_turns: false restores the previous behaviour.
  • Breaking (Rust API): ToolRuntime::call takes a third argument, &ToolCallContext (pass ToolCallContext::empty() when there is nothing to send), and ToolRuntime::accepts_secrets (default false) was added. graphrt_plugin_sdk::ToolCall has a new context field.

Fixed

  • Plaintext of secret-typed conversation variables is now scrubbed from node error messages, like other secrets.
  • The OTLP exporter no longer drops a run's root span when its queue is full. Several backends hide or discard every span of a trace without its root.
  • graphrt serve keeps keep-alive connections usable after responses sent before the request body was read (401/403 auth, 429 rate limits, 415, 413): the unread body is drained (up to --max-body-bytes, at most 2 s), or the response says Connection: close.
    • Pooling clients such as Dart's http.Client no longer fail their next request with "Broken pipe".
  • examples/supabase-chatbot/tests: end-to-end security test (real graphrt serve, supabase plugin in user_rpc mode, PostgREST and Postgres, a scripted hostile model) proving user A cannot reach user B's rows and that prompt injection cannot call functions outside the allowlist or reveal the user's JWT.

Install

curl -fsSL https://github.com/Graphrt/graphrt/releases/download/v0.4.0/install.sh | sh
brew install graphrt/graphrt/graphrt
cargo install graphrt-cli
docker pull ghcr.io/bimapangestu28/graphrt:0.4.0

The container image of this release was published at ghcr.io/bimapangestu28/graphrt and stays there. Starting with the next release, images are published at ghcr.io/graphrt/graphrt.

  • Windows (experimental): cross-compiled, not yet run on Windows.

Full changelog: CHANGELOG.md · v0.3.2...v0.4.0