Skip to content

feat(plugin-api): export the interactive prompt content models - #2145

Draft
DABH wants to merge 1 commit into
NVIDIA:developfrom
DABH:plugin-api-prompt-content-exports
Draft

feat(plugin-api): export the interactive prompt content models#2145
DABH wants to merge 1 commit into
NVIDIA:developfrom
DABH:plugin-api-prompt-content-exports

Conversation

@DABH

@DABH DABH commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description

Third-party plugin packages are asked to import plugin-authoring symbols only from the stable nat.plugin_api facade (per docs/source/extend/third-party-plugins.md). PR #2113 exported the interactive response side of that surface: InteractionPrompt, InteractionResponse, and the HumanResponse union with its concrete response models. The prompt side is still missing: the concrete prompt content models behind the HumanPrompt union are only importable from the implementation module nat.data_models.interactive.

Plugin authors do not only consume responses. HITL middleware hooks, user-input callbacks, and front-end integrations construct prompts: any plugin that calls Context.get().user_interaction_manager.prompt_user_input(...) first has to build a HumanPromptText (or a notification, binary, radio, checkbox, or dropdown variant). The in-repo HITL examples import HumanPromptText from nat.data_models.interactive, and the interactive workflows guide constructs it while pointing readers at that same internal module path — exactly the dependency an external package following the facade contract is told not to take. In addition, the binary and multiple-choice prompt models embed required option models, and those same option models are the field types of the already-exported HumanResponseBinary, HumanResponseRadio, HumanResponseCheckbox, and HumanResponseDropdown (selected_option), so typed construction of the exported response models also needs them.

This change is purely additive and completes the prompt-and-response symmetry of the interactive surface:

  • Re-export the concrete prompt content models HumanPromptText, HumanPromptNotification, HumanPromptBinary, HumanPromptRadio, HumanPromptCheckbox, and HumanPromptDropdown, together with the embedded option models BinaryHumanPromptOption and MultipleChoiceOption, through nat.plugin_api, and extend __all__.
  • Pin the new symbols in EXPECTED_PLUGIN_API_EXPORTS and extend the denied-import patterns in the plugin-authoring docs test (the existing HumanPrompt pattern already covers the HumanPrompt* model imports as substrings, so only the two option-model patterns are new).
  • Add a consumer-style test that constructs every prompt variant through nat.plugin_api imports alone and round-trips each one through InteractionPrompt to check the discriminated union resolves the concrete types.
  • Document the new surface in docs/source/extend/plugin-api.md, extending the interactive-models bullet and the "HITL middleware" surface-review row (the models follow that row's existing provisional public, trusted plugin status).

Deliberately not exported: the OAuth consent prompt variant stays private (it is underscore-prefixed by design), and the abstract bases (HumanPromptBase, HumanPromptMultipleChoiceBase) stay internal, mirroring how InteractionBase is not exported; the already-exported HumanPrompt union covers the "any prompt" typing need.

Migrating the in-repo consumers (the two HITL examples and the interactive workflows guide) to the facade imports is deliberately left as a follow-up so this change stays purely additive. No tracking issue exists for this yet; happy to file one — also covering that migration — if the team prefers.

Testing

  • uv run pytest packages/nvidia_nat_core/tests/nat/test_plugin_api.py — 8 passed (includes the new consumer-style prompt-construction test).
  • uv run pytest packages/nvidia_nat_core/tests/nat/builder packages/nvidia_nat_core/tests/nat/middleware packages/nvidia_nat_core/tests/nat/runtime packages/nvidia_nat_core/tests/nat/data_models — 852 passed.
  • uv run pre-commit run yapf --files <touched files> and uv run pre-commit run ruff-check --files <touched files> — 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/extend/plugin-api.md — 0 errors, 0 warnings, 0 suggestions.

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
    • Any contribution which contains commits that are not Signed-Off will not be accepted.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

The plugin-api facade exports the interactive response models and
InteractionPrompt, but not the concrete prompt content models behind the
HumanPrompt union. Plugin authors building interaction flows construct
prompts, not just responses, and today must import them from
nat.data_models.interactive in violation of the import-only-from-plugin_api
contract.

Export HumanPromptText, HumanPromptNotification, HumanPromptBinary,
HumanPromptRadio, HumanPromptCheckbox, and HumanPromptDropdown, together
with the BinaryHumanPromptOption and MultipleChoiceOption models that
binary and multiple-choice prompts and responses embed. Pin the new
symbols in the expected-exports test, extend the denied-import patterns,
add a consumer-style test constructing every prompt variant through
facade-only imports, and document the new surface in
docs/source/extend/plugin-api.md.

Signed-off-by: David Hyde <DABH@users.noreply.github.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c3498629-4a84-4aa8-a63e-7df065cb219b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant