Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/src/content/docs/reference/repo-memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tools:
file-glob: ["*.md", "*.json"]
max-file-size: 1048576 # 1MB (default 10KB)
max-file-count: 50 # default 100
max-patch-size: 102400 # 100KB max (default 10KB)
max-patch-size: 1048576 # 1MB max (default 10KB)
target-repo: "owner/repository"
create-orphan: true # default
allowed-extensions: [".json", ".txt", ".md"] # Restrict file types (default: empty/all files allowed)
Expand All @@ -41,7 +41,7 @@ tools:

**File Type Restrictions**: Use `allowed-extensions` to restrict which file types can be stored (default: empty/all files allowed). When specified, only files with listed extensions (e.g., `[".json", ".txt", ".md"]`) can be saved. Files with disallowed extensions will trigger validation failures.

**Patch Size Limit**: Use `max-patch-size` to limit the total size of changes in a single push (default: 10KB, max: 100KB). The total size of the git diff (all staged changes combined) must not exceed this value. If it does, the push is rejected with an error. Use this to prevent large unintentional memory updates.
**Patch Size Limit**: Use `max-patch-size` to limit the total size of changes in a single push (default: 10KB, max: 1MB). The total size of the git diff (all staged changes combined) must not exceed this value. If it does, the push is rejected with an error. Use this to prevent large unintentional memory updates.

**Note**: File glob patterns are matched against the **relative file path** within the artifact directory, not the branch path. Use bare extension patterns like `*.json` or `*.md` — do **not** include the branch name (e.g. `memory/custom-agent-for-aw/*.json` is incorrect).

Expand Down
8 changes: 4 additions & 4 deletions pkg/parser/schemas/main_workflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4553,8 +4553,8 @@
"max-patch-size": {
"type": "integer",
"minimum": 1,
"maximum": 102400,
"description": "Maximum total patch size in bytes (default: 10240 = 10KB, max: 102400 = 100KB). The total size of the git diff must not exceed this value."
"maximum": 1048576,
"description": "Maximum total patch size in bytes (default: 10240 = 10KB, max: 1048576 = 1MB). The total size of the git diff must not exceed this value."
Comment on lines +4556 to +4557
},
"description": {
"type": "string",
Expand Down Expand Up @@ -4644,8 +4644,8 @@
"max-patch-size": {
"type": "integer",
"minimum": 1,
"maximum": 102400,
"description": "Maximum total patch size in bytes (default: 10240 = 10KB, max: 102400 = 100KB). The total size of the git diff must not exceed this value."
"maximum": 1048576,
"description": "Maximum total patch size in bytes (default: 10240 = 10KB, max: 1048576 = 1MB). The total size of the git diff must not exceed this value."
},
"description": {
"type": "string",
Expand Down
6 changes: 3 additions & 3 deletions pkg/workflow/repo_memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var repoMemoryLog = logger.New("workflow:repo_memory")
const (
// defaultRepoMemoryMaxPatchSize is the default maximum total patch size in bytes (10KB).
defaultRepoMemoryMaxPatchSize = 10240
// maxRepoMemoryPatchSize is the maximum allowed value for max-patch-size (100KB).
maxRepoMemoryPatchSize = 102400
// maxRepoMemoryPatchSize is the maximum allowed value for max-patch-size (1MB).
maxRepoMemoryPatchSize = 1048576
)

// Pre-compiled regexes for performance (avoid recompilation in hot paths)
Expand All @@ -49,7 +49,7 @@ type RepoMemoryEntry struct {
FileGlob []string `yaml:"file-glob,omitempty"` // file glob patterns for allowed files
MaxFileSize int `yaml:"max-file-size,omitempty"` // maximum size per file in bytes (default: 10KB)
MaxFileCount int `yaml:"max-file-count,omitempty"` // maximum file count per commit (default: 100)
MaxPatchSize int `yaml:"max-patch-size,omitempty"` // maximum total patch size in bytes (default: 10KB, max: 100KB)
MaxPatchSize int `yaml:"max-patch-size,omitempty"` // maximum total patch size in bytes (default: 10KB, max: 1MB)
Description string `yaml:"description,omitempty"` // optional description for this memory
CreateOrphan bool `yaml:"create-orphan,omitempty"` // create orphaned branch if missing (default: true)
AllowedExtensions []string `yaml:"allowed-extensions,omitempty"` // allowed file extensions (default: [".json", ".jsonl", ".txt", ".md", ".csv"])
Expand Down
31 changes: 23 additions & 8 deletions pkg/workflow/repo_memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,12 @@ func TestRepoMemoryMaxPatchSizeValidation(t *testing.T) {
wantError: false,
},
{
name: "valid maximum size (102400 bytes = 100KB)",
name: "valid maximum size (1048576 bytes = 1MB)",
maxPatchSize: 1048576,
wantError: false,
},
{
name: "valid old maximum size (102400 bytes = 100KB)",
maxPatchSize: 102400,
wantError: false,
},
Expand All @@ -715,23 +720,28 @@ func TestRepoMemoryMaxPatchSizeValidation(t *testing.T) {
maxPatchSize: 51200,
wantError: false,
},
{
name: "valid large size (512000 bytes = 500KB)",
maxPatchSize: 512000,
wantError: false,
},
{
name: "invalid zero size",
maxPatchSize: 0,
wantError: true,
errorText: "max-patch-size must be between 1 and 102400, got 0",
errorText: "max-patch-size must be between 1 and 1048576, got 0",
},
{
name: "invalid negative size",
maxPatchSize: -1,
wantError: true,
errorText: "max-patch-size must be between 1 and 102400, got -1",
errorText: "max-patch-size must be between 1 and 1048576, got -1",
},
{
name: "invalid size exceeds maximum",
maxPatchSize: 102401,
maxPatchSize: 1048577,
wantError: true,
errorText: "max-patch-size must be between 1 and 102400, got 102401",
errorText: "max-patch-size must be between 1 and 1048576, got 1048577",
},
}

Expand Down Expand Up @@ -777,17 +787,22 @@ func TestRepoMemoryMaxPatchSizeValidationArray(t *testing.T) {
maxPatchSize: 10240,
wantError: false,
},
{
name: "valid large size in array (500KB)",
maxPatchSize: 512000,
wantError: false,
},
{
name: "invalid size in array (zero)",
maxPatchSize: 0,
wantError: true,
errorText: "max-patch-size must be between 1 and 102400, got 0",
errorText: "max-patch-size must be between 1 and 1048576, got 0",
},
{
name: "invalid size in array (exceeds max)",
maxPatchSize: 102401,
maxPatchSize: 1048577,
wantError: true,
errorText: "max-patch-size must be between 1 and 102400, got 102401",
errorText: "max-patch-size must be between 1 and 1048576, got 1048577",
},
}

Expand Down
6 changes: 3 additions & 3 deletions scratchpad/repo-memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ tools:
# file-glob: string[] (default: all files)
# max-file-size: int (default: 10240, max: 104857600)
# max-file-count: int (default: 100, max: 1000)
# max-patch-size: int (default: 10240, max: 102400)
# max-patch-size: int (default: 10240, max: 1048576)
# description: string (optional)
# create-orphan: boolean (default: true)
# campaign-id: string (optional)
Expand All @@ -248,7 +248,7 @@ tools:
# file-glob: string[] (default: all files)
# max-file-size: int (default: 10240, max: 104857600)
# max-file-count: int (default: 100, max: 1000)
# max-patch-size: int (default: 10240, max: 102400)
# max-patch-size: int (default: 10240, max: 1048576)
# description: string (optional)
# create-orphan: boolean (default: true)
# campaign-id: string (optional)
Expand Down Expand Up @@ -383,7 +383,7 @@ file-glob:
The total size of all changes (git diff) in a single repo-memory push MUST not exceed the configured maximum patch size.

- **Minimum**: 1 byte
- **Maximum**: 102400 bytes (100 KB)
- **Maximum**: 1048576 bytes (1 MB)
- **Default**: 10240 bytes (10 KB)
- **Configuration**: `max-patch-size` (in bytes)
- Validated during config parsing (Go layer)
Expand Down