Skip to content

feat: opt-in AI refinement of sample displayName and description#582

Open
Yimin-Jin wants to merge 7 commits into
template/devfrom
yimin/ai-refine-display-fields
Open

feat: opt-in AI refinement of sample displayName and description#582
Yimin-Jin wants to merge 7 commits into
template/devfrom
yimin/ai-refine-display-fields

Conversation

@Yimin-Jin

Copy link
Copy Markdown
Collaborator

Summary

Adds an opt-in refine_with_ai toggle to the Sync Sample Catalog workflow so AI can review and improve both displayName and description — not just fill blanks. Default behavior is unchanged.

Behavior

Toggle OFF (default): identical to today — an empty displayName is derived from the folder name, an empty description is generated by the LLM, and any value that already exists (PM-curated or preserved from the previous catalog) is left untouched.

Toggle ON (refine_with_ai: true): the LLM reviews every template's current displayName + description against its README and rewrites a field only when it no longer fits the sample's scenario — values that already match are kept verbatim (refinement is not a forced rewrite). displayName follows the Foundry Sample Finder convention: short, human-friendly Title Case scenario names (e.g. \Basic Agent, \Foundry Toolbox, \Azure Search RAG) instead of raw folder names.

Changes

  • sync-sample-catalog.yml: new refine_with_ai boolean input (default false), passed to the generator as AI_REFINE.
  • generate_sample_catalog.mjs:
    • New AI_REFINE flag gating the two paths.
    • Extracted shared callLLMForJson helper (removes duplicated request/parse/error handling).
    • New refineDisplayFieldsWithLLM (displayName + description, README-aware, keep-if-fits).
    • autoFillDisplayFields split into fillBlankDisplayFields (default) and refineAllWithLLM (opt-in).

Notes

  • Without Azure OpenAI credentials the refine path degrades to filling blanks only (warns).
  • Zero new dependencies. sample-catalog.json is regenerated by the workflow and intentionally NOT included.

Validation

  • node --check passes. Recommend a manual workflow_dispatch run (both toggle states) before merge.

Adds a 'refine_with_ai' workflow_dispatch input (default off). When off, behavior is unchanged: empty displayName is derived from the folder name and empty description is filled by the LLM, existing values untouched. When on, the LLM reviews both displayName and description of every template against its README and rewrites them only when they no longer fit, keeping values that already match. displayName now follows the Foundry Sample Finder convention (short human-friendly Title Case names). Shared LLM plumbing is extracted into callLLMForJson to avoid duplicating the request/parse logic.
@Yimin-Jin
Yimin-Jin requested a review from huimiu as a code owner July 23, 2026 06:58
The refine path fires one LLM request per template (~90 in a full run); a burst can trip the rate limiter at the sliding-window edge even with ample quota, which previously surfaced as many 429s and dropped fields. Wrap callLLMForJson's request in a retry loop that retries 429/5xx/network errors with jittered exponential backoff, honoring a server Retry-After (capped). Non-retryable 4xx and empty/invalid responses behave as before.
The first AI refine should regenerate every displayName/description without being anchored by the previous catalog's values (the keep-if-fits logic would otherwise preserve them). Adds an opt-in ignore_existing_catalog workflow input (default false) that skips mergeExistingDisplayFields via the IGNORE_EXISTING env, so all fields start empty and are fully regenerated. Normal runs are unchanged and still preserve PM-curated values.
After merging template/dev (PR #580 added fetch-layer retry with delay/parseRetryAfterMs/computeBackoffMs), the LLM retry path's local sleep/retryAfterMsFromResponse duplicated those helpers. Drop the duplicates and reuse the shared delay/parseRetryAfterMs.
Two samples in the same language+framework+protocol group getting the same displayName (e.g. both '05-workflows' -> 'Multi-Agent Workflow') is confusing since the user sees them together. Add detection-only warnDuplicateDisplayNames that flags such same-group collisions in the CI step summary so a PM can disambiguate before merge. Cross-group duplicates are allowed (never seen side by side). The catalog is left unchanged.
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