-
Notifications
You must be signed in to change notification settings - Fork 18
feat(nemo-agents): support for nemo agents run and nemo agents deploy for Fabric backed agents #909
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
Merged
mmogallapalli
merged 16 commits into
main
from
mmogallapall/aircore-932-define-and-implement-managed-fabric-runtimesession-lifecycle
Jul 28, 2026
Merged
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
800de5a
add fastapi server
mmogallapalli 77f8a2d
add session registry
mmogallapalli fdc28ce
lazy fabric session initializiation per session
mmogallapalli c1b2274
route requests with sessions
mmogallapalli f42fd0e
add per session invocation lock
mmogallapalli 8aa6750
concurrency & session lifecycle management
mmogallapalli 57fe33b
shared config validation protocol
mmogallapalli e6fb7c0
wiring fabric deployment
mmogallapalli 0098e9a
add common env setup helper
mmogallapalli 7ba35ca
followups
mmogallapalli 0f588be
lint
mmogallapalli 4f66513
remove file
mmogallapalli e76e524
nemo agents run
mmogallapalli 3c20a6b
cr followup
mmogallapalli f69cf41
reviewer feedback
mmogallapalli 3d1d94b
feedback pt2
mmogallapalli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
plugins/nemo-agents/src/nemo_agents_plugin/agent_config_formats.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Shared validation and deployment resolution for agent config formats.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any, Protocol | ||
|
|
||
| from nemo_agents_plugin.agent_config import AgentConfig | ||
| from nemo_agents_plugin.entities import NAT_WORKFLOW_CONFIG_FORMAT, NEMO_AGENTS_SPEC_CONFIG_FORMAT | ||
| from nemo_agents_plugin.utils import inject_default_model, inject_gateway_url, inject_nemo_trace_fields | ||
| from pydantic import ValidationError | ||
|
|
||
|
|
||
| class AgentConfigFormatError(ValueError): | ||
| """Base error for unsupported or invalid agent config formats.""" | ||
|
|
||
|
|
||
| class UnsupportedAgentConfigFormatError(AgentConfigFormatError): | ||
| """Raised when no handler exists for an agent config format.""" | ||
|
|
||
|
|
||
| class InvalidAgentConfigError(AgentConfigFormatError): | ||
| """Raised when an agent config does not satisfy its format contract.""" | ||
|
|
||
|
|
||
| class AgentConfigFormatHandler(Protocol): | ||
| """Validate and resolve one persisted agent config format.""" | ||
|
|
||
| def validate(self, config: dict[str, Any]) -> dict[str, Any]: ... | ||
|
|
||
| def resolve_for_deployment( | ||
| self, | ||
| config: dict[str, Any], | ||
| *, | ||
| workspace: str, | ||
| agent_name: str, | ||
| ) -> dict[str, Any]: ... | ||
|
|
||
|
|
||
| class _NatWorkflowConfigHandler: | ||
| def validate(self, config: dict[str, Any]) -> dict[str, Any]: | ||
| return config | ||
|
|
||
| def resolve_for_deployment( | ||
| self, | ||
| config: dict[str, Any], | ||
| *, | ||
| workspace: str, | ||
| agent_name: str, | ||
| ) -> dict[str, Any]: | ||
| resolved = inject_gateway_url(config, workspace) | ||
|
mmogallapalli marked this conversation as resolved.
|
||
| resolved = inject_default_model(resolved) | ||
| inject_nemo_trace_fields(resolved, workspace=workspace, agent_name=agent_name) | ||
| return resolved | ||
|
|
||
|
|
||
| class _NemoAgentsSpecConfigHandler: | ||
| def validate(self, config: dict[str, Any]) -> dict[str, Any]: | ||
| return self._normalize(config) | ||
|
|
||
| def resolve_for_deployment( | ||
| self, | ||
| config: dict[str, Any], | ||
| *, | ||
| workspace: str, | ||
| agent_name: str, | ||
| ) -> dict[str, Any]: | ||
| del workspace, agent_name | ||
| return self._normalize(config) | ||
|
|
||
| @staticmethod | ||
|
mikeknep marked this conversation as resolved.
|
||
| def _normalize(config: dict[str, Any]) -> dict[str, Any]: | ||
| try: | ||
| return AgentConfig.model_validate(config).model_dump(exclude_none=True) | ||
| except ValidationError as error: | ||
| raise InvalidAgentConfigError(f"Invalid agent config: {error}") from error | ||
|
|
||
|
|
||
| _AGENT_CONFIG_FORMAT_HANDLERS: dict[str, AgentConfigFormatHandler] = { | ||
| NAT_WORKFLOW_CONFIG_FORMAT: _NatWorkflowConfigHandler(), | ||
| NEMO_AGENTS_SPEC_CONFIG_FORMAT: _NemoAgentsSpecConfigHandler(), | ||
| } | ||
|
|
||
|
|
||
| def get_agent_config_format_handler(config_format: str) -> AgentConfigFormatHandler: | ||
| """Return the handler registered for an agent config format.""" | ||
| try: | ||
| return _AGENT_CONFIG_FORMAT_HANDLERS[config_format] | ||
| except KeyError as error: | ||
| raise UnsupportedAgentConfigFormatError(f"Unsupported config_format {config_format!r}.") from error | ||
|
|
||
|
|
||
| def validate_agent_config(config_format: str, config: dict[str, Any]) -> dict[str, Any]: | ||
| """Validate and normalize an agent config before persistence.""" | ||
| return get_agent_config_format_handler(config_format).validate(config) | ||
|
|
||
|
|
||
| def resolve_agent_config_for_deployment( | ||
| config_format: str, | ||
| config: dict[str, Any], | ||
| *, | ||
| workspace: str, | ||
| agent_name: str, | ||
| ) -> dict[str, Any]: | ||
| """Resolve a persisted agent config for deployment.""" | ||
| return get_agent_config_format_handler(config_format).resolve_for_deployment( | ||
| config, | ||
| workspace=workspace, | ||
| agent_name=agent_name, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
plugins/nemo-agents/src/nemo_agents_plugin/fabric/environment.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Prepare Platform-owned environment paths before Fabric runtime startup.""" | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| from nemo_agents_plugin.agent_config import AgentConfig | ||
|
|
||
|
|
||
| def ensure_local_workspace_dir(agent_config: AgentConfig, base_dir: Path) -> None: | ||
| """Create the configured local workspace relative to the agent base directory.""" | ||
| if agent_config.environment.provider != "local": | ||
| return | ||
|
|
||
| workspace = Path(agent_config.environment.workspace) | ||
| if not workspace.is_absolute(): | ||
| workspace = base_dir / workspace | ||
| workspace.mkdir(parents=True, exist_ok=True) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.