Commit Graph

45 Commits

Author SHA1 Message Date
Teknium 00cd12f7e4 refactor(agent/relay): fold relay_llm attempt scaffolding into _ManagedAttempt; dedupe runtime session/scope paths; drop dead relay_runtime module-level shims 2026-09-02 13:29:48 -07:00
Bryan Bednarski 88300217c2 feat(relay): activate configured dynamic plugins
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-19 08:52:01 -07:00
Bryan Bednarski a2d0ba3d81 docs(relay): clarify timeout payload isolation
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-17 19:24:27 -07:00
Bryan Bednarski 0f5f5a5996 Merge main into fix-relay-client-timeout-payload
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-17 18:55:18 -07:00
Jeffrey Quesnelle e818025b4d Merge pull request #85582 from bbednarski9/codex/fix-relay-lazy-completed-streams
fix(relay): unwrap lazy completed streams
2026-08-17 21:39:52 -04:00
Jeffrey Quesnelle 75bbc055a7 Merge pull request #85579 from bbednarski9/codex/fix-relay-canonical-operation-names
fix(relay): use canonical managed operation names
2026-08-17 21:29:18 -04:00
Alex Fournier 7ee68cca45 test(relay): cover lazy completion with interceptor
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-08-17 10:21:32 -07:00
Alex Fournier 256d7efbfd test(relay): document stream priming boundary
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-08-17 09:39:11 -07:00
rainbowgits aba4934274 fix(agent): omit unsupported metadata on Relay scope.pop
Older nemo-relay bindings reject metadata= on scope.pop, which aborted
turn finalization and left scopes open. Filter kwargs to what the live
binding accepts so close paths can complete.
2026-08-15 00:33:01 -07:00
Alex Fournier 8418ada162 refactor(relay): centralize protocol descriptors
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-08-13 14:42:48 -07:00
Bryan Bednarski 56104af196 fix(relay): unwrap lazy completed streams
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-13 12:26:35 -07:00
Bryan Bednarski fe55b7786e fix(relay): keep client timeout off managed payloads
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-13 12:24:44 -07:00
Bryan Bednarski 377784ac61 fix(relay): use canonical managed operation names
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-13 12:23:36 -07:00
Teknium 961f7481a7 fix(relay): bypass managed execution for nested calls inside managed callbacks
The native Relay pipeline binds its Futures to the event loop that
entered run_in_session_async. While a managed tool callback executes,
that loop is blocked until the callback returns — so a nested managed
relay call made from inside the callback (vision_analyze's auxiliary
LLM call on a worker-thread loop) awaits a Future that can never
complete: 'RuntimeError: Future attached to a different loop', or a
deadlock, plus 'Event loop is closed' at shutdown when the orphaned
future completes late. (#77244)

Fix: managed_callback_guard, a ContextVar depth marker set around every
Hermes callback the relay adapters hand to the native pipeline
(relay_tools.execute invoke, relay_llm execute/execute_async invoke,
ManagedLlmStream run_callback). resolve_execution_context returns the
no-relay triple while the marker is set, so nested calls run unmanaged.
The marker propagates through contextvars.copy_context() into the
worker threads tools use for their internal async work.

Top-level turn LLM calls and tool wraps stay fully managed — verified
live: vision_analyze works under active shared metrics while the main
turn still records managed llm.execute events.

Alternative fixes considered and rejected: removing
retain_managed_execution (kills the shared-metrics managed pipeline)
and gating on main-thread identity (managed tool wraps legitimately
run on the run_agent thread, so that gate disables relay everywhere).
2026-08-08 23:46:17 -07:00
Teknium ceebb21dd7 fix: suppress pydantic serializer warnings leaking to the terminal
The Anthropic SDK's streaming accumulator builds ParsedMessage snapshots
whose ParsedTextBlock content doesn't match the generic union pydantic
expects, so model_dump() on stream events (message_stop) emits
PydanticSerializationUnexpectedValue UserWarnings straight into the
user's CLI output mid-response.

Pass warnings=False at every helper that dumps arbitrary SDK models
(relay_llm/_jsonable, relay_tools/_jsonable, anthropic_adapter
_to_plain_data, run_agent _hook_jsonable, chat_completion_helpers
extra_content/reasoning_details sites, chat_completions transport),
with a TypeError fallback for duck-typed model_dump implementations.

Adds regression tests including a precondition test that proves the
fixture still trips the warning without suppression.
2026-08-08 23:14:30 -07:00
Alex Fournier a97abcd55a Merge upstream main into model metrics
Signed-off-by: Alex Fournier <afournier@nvidia.com>

# Conflicts:
#	tests/agent/test_auxiliary_relay.py
2026-08-02 20:10:47 -07:00
AKAZIK-py fdfddb55cb fix(moa): carry completed responses through the managed Relay path
Under managed Relay execution the provider factory runs lazily inside
provider_stream() on the Relay session's event loop. The MoA facade's
auxiliary call_llm(stream=True) is invoked from that callback, so the
eager final_response check added for the non-managed path never fires:
the inner ManagedLlmStream is returned to the outer stream, which then
synchronously iterates it on the same loop thread and dies with
RuntimeError: Cannot run the event loop while another loop is running
(the completed response effectively trapped one level deeper).

stream_current() now detects a running event loop and returns the raw
factory result instead of nesting a ManagedLlmStream: the outer managed
stream already provides Relay tracking for the enclosing attempt, and
its own completed_response_predicate traps the completed response as
final_response — the same contract the main streaming worker consumes
(chat_completion_helpers reads stream.final_response after the chunk
loop). Nested managed streams remain supported for genuinely streaming
providers via the outer stream's own iteration.

Adds managed-execution regressions using the retained relay_turn
fixture: direct completed-response trapping, and the nested
facade-shaped stream_current call.
2026-07-31 22:30:33 -07:00
AKAZIK-py ada3663ce7 fix(moa): unwrap completed responses in the auxiliary streaming path 2026-07-31 22:30:33 -07:00
Alex Fournier 43d29a37c8 fix(observability): include auxiliary model routes
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-31 06:58:41 -07:00
Alex Fournier 5e34fa2d5c fix(relay): preserve provider stream errors
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-28 09:58:43 -07:00
Alex Fournier b1a5d67e71 Merge upstream main into fix/hermes-relay-anthropic-context
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-28 08:10:58 -07:00
Alex Fournier eda54775e2 fix(relay): isolate streaming callback contexts
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-27 21:11:04 -07:00
Alex Fournier 14bed44c8c Reapply "feat(observability): integrate NeMo Relay runtime and shared metrics"
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-27 21:10:51 -07:00
Jeffrey Quesnelle 841a5a744a Revert "feat(observability): integrate NeMo Relay runtime and shared metrics" 2026-07-27 22:28:08 -04:00
Alex Fournier 3be8a2f5f9 refactor(relay): serialize provider objects by capability
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-27 08:18:41 -07:00
Alex Fournier bfae9c2572 fix(relay): ignore rewrites after codec baseline failure
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-27 08:17:21 -07:00
Alex Fournier ec6c881453 fix(relay): preserve buffered provider stream chunks
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-27 08:16:16 -07:00
Alex Fournier a3ef27ab70 fix(relay): preserve intentional request removals
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-23 14:22:49 -07:00
Alex Fournier 06ed41aa1f fix(relay): preserve managed cancellation signals
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-23 14:21:37 -07:00
Alex Fournier ad6fb26681 fix(relay): fence bypassed stream chunks
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-23 14:09:33 -07:00
Alex Fournier 4788994bd2 fix(relay): preserve managed callback context
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-23 13:53:59 -07:00
Alex Fournier 1500ce163c fix(relay): normalize rewritten LLM responses
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-23 13:44:27 -07:00
Alex Fournier e862099dff fix(relay): merge Anthropic stream usage
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-23 13:32:44 -07:00
Alex Fournier c789bdd38a fix(relay): close managed provider streams
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-23 13:32:03 -07:00
Alex Fournier 9dfe690125 fix(relay): preserve provider request extensions
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-23 13:24:19 -07:00
Alex Fournier 1c6a96032c fix(relay): preserve successful managed results
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-23 13:12:50 -07:00
Alex Fournier afd0b3ecd4 fix(observability): keep Relay session headers local
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-22 14:35:55 -07:00
Alex Fournier 537425ebe4 fix(runtime): close abandoned Relay streams
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-22 10:32:49 -07:00
Alex Fournier 27c7c877c5 fix(runtime): close failed auxiliary Relay streams
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-21 14:40:19 -07:00
Alex Fournier 6efc5fe0af fix(runtime): preserve provider payloads through Relay
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-21 09:25:22 -07:00
Alex Fournier 774bcac352 fix(runtime): preserve native streaming responses
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-19 09:23:03 -04:00
Alex Fournier 2c8fd38f2e fix(observability): defer logical LLM completion until validation
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-19 09:00:27 -04:00
Alex Fournier 55b7903cf7 fix(observability): harden Relay terminal lifecycle metrics
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-19 08:59:42 -04:00
Alex Fournier 4dedaa4237 refactor(runtime): consolidate Relay lifecycle ownership
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-19 08:59:06 -04:00
Alex Fournier 9bc521b138 refactor(runtime): manage Relay LLM tool and subagent execution
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-07-19 08:57:38 -04:00