feat(core): route interaction prompt ids and timestamps via providers - #2144
Open
DABH wants to merge 2 commits into
Open
feat(core): route interaction prompt ids and timestamps via providers#2144DABH wants to merge 2 commits into
DABH wants to merge 2 commits into
Conversation
…e provider hooks UserInteractionManager.prompt_user_input still stamps the interaction prompt id with uuid.uuid4() and the prompt and response timestamps with time.gmtime() wall-clock values called inline, so human-in-the-loop interactions are the one remaining runtime surface that ignores the opt-in id and time provider hooks introduced in nat.utils.providers. Reproducible runs that install fixed providers therefore still see nondeterministic interaction ids and timestamps. Route the prompt id through generate_id() and derive both timestamps from current_time() via time.gmtime(current_time()), preserving the exact existing timestamp format. With the default providers this is behavior-identical to the previous inline calls. Mention the interaction prompt and response coverage in the deterministic identifiers section of the observability guide and in the nat.utils.providers module docstring, which enumerates the surfaces the runtime stamps through the hooks. Add a test alongside the existing UserInteractionManager tests that installs a fixed id provider and an advancing time provider (restoring them afterwards), drives prompt_user_input through a stub callback, and asserts the InteractionPrompt and InteractionResponse carry the deterministic id and that each is stamped with the formatted timestamp of its own time provider reading. Signed-off-by: David Hyde <DABH@users.noreply.github.com>
WalkthroughInteraction prompts and responses now receive IDs and timestamps from runtime providers. The interactive test verifies deterministic provider behavior, statuses, content, callback output, and state restoration. Documentation describes these entities as runtime-stamped. ChangesInteraction metadata
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
DABH
marked this pull request as ready for review
August 5, 2026 20:17
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
PR #2114 added the opt-in, process-wide provider hooks in
nat.utils.providersand routed the runtime's generated identifiers and timestamps through them:Runnerworkflow run and trace ids,IntermediateStepPayloaddefaults,Spanids and timestamps, andContext.push_active_functioninvocation ids. One runtime surface was left out: human-in-the-loop interactions.UserInteractionManager.prompt_user_inputstill stamps the outgoingInteractionPromptwith an inlineuuid.uuid4()id, and stamps both the prompt and the returnedInteractionResponsewith wall-clock timestamps (time.gmtime()with no argument, which reads the system clock). Third-party plugin packages (docs/source/extend/third-party-plugins.md) that build on the toolkit's plugin system and install fixed providers for reproducible runs — record or replay style testing, golden-file trace comparison, or runtimes that re-execute workflow code and need identifiers to remain stable across re-executions — therefore still observe nondeterministic interaction ids and timestamps, so two otherwise identical runs cannot correlate their interaction prompts.This PR completes the coverage:
generate_id().current_time()viatime.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(current_time())), preserving the exact existing timestamp format.nat.utils.providersmodule docstring now list interaction prompts and responses among the values the runtime stamps through the hooks, so the two descriptions stay consistent.Zero behavior change by default: when no provider is installed, the defaults remain
uuid.uuid4andtime.time, andtime.gmtime(time.time())is equivalent to the previoustime.gmtime()call.No tracking issue exists for this yet; happy to file one if the team prefers.
Testing
test_prompt_user_input_uses_installed_providersin packages/nvidia_nat_core/tests/nat/builder/test_interactive.py, alongside the existingUserInteractionManagertests: it installs a fixed id provider and an advancing time provider (restored infinally), drivesprompt_user_inputthrough a stub callback, and asserts theInteractionPrompthanded to the callback and the returnedInteractionResponsecarry the deterministic id, the expected statuses, and each the formatted UTC timestamp of its own time-provider reading — proving the two timestamps come from two independentcurrent_time()calls.uv run pytest packages/nvidia_nat_core/tests/nat/builder/test_interactive.py packages/nvidia_nat_core/tests/nat/utils/test_providers.py— 21 passed.uv run pytest packages/nvidia_nat_core— 2613 passed, 235 skipped.uv run pre-commit run yapf --files <touched files>anduv run pre-commit run ruff-check --files <touched files>— both passed.uv run python ci/scripts/copyright.py --verify-apache-v2— passed.uv run python ci/scripts/path_checks.py— passed.uv run vale docs/source/run-workflows/observe/observe.md— 0 errors, 0 warnings.By Submitting this PR I confirm:
Summary by CodeRabbit
Enhancements
Documentation