Skip to content

fix(js/genkit): Explicitly allow null types in promptDir#5036

Merged
pavelgj merged 3 commits into
genkit-ai:mainfrom
7hokerz:7hokerz/genkit-promptDir-null
Apr 13, 2026
Merged

fix(js/genkit): Explicitly allow null types in promptDir#5036
pavelgj merged 3 commits into
genkit-ai:mainfrom
7hokerz:7hokerz/genkit-promptDir-null

Conversation

@7hokerz
Copy link
Copy Markdown
Contributor

@7hokerz 7hokerz commented Apr 1, 2026

Description here... Help the reviewer by:

  • Runtime already treats promptDir: null as an opt-out for automatic ./prompts loading.
  • The problem is that while runtime logic seems to treat null values ​​specially and allow them, type does not.
  • This change aligns the type definition with existing behavior and adds coverage for the null opt-out case.

In genkit.ts (972-978 line)

private configure() {
...
if (this.options.promptDir !== null) {
      loadPromptFolder(
        this.registry,
        this.options.promptDir ?? './prompts',
        ''
      );
    }
...

Checklist (if applicable):

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ability to disable automatic prompt loading by allowing promptDir to be set to null in GenkitOptions. However, feedback indicates that the implementation of the prompt() method still defaults to the standard directory when null is provided, meaning the opt-out behavior is not yet fully functional. Furthermore, the added test case needs to be more robust to ensure it correctly verifies that file-based loading is disabled even when prompts exist in the default directory.

Comment thread js/genkit/src/genkit.ts
Comment thread js/genkit/tests/prompts_test.ts
@MichaelDoyle MichaelDoyle requested review from ifielker and pavelgj April 7, 2026 12:58
@MichaelDoyle
Copy link
Copy Markdown
Contributor

Looping in @ifielker and @pavelgj since they have more context than I do.

@pavelgj
Copy link
Copy Markdown
Member

pavelgj commented Apr 7, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ability to disable automatic prompt loading by setting the promptDir option to null. Changes include updating type definitions in prompt.ts and genkit.ts, adjusting the logic in the Genkit class to respect the null value instead of defaulting to the ./prompts directory, and adding a unit test to verify that prompts are not loaded when promptDir is null. I have no feedback to provide.

Comment thread js/genkit/src/genkit.ts
@pavelgj pavelgj enabled auto-merge (squash) April 13, 2026 14:15
@pavelgj pavelgj merged commit 1d4ffeb into genkit-ai:main Apr 13, 2026
8 checks passed
@7hokerz 7hokerz deleted the 7hokerz/genkit-promptDir-null branch April 13, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants