-
Notifications
You must be signed in to change notification settings - Fork 15
Add async session boundary to the Python SDK (FABRIC-10) #12
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
AjayThorve
merged 10 commits into
NVIDIA:main
from
AjayThorve:ajay/fabric-10-support-session-management-and-cancellations
Jun 23, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f27cbb1
Add async session boundary to the Python SDK (start/invoke/stream/can…
AjayThorve 9e7a201
ci(python): run the session smoke
AjayThorve 37755fb
Surface per-turn invocation handles on Session
AjayThorve bca7285
Document session SDK methods (params, returns, errors)
AjayThorve 3a4ae87
Add session unit tests
AjayThorve c59f0be
Add hermes_session example profile; note sessions are SDK-only
AjayThorve 3bf05c6
Address CodeRabbit review on the session boundary
AjayThorve 83aef91
Remove unused agent_profile from the example config
AjayThorve c77a46f
Address CodeRabbit: single-flight session turns; README example import
AjayThorve 0b02612
Apply suggestion from @dagardner-nv
AjayThorve 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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| schema_version: fabric.profile/v1alpha1 | ||
| name: hermes_session | ||
| description: Drive the Hermes Python adapter as a multi-turn session (runtime mode session). | ||
|
|
||
| harness: | ||
| adapter_id: nvidia.fabric.hermes.sdk | ||
| resolution: preinstalled | ||
| settings: | ||
| python_env: HERMES_PYTHON | ||
| workspace: ./repos/my-service | ||
| hermes_home: ./artifacts/hermes-home | ||
| base_url: https://integrate.api.nvidia.com/v1 | ||
| max_turns: 1 | ||
|
dagardner-nv marked this conversation as resolved.
|
||
| max_tokens: 512 | ||
| temperature: 0.0 | ||
| reasoning_config: | ||
| effort: none | ||
| enabled_toolsets: [] | ||
| system_prompt: You are a concise smoke test assistant. | ||
|
|
||
| runtime: | ||
| mode: session | ||
| transport: library | ||
| input_schema: chat | ||
| output_schema: message | ||
| artifacts: ./artifacts/hermes-session | ||
|
|
||
| environment: | ||
| provider: local | ||
| workspace: ./repos/my-service | ||
| artifacts: ./artifacts/hermes-session | ||
|
|
||
| telemetry: | ||
| enabled: false | ||
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,50 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Quickstart: a multi-turn Fabric session (start -> invoke -> stream -> stop). | ||
|
|
||
| The session replays the accumulated transcript as conversation history on each | ||
| turn, so the harness remembers prior turns. | ||
|
|
||
| Run it with an interpreter that has the ``nemo_fabric`` native binding and Hermes | ||
| installed, with an API key available: | ||
|
|
||
| set -a; . ./.env; set +a # provides NVIDIA_API_KEY | ||
| <hermes-venv>/bin/python examples/session_quickstart.py | ||
|
|
||
| For a zero-setup local check of the session mechanics (no native binding, no | ||
| Hermes, no API key), run the unit smoke instead: | ||
|
|
||
| python3 python/tests/smoke_sdk_sessions.py | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import asyncio | ||
|
|
||
| from nemo_fabric import FabricClient | ||
|
|
||
|
|
||
| async def main() -> None: | ||
| async with await FabricClient().start( | ||
| "examples/code-review-agent", profile="hermes_session" | ||
| ) as session: | ||
| print(f"session {session.id} [{session.status.value}]") | ||
|
|
||
| result = await session.invoke("My name is Robin. Please remember it for later.") | ||
| print(f"\n> remember my name\n {(result.get('output') or {}).get('response')}") | ||
|
|
||
| # stream() yields events as they arrive, then the final RunResult (last item). | ||
| print("\n> what is my name? (streamed)") | ||
| async for item in session.stream("What is my name? Reply with just the name."): | ||
| if "status" in item: # terminal RunResult | ||
| print(f" = {(item.get('output') or {}).get('response')}") | ||
| else: # incremental event | ||
| print(f" . {item.get('kind')}: {item.get('message')}") | ||
|
|
||
| print(f"\ntranscript turns accumulated: {len(session.messages)}") | ||
| print(f"\nsession [{session.status.value}] after context exit") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(main()) |
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.
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.