Skip to content

[plan] Move cache-memory and repo-memory restore before user steps: in agent job #43943

Description

@github-actions

Objective

Reorder step emission in the compiler so that `cache-memory` and `repo-memory` restore steps run before the user's frontmatter `steps:` block in the compiled agent job. This allows deterministic `steps:` code to read memory without requiring an LLM turn.

Context

Issue #43924 identifies that all three memory stores are currently materialized after custom user steps run. In `pkg/workflow/compiler_yaml_main_job.go`, the function `generateRuntimeAndWorkspaceSetupSteps` calls `emitCustomSteps` (line 227) before `generateCacheMemorySteps` (line 235) and `generateRepoMemorySteps` (line 239).

This means a frontmatter `steps:` block reads empty `/tmp/gh-aw/cache-memory/` and `/tmp/gh-aw/repo-memory/` directories, forcing authors to duplicate state via raw `actions/cache`.

Implementation Plan

Implementation Plan

Files to Modify

  • `pkg/workflow/compiler_yaml_main_job.go` — move `generateCacheMemorySteps` and `generateRepoMemorySteps` calls to before `emitCustomSteps`
  • `pkg/workflow/compiler_yaml_main_job_test.go` (or new test file) — add tests verifying restore steps precede custom steps in generated YAML

Approach

  1. In `generateRuntimeAndWorkspaceSetupSteps`, move the `generateCacheMemorySteps(yaml, data)` and `generateRepoMemorySteps(yaml, data)` calls so they emit before the `c.emitCustomSteps(...)` call.
  2. Verify the DIFC proxy is already running by this point (it is — `generateStartDIFCProxyStep` runs before both custom steps and memory steps already), so memory restore steps can safely use `gh` if needed.
  3. Confirm that `generateCacheMemorySteps` / `generateRepoMemorySteps` have no dependencies on state set by custom steps (e.g., environment variables, checked-out code).
  4. Update or add tests in `pkg/workflow/cache_memory_syntax_test.go` and related files to assert the ordering of restore steps vs. custom steps in the generated YAML.

Expected step order after change

  1. Create gh-aw temp directory
  2. Configure gh CLI for GitHub Enterprise
  3. Start DIFC proxy (if applicable)
  4. cache-memory restore steps ← moved up
  5. repo-memory clone steps ← moved up
  6. User custom `steps:` block
  7. (rest of agent job...)

Acceptance Criteria

  • `/tmp/gh-aw/cache-memory//` directory is populated before any user `steps:` run
  • `/tmp/gh-aw/repo-memory//` directory is populated before any user `steps:` run
  • Existing cache-memory and repo-memory tests continue to pass (`make test`)
  • New or updated test asserts the correct ordering in generated YAML
  • `make recompile` passes for any affected workflow markdown files

Generated by 📋 Plan Command · 79.6 AIC · ⌖ 11.7 AIC · ⊞ 4.7K ·
Comment /plan to run again

  • expires on Jul 8, 2026, 10:39 PM UTC-08:00

Metadata

Metadata

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions