Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 24, 2026

Refactor cache memory prompt text to markdown template file

Summary:
Refactored cache memory prompt from inline generation to a markdown template file with placeholder interpolation via the substitute_placeholders.cjs script.

Changes:

  • Created actions/setup/md/cache_memory_prompt.md template with __GH_AW_CACHE_DIR__ and __GH_AW_CACHE_DESCRIPTION__ placeholders
  • Updated buildCacheMemoryPromptSection to use EnvVars for static values
  • Modified unified_prompt_step.go to pass static env vars ONLY to substitution step (not prompt creation step)
  • Added 7 unit tests for buildCacheMemoryPromptSection covering single cache, multiple caches, and edge cases
  • Updated integration tests to verify correct env var placement
  • Recompiled all workflow files
  • Merged main branch
  • All formatting and linting checks passing

Implementation:

  1. Prompt Creation Step: Simply cats the template file without cache env vars

    - name: Create prompt with built-in context
      env:
        GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
        # NO cache env vars here - only GitHub Actions expressions
      run: |
        cat "/opt/gh-aw/prompts/cache_memory_prompt.md" >> "$GH_AW_PROMPT"
  2. Substitution Step: Contains cache env vars and performs interpolation

    - name: Substitute placeholders
      env:
        GH_AW_CACHE_DIR: ${{ '/tmp/gh-aw/cache-memory/' }}
        GH_AW_CACHE_DESCRIPTION: ${{ '' }}
      with:
        script: |
          substitutePlaceholders({
            substitutions: {
              GH_AW_CACHE_DIR: process.env.GH_AW_CACHE_DIR,
              GH_AW_CACHE_DESCRIPTION: process.env.GH_AW_CACHE_DESCRIPTION
            }
          })

Testing:

  • All 40 cache-related tests passing
  • 7 new unit tests for buildCacheMemoryPromptSection
  • Verified single default cache uses template file
  • Verified multiple caches use inline generation
  • Verified env vars only in substitution step
  • All linters passing
Original prompt

Refactor the prompt text inserted for a cache memory as a markdown file template in actions/setup/md + template expression interpolation.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 24, 2026 23:54
…tution

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor prompt text for cache memory markdown template Refactor cache memory prompt to markdown template with sed interpolation Jan 25, 2026
Copilot AI requested a review from pelikhan January 25, 2026 00:14
@pelikhan
Copy link
Contributor

@copilot the interpolation is done in a later step. Remove sed calls and make sure the variables are passed in tbe interpolation step

- Updated template to use __GH_AW_CACHE_DIR__ and __GH_AW_CACHE_DESCRIPTION__ placeholders
- Removed Substitutions field from PromptSection
- Changed buildCacheMemoryPromptSection to use EnvVars instead of Substitutions
- Added logic to include static env vars in the substitution step expression mappings
- Removed all sed-based substitution code from unified_prompt_step.go
- Updated tests to check for env vars and substitution step instead of sed commands
- Cache values are now passed to substitute_placeholders.cjs for interpolation

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 25, 2026

@copilot the interpolation is done in a later step. Remove sed calls and make sure the variables are passed in tbe interpolation step

Done in commit 49e7fbb. Removed sed calls and updated to pass cache variables (GH_AW_CACHE_DIR, GH_AW_CACHE_DESCRIPTION) through the substitute_placeholders.cjs interpolation step. The template file is now simply cat'd at runtime, and values are interpolated in the later "Substitute placeholders" step.

Copilot AI changed the title Refactor cache memory prompt to markdown template with sed interpolation Refactor cache memory prompt to markdown template with placeholder interpolation Jan 25, 2026
@pelikhan
Copy link
Contributor

@copilot substitution should only happen in the substitution step

…eation step

- Modified generateUnifiedPromptStep to exclude static env vars from prompt creation step
- Static values (not wrapped in ${{ }}) now only added to substitution step
- Updated test to verify cache env vars are not in prompt creation step
- Recompiled all workflow files

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 25, 2026

@copilot substitution should only happen in the substitution step

Fixed in commit cb90f11. Cache env vars now only appear in the "Substitute placeholders" step, not the "Create prompt" step. Static values are excluded from the prompt creation step's environment and only passed to the substitution step for interpolation.

@pelikhan
Copy link
Contributor

@copilot add tests for multiple caches

…scenarios

- Added 7 unit tests covering single cache, multiple caches, and edge cases
- Tests verify template file usage for single default cache
- Tests verify inline content generation for multiple caches
- Tests verify environment variable handling
- Tests verify description text formatting
- All 40 cache-related tests passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 25, 2026

@copilot add tests for multiple caches

Added in commit 031354e. Created 7 unit tests for buildCacheMemoryPromptSection covering:

  • Single default cache with/without description (uses template file)
  • Multiple caches with mixed descriptions (uses inline content)
  • Single non-default cache (uses inline content)
  • Edge cases (nil config, empty caches)

All 40 cache-related tests passing.

@pelikhan pelikhan marked this pull request as ready for review January 25, 2026 12:47
@pelikhan
Copy link
Contributor

@copilot merge main, format, lint go

Copilot AI and others added 2 commits January 25, 2026 18:46
- Merged origin/main branch
- Fixed testifylint issue: use assert.Empty instead of assert.Equal(t, "")
- Formatting: removed trailing whitespace
- All linters passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 25, 2026

@copilot merge main, format, lint go

Completed in commit 4600c20. Merged origin/main, ran formatting, and fixed linting issues. All linters passing.

@pelikhan pelikhan merged commit c9e37dc into main Jan 25, 2026
84 checks passed
@pelikhan pelikhan deleted the copilot/refactor-cache-memory-prompt branch January 25, 2026 18:53
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.

2 participants