Skip to content

feat: Add push_repo_memory MCP tool for early size validation#19977

Merged
pelikhan merged 11 commits intomainfrom
copilot/fix-repo-memory-size-issue
Mar 7, 2026
Merged

feat: Add push_repo_memory MCP tool for early size validation#19977
pelikhan merged 11 commits intomainfrom
copilot/fix-repo-memory-size-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 7, 2026

  • Analyze the issue - repo-memory fails when memory size exceeds limits, causing workflow failure
  • Add push_repo_memory tool to pkg/workflow/js/safe_outputs_tools.json
  • Add push_repo_memory tool to actions/setup/js/safe_outputs_tools.json
  • Update pkg/workflow/safe_outputs_generation.go to include repo-memory config in safe outputs config JSON and enable the tool in filtered tools
  • Add pushRepoMemoryHandler to actions/setup/js/safe_outputs_handlers.cjs
  • Register handler in actions/setup/js/safe_outputs_tools_loader.cjs
  • Update actions/setup/md/repo_memory_prompt.md to instruct agent to call push_repo_memory (conditional on tool availability)
  • Update actions/setup/md/repo_memory_prompt_multi.md for multi-memory workflows (conditional on tool availability)
  • Update TestGetSafeOutputsToolsJSON test to include push_repo_memory
  • Add unit tests for pushRepoMemoryHandler in safe_outputs_handlers.test.cjs (9 new test cases)
  • Add Go unit tests for generateSafeOutputsConfig with RepoMemoryConfig (3 tests)
  • Add Go unit tests for generateFilteredToolsJSON inclusion/exclusion of push_repo_memory (3 tests)
  • Simplify pushRepoMemoryHandler to use core.debug (always available via shim.cjs) instead of server.debug
  • Build, format, lint and test the changes (all pass)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Changeset

  • Type: patch
  • Description: Added documentation for the new push_repo_memory safe output tool that validates repo memory limits early in setup prompts and tests.

Generated by Changeset Generator for issue #19977 ·

Warning

⚠️ Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • ab.chatgpt.com
  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"
    - "github.com"

See Network Configuration for more information.



✨ PR Review Safe Output Test - Run 22808419278

💥 [THE END] — Illustrated by Smoke Claude ·

Copilot AI linked an issue Mar 7, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits March 7, 2026 18:39
Adds a new `push_repo_memory` safe output MCP tool that allows the AI
agent to validate repo-memory file sizes during its session, before the
post-run push job runs. When memory exceeds configured limits, the tool
returns a clear error message suggesting the agent reduce content size.

Changes:
- Add `push_repo_memory` tool to safe_outputs_tools.json
- Add `pushRepoMemoryHandler` to safe_outputs_handlers.cjs
- Register handler in safe_outputs_tools_loader.cjs
- Update safe_outputs_generation.go to include repo-memory config in
  safe outputs JSON when repo-memory is configured
- Update repo_memory_prompt.md and repo_memory_prompt_multi.md to
  instruct agents to call push_repo_memory after writing memory
- Update TestGetSafeOutputsToolsJSON to include push_repo_memory

Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
…h_repo_memory

Address code review: only add push_repo_memory to actions/setup/js/safe_outputs_tools.json
without bringing in unrelated sync changes from pkg/workflow/js/safe_outputs_tools.json.
Also improve handler comments and error message clarity.

Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix repo-memory fails when exceeding allowed size feat: Add push_repo_memory MCP tool for early size validation Mar 7, 2026
Copilot finished work on behalf of dsyme March 7, 2026 18:45
@dsyme dsyme requested a review from pelikhan March 7, 2026 18:47
@dsyme dsyme marked this pull request as ready for review March 7, 2026 18:47
Copilot AI review requested due to automatic review settings March 7, 2026 18:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new push_repo_memory MCP tool to allow agents to validate repo-memory size constraints during the session (before the post-run push_repo_memory.cjs job), and wires the tool into the safe-outputs MCP server when repo-memory is configured.

Changes:

  • Inject push_repo_memory configuration (memories + limits) into safe-outputs config.json and enable the tool in filtered tools.json when repo-memory is present.
  • Add pushRepoMemoryHandler to scan repo-memory directories and enforce file size / file count / total size limits with the same 20% overhead approach as the post-run push job.
  • Update repo-memory prompts to instruct agents to call push_repo_memory after writing memory files.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pkg/workflow/safe_outputs_tools_test.go Updates embedded tools JSON test to include push_repo_memory.
pkg/workflow/safe_outputs_generation.go Adds safe-outputs config/tool enablement for push_repo_memory based on repo-memory config.
pkg/workflow/js/safe_outputs_tools.json Adds the push_repo_memory tool schema to the embedded tools list.
actions/setup/md/repo_memory_prompt.md Instructs agents to call push_repo_memory after writing memory files (single-memory prompt).
actions/setup/md/repo_memory_prompt_multi.md Instructs agents to call push_repo_memory after writing memory files (multi-memory prompt).
actions/setup/js/safe_outputs_tools_loader.cjs Registers push_repo_memory handler in the tool handler map.
actions/setup/js/safe_outputs_tools.json Adds push_repo_memory tool schema to the runtime tools list used by the MCP server.
actions/setup/js/safe_outputs_handlers.cjs Implements pushRepoMemoryHandler and exports it via createHandlers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +602 to +618
// Add push_repo_memory config if repo-memory is configured
// This enables the push_repo_memory MCP tool for early size validation during agent session
if data.RepoMemoryConfig != nil && len(data.RepoMemoryConfig.Memories) > 0 {
var memories []map[string]any
for _, memory := range data.RepoMemoryConfig.Memories {
memories = append(memories, map[string]any{
"id": memory.ID,
"dir": "/tmp/gh-aw/repo-memory/" + memory.ID,
"max_file_size": memory.MaxFileSize,
"max_patch_size": memory.MaxPatchSize,
"max_file_count": memory.MaxFileCount,
})
}
safeOutputsConfig["push_repo_memory"] = map[string]any{
"memories": memories,
}
safeOutputsConfigLog.Printf("Added push_repo_memory config with %d memory entries", len(memories))
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The new push_repo_memory safe-outputs config/tool enablement is not covered by existing Go unit tests for config/tool generation. Please add tests that verify: (1) generateSafeOutputsConfig includes the expected push_repo_memory.memories entries when RepoMemoryConfig is present, and (2) generateFilteredToolsJSON includes push_repo_memory only when repo-memory is configured.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added 6 Go unit tests in commit 13419cc:

generateSafeOutputsConfig tests (in safe_outputs_config_generation_test.go):

  • TestGenerateSafeOutputsConfigRepoMemory — verifies push_repo_memory.memories entries are populated with correct id, dir, and size limits when RepoMemoryConfig is present
  • TestGenerateSafeOutputsConfigNoRepoMemory — verifies push_repo_memory is absent when RepoMemoryConfig is nil
  • TestGenerateSafeOutputsConfigEmptyRepoMemory — verifies push_repo_memory is absent when Memories slice is empty

generateFilteredToolsJSON tests (in safe_outputs_tools_generation_test.go):

  • TestGenerateFilteredToolsJSONIncludesPushRepoMemoryWithRepoMemoryConfig — verifies push_repo_memory is included when RepoMemoryConfig has entries
  • TestGenerateFilteredToolsJSONExcludesPushRepoMemoryWithoutRepoMemoryConfig — verifies push_repo_memory is excluded when RepoMemoryConfig is nil
  • TestGenerateFilteredToolsJSONExcludesPushRepoMemoryWithEmptyMemories — verifies push_repo_memory is excluded when Memories is empty

dsyme and others added 4 commits March 7, 2026 20:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…rs.test.cjs

Covers: unknown memory_id, missing memory dir, oversized file, too many files,
total size over limit, default memory_id, recursive subdirectory scanning, and
handler structure export check.

Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
- TestGenerateSafeOutputsConfigRepoMemory: verifies memories array is populated
- TestGenerateSafeOutputsConfigNoRepoMemory: verifies absent when config is nil
- TestGenerateSafeOutputsConfigEmptyRepoMemory: verifies absent with empty memories
- TestGenerateFilteredToolsJSONIncludesPushRepoMemoryWithRepoMemoryConfig
- TestGenerateFilteredToolsJSONExcludesPushRepoMemoryWithoutRepoMemoryConfig
- TestGenerateFilteredToolsJSONExcludesPushRepoMemoryWithEmptyMemories

Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copilot finished work on behalf of dsyme March 7, 2026 20:20
@pelikhan
Copy link
Contributor

pelikhan commented Mar 7, 2026

@copilot the core object should always be available since the shim.cjs file is loaded in the MCP JavaScript. Review and simplify code.

…s available via shim.cjs

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

Copilot AI commented Mar 7, 2026

@copilot the core object should always be available since the shim.cjs file is loaded in the MCP JavaScript. Review and simplify code.

Simplified in commit 720967e. Added /// <reference types="@actions/github-script" /> to safe_outputs_handlers.cjs and replaced server.debug(...) with core.debug(...) in pushRepoMemoryHandler. The handler now uses core directly (always available via shim.cjs) rather than routing through the MCP server object for this validation log.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/github/gh-aw/contents/.github%2Fworkflows%2Faudit-workflows.md
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/dist/workers/forks.js --stdout in/feature-branc--verify git conf�� --local --get e/git -1 --format=%s nfig/composer/vendor/bin/git e/git (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

✅ All tools validated successfully! Agent Container Smoke Test confirms agent container is ready.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.53.0
jq 1.7
yq v4.52.4
curl 8.5.0
gh 2.87.3
node v20.20.0
python3 3.12.3
go 1.24.13
java 21.0.10
dotnet 10.0.102

Result: 12/12 tools available ✅

Overall Status: PASS

🔧 Tool validation by Agent Container Smoke Test ·

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

Commit pushed: c2476bb

Generated by Changeset Generator

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

🤖 Smoke test check-in from your friendly Copilot agent!

Quick results for run §22808419281:

Test
GitHub MCP
Safe Inputs GH CLI
Serena MCP
Playwright
Web Fetch
File Writing
Bash Tool
Discussion Interaction
Build gh-aw
Discussion Creation
Workflow Dispatch
PR Review

Overall: ⚠️ PARTIAL PASS (11/12 — Serena MCP unavailable)

PR author: @copilot-swe-agent | Assignees: @dsyme, @Copilot

📰 BREAKING: Report filed by Smoke Copilot ·

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR adds push_repo_memory as a new safe-output tool to enable early size validation before workflows complete. The changes are consistent across all workflow lock files and the Go generation code. One minor note about nil-vs-empty slice serialization on the memories array, but overall the implementation looks solid and well-tested.

📰 BREAKING: Report filed by Smoke Copilot

}
safeOutputsConfig["push_repo_memory"] = map[string]any{
"memories": memories,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice addition of push_repo_memory to the safe-outputs config! One small thought: if memories ends up being an empty slice (e.g., all memory configs are filtered out), the config entry would have "memories": null. Consider initializing with memories := make([]map[string]any, 0, len(data.RepoMemoryConfig.Memories)) to ensure it serializes as [] rather than null.

// Add push_repo_memory tool if repo-memory is configured
// This tool enables early size validation during the agent session
if data.RepoMemoryConfig != nil && len(data.RepoMemoryConfig.Memories) > 0 {
enabledTools["push_repo_memory"] = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Good symmetry — enabling push_repo_memory in the tools list mirrors the config generation above. This ensures the tool only appears in the schema when repo-memory is actually configured, keeping the tool surface clean.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

Smoke Test Results — Run §22808419278

Core tests #1#10: ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
PR review tests #11#17: ✅ ✅ ✅ ✅ ✅ ✅ ⚠️(skip)

Overall: PARTIAL (close PR skipped — no safe test PR)

💥 [THE END] — Illustrated by Smoke Claude ·

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude

@pelikhan pelikhan merged commit bafae99 into main Mar 7, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/fix-repo-memory-size-issue branch March 7, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repo-memory fails when memory exceeds allowed size

4 participants