-
Notifications
You must be signed in to change notification settings - Fork 22
feat: enable Relay streaming for Pi #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,7 +142,7 @@ and additive extension maps because their support does not vary by adapter: | |
| | `skills.paths` | Yes | Yes | Yes | Yes | No | InteractiveAgent: Yes; BenchAgent: No | No | Yes | No | | ||
| | `mcp.servers.<name>.transport`, `.url` with `harness_native` exposure | Yes | Yes | Yes | Yes | No | InteractiveAgent: Yes; BenchAgent: No | No | No | No | | ||
| | `mcp.servers.<name>.exposure = "fabric_managed"` | No; not implemented | No; not implemented | No; not implemented | No; not implemented | No | No; not implemented | No | No | No | | ||
| | `telemetry.providers.relay` | Yes | Yes | Yes | Yes | Yes | Yes | No | Yes | Yes, supports collector-backed ATOF streaming | | ||
| | `telemetry.providers.relay` | Yes | Yes | Yes | Yes | Yes | Yes | No | Yes, supports embedded collector-backed ATOF streaming | Yes, supports collector-backed ATOF streaming | | ||
| | `telemetry.providers.native` | No | Yes; OpenTelemetry | Yes; OpenTelemetry and OpenInference | No | No | No | No | No | No | | ||
| | `telemetry.providers.<provider>.config` | Declared-provider pass-through | Declared-provider pass-through | Declared-provider pass-through | Declared-provider pass-through | Declared-provider pass-through | Declared-provider pass-through | No | Declared-provider pass-through | No | | ||
| | `relay.project`, `.output_dir`, `.observability` | Yes | Yes | Yes | Yes | Yes | Yes | No | Yes | Uses the named external collector sink when selected; config is not sent to the remote service | | ||
|
|
@@ -184,7 +184,7 @@ and produces normalized trajectories in Agent Trajectory Interchange Format | |
| | [mini-SWE-agent](python/mini-swe-agent/README.md) | Conversation history | Adapter-owned subclass with NeMo Relay Python SDK scopes | Creates a fresh Relay plugin and request scope, emits step, model, and bash-action telemetry, and collects artifacts | Clears the agent and Relay state | Not implemented | | ||
| | [NOOA](python/nooa/README.md) | InteractiveAgent queue dispatcher or BenchAgent task state | Adapter-owned Relay middleware and generated Relay configuration | InteractiveAgent dispatches queued requests; BenchAgent evaluates one task | Closes agent resources and Relay state | Not implemented | | ||
| | [OpenCode](typescript/opencode/README.md) | Embedded OpenCode host and session | Not supported | Reuses the session and calls `prompt()`, `wait()`, and `context()` for ordered text input | Removes the session and closes the host | Not implemented | | ||
| | [Pi](typescript/pi/README.md) | In-memory Pi `AgentSession` | Runtime-owned Relay 0.9 CLI gateway and explicit Pi extension | Reuses the session, calls `prompt()` for ordered text input, and collects ATOF; `relay_artifacts` does not include local ATIF | Aborts work, emits extension shutdown so local ATIF finalizes on disk, disposes the session, and then stops the gateway | Not implemented | | ||
| | [Pi](typescript/pi/README.md) | In-memory Pi `AgentSession` | Runtime-owned Relay 0.9 CLI gateway and explicit Pi extension | Reuses the session and calls `prompt()` for ordered text input; with `streaming=True`, routes every model turn's ATOF through the embedded collector; `relay_artifacts` does not include local ATIF | Aborts work, emits extension shutdown so local ATIF finalizes on disk, disposes the session, and then stops the gateway | Not implemented | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Format the Configuration Expression as Code. Wrap As per coding guidelines, format expressions and code elements as inline code. 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| | [Remote Agent](python/remote-agent/README.md) | `httpx.AsyncClient` and user/assistant transcript | Remote Relay publishes to a shared ATOF collector | Registers the request ID, maps it into body metadata, sends one HTTP request, and retains the completed transcript | Closes the HTTP client | Implemented over HTTP(S) | | ||
|
|
||
| Telemetry output names use the descriptor contract values. Claude, Codex, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ The adapter supports: | |
| - Slash commands registered by those explicit extensions | ||
| - NeMo Relay 0.9 telemetry through a runtime-owned gateway and an explicitly | ||
| configured Relay Pi extension | ||
| - Live ATOF records from every Pi model turn through the default embedded | ||
| NeMo Fabric collector | ||
| - Ordered plain-text invocations with a `{ "response": "..." }` terminal | ||
| output, Relay runtime details, and collected ATOF artifacts | ||
|
|
||
|
|
@@ -154,8 +156,43 @@ results do not prevent subsequent turns. | |
| Session, turn, and tool telemetry does not depend on model redirection. Model | ||
| telemetry is available only when Relay supports the selected model API and the | ||
| gateway upstream matches the model endpoint. A skipped redirect is recorded as | ||
| a `model_redirect` mark with the reason. Relay-backed | ||
| `Runtime.invoke_stream()` correlation is not yet supported for Pi. | ||
| a `model_redirect` mark with the reason. | ||
|
|
||
| Install the matching collector for the embedded streaming path: | ||
|
|
||
| ```bash | ||
| pip install "nemo-fabric[streaming]" | ||
| ``` | ||
|
|
||
| Start the runtime with streaming enabled to consume live ATOF records from all | ||
| model turns in one Pi invocation: | ||
|
Comment on lines
+167
to
+168
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: rg -n -i 'model_redirect|redirect|ATOF|atof' adapters/typescript/pi sdk/python/nemo-fabric-collector docs/integrations/harness/pi.mdx examples/README.md
sed -n '150,205p' adapters/typescript/pi/README.md
sed -n '170,215p' docs/integrations/harness/pi.mdx
sed -n '35,50p' examples/README.mdRepository: NVIDIA/NeMo-Fabric Length of output: 17038 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- redirect and extension symbols ---'
rg -n -C 8 'model_redirect|redirect|turn_start|agent_settled|stream|ATOF|atof' adapters/typescript/pi/src sdk/python/nemo-fabric-collector/src/nemo_fabric_collector --glob '*.{ts,py,mjs}'
printf '%s\n' '--- pi source outline ---'
ast-grep outline adapters/typescript/pi/src/pi-sdk.ts
printf '%s\n' '--- collector outline ---'
ast-grep outline sdk/python/nemo-fabric-collector/src/nemo_fabric_collector/app.pyRepository: NVIDIA/NeMo-Fabric Length of output: 50374 🏁 Script executed: sed -n '430,530p' adapters/typescript/pi/src/pi-sdk.ts
rg -n -C 12 'model_redirect|redirect' adapters/typescript/pi
sed -n '680,900p' sdk/python/nemo-fabric-collector/src/nemo_fabric_collector/app.pyRepository: NVIDIA/NeMo-Fabric Length of output: 17363 Qualify model-turn ATOF availability. These claims promise ATOF records from every model turn, but Relay can skip a redirect when it does not support the selected model API or the gateway upstream does not match the model endpoint. The collector then receives a Update all three locations to state that ATOF records apply only to model turns successfully redirected to a supported, matching endpoint, and mention the 🤖 Prompt for AI Agents |
||
|
|
||
| ```python | ||
| from nemo_fabric import Fabric | ||
|
|
||
| async with await Fabric().start_runtime(config, streaming=True) as runtime: | ||
| stream = runtime.invoke_stream(input="Review the latest patch") | ||
| async for record in stream: | ||
| print(record) | ||
| result = await stream.result() | ||
| ``` | ||
|
|
||
| The terminal `RunResult` remains separate from the ATOF records. Fully consume | ||
| each stream, or call `await stream.aclose()` if iteration stops early, before | ||
| starting another invocation; the same runtime can then alternate | ||
| `invoke_stream()` and `invoke()` calls. The embedded collector serializes both | ||
| methods behind one Pi invocation lease. Streaming capture begins at the first | ||
| Pi `turn_start` and closes at `agent_settled`. If Relay output is interrupted or | ||
| late, the collector discards the remaining records through that same terminal | ||
| marker before allowing another invocation to start. Use the default embedded | ||
| collector for Pi streaming. The Pi extension does not attach NeMo Fabric | ||
| request IDs, so | ||
| `start_runtime(..., streaming=True, launch_collector=False)` cannot correlate | ||
| its records through an externally managed collector. | ||
|
|
||
| This Relay-backed path runs the adapter's ordinary `invoke` operation. It is | ||
| independent of native OpenAI streaming, so the adapter descriptor's | ||
| `capabilities.streaming` value remains `false`. | ||
|
|
||
| ## Custom Tool Modules | ||
|
|
||
|
|
@@ -204,11 +241,14 @@ path explicitly: | |
| .venv/bin/python -m examples.code_review_agent \ | ||
| --variant pi \ | ||
| --relay \ | ||
| --stream \ | ||
| --pi-relay-extension-path /path/to/NeMo-Relay/crates/cli/assets/pi-extension \ | ||
| --input "Review calculator.py" | ||
| ``` | ||
|
|
||
| MCP is not currently supported. Do not combine the Pi variant with `--stream`. | ||
| The command collects Relay ATOF records from every model turn, then prints one | ||
| JSON document containing `atof_records` and the separate terminal `result`. MCP | ||
| is not currently supported. | ||
|
|
||
| ## Dependency Rationale | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Expand ATOF on First Use.
This is the first use of
ATOFin this document. Spell out Agent Trajectory Observability Format and include(ATOF)here.As per coding guidelines, spell out terms on first use and put the acronym in parentheses.
🤖 Prompt for AI Agents
Source: Coding guidelines