You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>By the end of this chapter you can <strong>cap, meter, and gate</strong> agentic spend — with <code>max-ai-credits</code> per-workflow budgets and org-wide defaults — and set the policy that keeps a fleet affordable and compliant as it grows.</p>
8
-
<p>Everything targets <strong>gh aw v0.81.6</strong>. We put a hard budget on the Repo Assistant and show how an org enforces the same limits across every repo at once.</p>
7
+
<p>By the end of this chapter you can <strong>cap, meter, and gate</strong> agentic spend — with <code>max-ai-credits</code> per-workflow budgets and org-wide defaults — and set the policy that keeps a fleet affordable and compliant as it grows. That policy surface extends past cost to the agent's <em>supply chain</em>: which skills and prompts your workflows are even allowed to consume.</p>
8
+
<p>Everything targets <strong>gh aw v0.81.6</strong>. We put a hard budget on the Repo Assistant and show how an org enforces the same limits — and the same approved dependency list — across every repo at once.</p>
9
9
</section>
10
10
11
11
<sectiondata-slot="concept-agentic-work-has-a-budget-and-a-policy-surface" data-title="Concept: agentic work has a budget and a policy surface">
@@ -47,6 +47,28 @@ <h3>Org-wide defaults and policy</h3>
47
47
<pclass="callout-title">Builder detail: the recommended rollout</p>
48
48
<p>The docs prescribe a layered rollout: <em>enterprise baseline → org where needed → repo exceptions → rare, explicit frontmatter overrides.</em> Preview any change with <code>gh aw env update … --dry-run</code> before applying. Most repos stay aligned to the baseline; exceptions are deliberate and visible.</p>
49
49
</aside>
50
+
51
+
<h3>Governing the agent supply chain (APM)</h3>
52
+
<p>Budgets and policy variables govern <em>spend</em> and <em>capabilities</em>. A third surface is the <em>dependency</em> supply chain from <aclass="xref" href="reuse-and-memory.html">Chapter 11</a>: the skills, prompts, and plugins an agent consumes are executable context, so an unreviewed one is an injection vector — exactly the <aclass="xref" href="defense-in-depth.html">Chapter 7</a> threat model. The <strong>Agent Package Manager (APM)</strong> “treats agent skills as packages with the same governance primitives that enterprises require for code dependencies” (<ahref="https://learn.github.com/well-architected/governance/recommendations/governing-agentic-workflows">Governing agentic workflows</a>).</p>
53
+
<p>Three controls turn that supply chain into a governed surface:</p>
54
+
<ul>
55
+
<li><strong>Pinning & scanning.</strong> Every package is pinned to an exact commit SHA in an <code>apm.lock.yaml</code> so “there is no drift between what was reviewed and what actually runs,” and install-time scanning flags “hidden Unicode threats like homoglyphs, bidirectional override characters, and zero-width joiners” that could smuggle invisible instructions into a prompt (<ahref="https://learn.github.com/well-architected/governance/recommendations/governing-agentic-workflows">Governing agentic workflows</a>).</li>
56
+
<li><strong>Org-level allowlists.</strong> An <code>apm-policy.yml</code> in the org's <code>.github</code> repository controls which packages any repo may consume. Inheritance is <em>tighten-only</em> across enterprise → org → repo — children “can narrow allowlists, add deny entries, and escalate enforcement, but… cannot relax constraints set by a parent” — the same percolation model as your cost defaults, applied to dependencies.</li>
57
+
<li><strong>Isolation.</strong> Importing a skill with <code>isolated: true</code> means “the agent sees only the skill's packaged instructions,” so a compromised repo-level <code>AGENTS.md</code> or <code>copilot-instructions.md</code> cannot silently override a security skill's rules (<ahref="https://learn.github.com/well-architected/governance/recommendations/governing-agentic-workflows">Governing agentic workflows</a>).</li>
58
+
</ul>
59
+
<figureclass="code">
60
+
<figcaption>Illustrative: an org-wide dependency allowlist in <code>.github/apm-policy.yml</code></figcaption>
<p>Together — lockfile + org policy + isolation — these give a platform team a complete answer to the compliance question “show me exactly what instructions the agent followed, at what version.” Air-gapped shops can go further and route all downloads through a corporate scanning proxy (<code>PROXY_REGISTRY_ONLY=1</code>) so nothing is fetched directly from GitHub (<ahref="https://learn.github.com/well-architected/governance/recommendations/governing-agentic-workflows">Governing agentic workflows</a>).</p>
50
72
</section>
51
73
52
74
<sectiondata-slot="when-to-cap-meter-and-gate-cost-and-risk-trade-offs" data-title="When to cap, meter, and gate (cost and risk trade-offs)">
@@ -60,6 +82,7 @@ <h3>Org-wide defaults and policy</h3>
60
82
<tr><td>an occasional deep task (refactor)</td><td>a higher per-run budget, no aggressive daily cap</td></tr>
<li><strong>Don't set org defaults so tight that every repo overrides them.</strong> If exceptions become the norm, the baseline is wrong. The goal is most repos aligned, few exceptions.</li>
70
93
<li><strong>Don't rely on budgets for security.</strong> A budget limits <em>spend</em>, not <em>blast radius</em> — that's still safe outputs, the firewall, and policy gates (Chapters 6–8). Cost controls and security controls are complementary.</li>
71
94
<li><strong>Don't govern by editing workflows.</strong> At scale, prefer <code>gh aw env</code> defaults and <code>GH_AW_POLICY_*</code> gates — central, reviewable, and applied without recompiling every repo.</li>
95
+
<li><strong>Don't let agents pull skills you haven't approved.</strong> An unpinned, unscanned skill package is an ungoverned instruction source; set an <code>apm-policy.yml</code> allowlist and require pinned constraints before you widen a fleet, not after.</li>
72
96
</ul>
73
97
</section>
74
98
@@ -126,6 +150,7 @@ <h3>When <em>not</em> to</h3>
126
150
<li>Agentic work has a <strong>variable cost</strong> and, at scale, a <strong>policy surface</strong> — FinOps and governance now apply to your agents.</li>
127
151
<li>Per-workflow: <code>max-ai-credits</code> (default 1000, steering at 80/90/95/99%), <code>max-daily-ai-credits</code> (fail-safe daily cap), <code>timeout-minutes</code>, and <code>stop-after</code>.</li>
128
152
<li>Org-wide: <code>gh aw env</code> sets <code>GH_AW_DEFAULT_*</code> defaults that <strong>percolate</strong> (frontmatter → repo → org → enterprise), and <code>GH_AW_POLICY_*</code> variables <strong>gate capabilities</strong> without recompiling.</li>
153
+
<li>Supply chain: <strong>APM</strong> governs <em>which</em> skills a fleet may use — SHA-pinned <code>apm.lock.yaml</code>, install-time Unicode scanning, a tighten-only <code>apm-policy.yml</code> allowlist, and <code>isolated: true</code> imports that repo config can't override.</li>
129
154
<li>Tune budgets to the work, roll out defaults in layers, and remember budgets limit <em>spend</em>, not <em>blast radius</em>.</li>
130
155
</ul>
131
156
<p><strong>What's next.</strong> You can now build, secure, operate, and govern agentic workflows. The final chapter zooms all the way out: <aclass="xref" href="fleets-and-adoption.html">Chapter 14: Fleets & Adoption</a> takes the Repo Assistant from one repo to a multi-repo fleet and lays out the enterprise adoption playbook.</p>
Copy file name to clipboardExpand all lines: content/chapters/reuse-and-memory.html
+17Lines changed: 17 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,21 @@ <h3>Imports and shared components</h3>
33
33
</figure>
34
34
<p>Paths resolve three ways: <strong>relative</strong> to the workflow, <strong>repo-root</strong> (<code>.github/…</code>), or <strong>cross-repo</strong> as <code>owner/repo/path@ref</code> — and cross-repo imports are “pinned to a semantic tag, branch, or commit SHA” and cached for offline compiles (<ahref="https://github.github.com/gh-aw/reference/imports/">Imports</a>). Fields merge sensibly: tool allowlists concatenate and dedupe; each safe-output type is defined once, with the main workflow winning on conflict.</p>
35
35
36
+
<h3>Packaging dependencies: the Agent Package Manager (APM)</h3>
37
+
<p>Imports compose files you write. But agents increasingly depend on <em>published</em> primitives — skills, prompts, instructions, sub-agents, hooks, and plugins — that live in other repositories and evolve on their own cadence. The <strong>Agent Package Manager (APM)</strong> “manages AI agent primitives… Packages can depend on other packages and APM resolves the full dependency tree” (<ahref="https://github.github.com/gh-aw/reference/dependencies/">APM Dependencies</a>). It is the same DRY instinct as a shared component, but for the agent's <em>context</em> rather than its config — a real package manager for agent intelligence.</p>
38
+
<p>APM plugs into gh-aw through exactly the mechanism you just learned: you import a shared file, <code>shared/apm.md</code>, and pass it the packages you want. That import “adds a dedicated <code>apm</code> job” that resolves and packs the packages into a bundle at build time, which the agent job unpacks “for deterministic startup” (<ahref="https://github.github.com/gh-aw/reference/dependencies/">APM Dependencies</a>).</p>
39
+
<figureclass="code">
40
+
<figcaption>Illustrative: depend on published skills via the <code>shared/apm.md</code> import</figcaption>
41
+
<pre><codeclass="language-yaml">imports:
42
+
- uses: shared/apm.md # vendored from microsoft/apm via `gh aw add`
43
+
with:
44
+
packages:
45
+
- microsoft/apm-sample-package # a full package
46
+
- github/awesome-copilot/skills/review-and-refactor # one primitive
47
+
- anthropics/skills/skills/frontend-design#v2.0 # pinned to a tag</code></pre>
48
+
</figure>
49
+
<p>Each entry is a package reference in one of three shapes: <code>owner/repo</code> (a full package), <code>owner/repo/path</code> (a single primitive such as one skill), or <code>owner/repo#ref</code> (pinned to a tag, branch, or SHA) (<ahref="https://github.github.com/gh-aw/reference/dependencies/">APM Dependencies</a>). Reproducibility is the point: an <code>apm.lock</code> file “pin[s] every package to an exact commit SHA, so the same versions are installed on every run,” and those lock diffs “appear in pull requests and are reviewable before merge” — an audit trail for exactly which agent context is in use. That reviewable, pinnable supply chain is what makes APM <em>governable</em> at org scale, which we return to in <aclass="xref" href="governance-and-finops.html">Chapter 13</a>.</p>
50
+
36
51
<h3>Repo memory vs. cache memory</h3>
37
52
<p>Persistence comes in two flavors, and choosing correctly matters. <strong>Repo memory</strong> gives “persistent file storage via Git branches with unlimited retention” — enable it with <code>tools: repo-memory: true</code> and the compiler auto-configures a <code>memory/default</code> branch that files “auto-commit/push after workflow completion” (<ahref="https://github.github.com/gh-aw/reference/repo-memory/">Repo Memory</a>). <strong>Cache memory</strong> uses the GitHub Actions cache instead — fast, but 7-day retention and no version control.</p>
38
53
<table>
@@ -68,6 +83,7 @@ <h3>Repo memory vs. cache memory</h3>
68
83
<h3>When <em>not</em> to</h3>
69
84
<ul>
70
85
<li><strong>Don't track a moving branch for cross-repo imports.</strong> Pin to a tag or SHA (<code>@v2.1.0</code>), not <code>@main</code> — an unpinned import is a supply-chain risk, the same lesson as unpinned engine versions in <aclass="xref" href="engines.html">Chapter 5</a>.</li>
86
+
<li><strong>Don't consume APM packages unpinned or unreviewed.</strong> A skill is executable context: commit the <code>apm.lock</code>, review its diffs, and pin references. Skills you don't control are exactly where the <aclass="xref" href="defense-in-depth.html">Chapter 7</a> threat model applies — govern them (Chapter 13), don't trust them by default.</li>
71
87
<li><strong>Don't put secrets in memory.</strong> Repo memory follows repository permissions and lives in a branch; “don't store sensitive data in repo memory.” Keep secrets in Actions secrets, always.</li>
72
88
<li><strong>Don't reach for repo memory when cache memory fits.</strong> Session-only scratch state doesn't need an unlimited, version-controlled branch — use the faster 7-day cache.</li>
73
89
<li><strong>Don't over-abstract.</strong> A shared component with fifteen parameters is harder to reason about than two honest copies. Share the stable core; let the edges vary.</li>
@@ -127,6 +143,7 @@ <h3>When <em>not</em> to</h3>
127
143
<ul>
128
144
<li>As you scale to many repos, factor common intent into <strong>shared components</strong> — files without <code>on:</code> that others <code>import</code>.</li>
129
145
<li>Imports resolve <strong>relative</strong>, <strong>repo-root</strong>, or <strong>cross-repo</strong> (<code>owner/repo/path@ref</code>, pinned); fields merge, and <code>import-schema</code> allows typed parameters.</li>
146
+
<li>The <strong>Agent Package Manager (APM)</strong> rides the same import mechanism (<code>shared/apm.md</code> + <code>packages:</code>) to depend on published skills/prompts/plugins, pinned to exact SHAs in an <code>apm.lock</code> for reproducible, reviewable builds.</li>
130
147
<li><strong>Repo memory</strong> (Git branches, unlimited, versioned) vs. <strong>cache memory</strong> (Actions cache, 7-day, fast) give the agent persistence across runs.</li>
131
148
<li>Follow the <strong>rule of three</strong>, <strong>pin</strong> cross-repo imports, and never store secrets in memory.</li>
| 8 | II | Builder | Tools & MCP: Real Capabilities, Governed | Add governed capabilities via `tools:` and MCP servers |`tools:`; MCP servers; MCP gateway; built-in tools; tool permissions | 7 |
31
31
| 9 | II | Both | Continuous Triage & Docs: Reading the Room | Ship the Triage and Docs patterns as mini-products | Continuous Triage; Continuous Docs; scheduled+event triggers; agentics samples | 6, 8 |
32
32
| 10 | II | Both | Continuous Review, Testing & CI-Doctor | Close the quality loop with review/test/heal patterns | Review; Testing; CI-Doctor; Refactoring; `pull_request` triggers | 9 |
33
-
| 11 | III | Builder | Reuse & Memory: Shared Components and Repo Knowledge | Factor shared intent via `imports:` and add persistent memory |`imports:`; shared components; memory/persistence; AGENTS.md | 10 |
33
+
| 11 | III | Builder | Reuse & Memory: Shared Components and Repo Knowledge | Factor shared intent via `imports:` and add persistent memory |`imports:`; shared components; APM dependencies (`shared/apm.md`); memory/persistence; AGENTS.md | 10 |
34
34
| 12 | III | Both | Trust & Operate: Observability and Debugging | Inspect, debug, and audit runs to trust the fleet |`gh aw logs`; `gh aw audit`; OpenTelemetry; run summaries; HITL review | 11 |
35
-
| 13 | III | Leader | Governance & FinOps: Policy and Cost at Scale | Cap, meter, and gate agentic spend and set org policy |`max-ai-credits`; AI Credits; token efficiency; governance/policy | 12 |
35
+
| 13 | III | Leader | Governance & FinOps: Policy and Cost at Scale | Cap, meter, and gate agentic spend and set org policy |`max-ai-credits`; AI Credits; token efficiency; governance/policy; APM supply-chain governance (`apm-policy.yml`)| 12 |
36
36
| 14 | III | Leader | Fleets & Adoption: From One Repo to the Org | Scale into a governed multi-repo fleet with a rollout playbook | multi-repo fleets; dispatcher pattern; cross-repo composition; adoption playbook | 13 |
37
37
38
38
**Parts (maturity arc):****Part I — The Individual** (chs 1–5) · **Part II — The Team** (chs 6–10) ·
0 commit comments