hive-skills 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +235 -0
  3. package/assets/LICENSE +32 -0
  4. package/assets/THIRD_PARTY_NOTICES.md +72 -0
  5. package/assets/manifest.json +1290 -0
  6. package/assets/skills/authored/code-review/composable/BUNDLE.md +192 -0
  7. package/assets/skills/authored/code-review/composable/INDEX.md +13 -0
  8. package/assets/skills/authored/code-review/composable/VERSION +1 -0
  9. package/assets/skills/authored/code-review/composable/mini/01-review-method.md +34 -0
  10. package/assets/skills/authored/code-review/composable/mini/02-security-review.md +20 -0
  11. package/assets/skills/authored/code-review/composable/mini/03-correctness-bugs.md +19 -0
  12. package/assets/skills/authored/code-review/composable/mini/04-concurrency.md +16 -0
  13. package/assets/skills/authored/code-review/composable/mini/05-error-handling.md +12 -0
  14. package/assets/skills/authored/code-review/composable/mini/06-performance.md +11 -0
  15. package/assets/skills/authored/code-review/composable/mini/07-api-design.md +20 -0
  16. package/assets/skills/authored/code-review/composable/mini/08-missing-tests.md +25 -0
  17. package/assets/skills/authored/code-review/composable/mini/09-refactoring-and-communication.md +32 -0
  18. package/assets/skills/authored/data-analysis/composable/BUNDLE.md +186 -0
  19. package/assets/skills/authored/data-analysis/composable/INDEX.md +13 -0
  20. package/assets/skills/authored/data-analysis/composable/VERSION +1 -0
  21. package/assets/skills/authored/data-analysis/composable/mini/01-data-quality-profiling.md +26 -0
  22. package/assets/skills/authored/data-analysis/composable/mini/02-aggregation-pitfalls.md +21 -0
  23. package/assets/skills/authored/data-analysis/composable/mini/03-time-series.md +19 -0
  24. package/assets/skills/authored/data-analysis/composable/mini/04-segmentation.md +23 -0
  25. package/assets/skills/authored/data-analysis/composable/mini/05-discount-pricing.md +17 -0
  26. package/assets/skills/authored/data-analysis/composable/mini/06-insight-generation.md +25 -0
  27. package/assets/skills/authored/data-analysis/composable/mini/07-executive-writing.md +26 -0
  28. package/assets/skills/authored/data-analysis/composable/mini/08-recommendations.md +20 -0
  29. package/assets/skills/authored/data-analysis/composable/mini/09-reproducibility-assumptions.md +20 -0
  30. package/assets/skills/authored/financial-analysis/composable/BUNDLE.md +1293 -0
  31. package/assets/skills/authored/financial-analysis/composable/INDEX.md +17 -0
  32. package/assets/skills/authored/financial-analysis/composable/VERSION +1 -0
  33. package/assets/skills/authored/financial-analysis/composable/mini/00-core.md +69 -0
  34. package/assets/skills/authored/financial-analysis/composable/mini/01-profitability-efficiency-ratios.md +173 -0
  35. package/assets/skills/authored/financial-analysis/composable/mini/02-liquidity-leverage-ratios.md +120 -0
  36. package/assets/skills/authored/financial-analysis/composable/mini/03-valuation-ratios-interpretation.md +107 -0
  37. package/assets/skills/authored/financial-analysis/composable/mini/04-dcf-projection-wacc.md +122 -0
  38. package/assets/skills/authored/financial-analysis/composable/mini/05-dcf-terminal-value-sensitivity.md +75 -0
  39. package/assets/skills/authored/financial-analysis/composable/mini/06-comparables-precedents.md +78 -0
  40. package/assets/skills/authored/financial-analysis/composable/mini/07-budget-variance-analysis.md +47 -0
  41. package/assets/skills/authored/financial-analysis/composable/mini/08-driver-based-forecasting-scenarios.md +111 -0
  42. package/assets/skills/authored/financial-analysis/composable/mini/09-rolling-forecasts-accuracy.md +114 -0
  43. package/assets/skills/authored/financial-analysis/composable/mini/10-reporting-exec-summary.md +58 -0
  44. package/assets/skills/authored/financial-analysis/composable/mini/11-industry-adaptations.md +130 -0
  45. package/assets/skills/authored/financial-analysis/composable/mini/12-toolkit-scripts-io.md +102 -0
  46. package/assets/skills/authored/python-api/composable/BUNDLE.md +389 -0
  47. package/assets/skills/authored/python-api/composable/INDEX.md +13 -0
  48. package/assets/skills/authored/python-api/composable/VERSION +1 -0
  49. package/assets/skills/authored/python-api/composable/mini/01-project-structure.md +44 -0
  50. package/assets/skills/authored/python-api/composable/mini/02-routing-and-app.md +38 -0
  51. package/assets/skills/authored/python-api/composable/mini/03-pydantic-models.md +45 -0
  52. package/assets/skills/authored/python-api/composable/mini/04-validation-and-errors.md +59 -0
  53. package/assets/skills/authored/python-api/composable/mini/05-dependencies-and-auth.md +60 -0
  54. package/assets/skills/authored/python-api/composable/mini/06-pagination-filtering.md +44 -0
  55. package/assets/skills/authored/python-api/composable/mini/07-async-performance.md +30 -0
  56. package/assets/skills/authored/python-api/composable/mini/08-testing.md +45 -0
  57. package/assets/skills/authored/python-api/composable/mini/09-middleware-observability.md +29 -0
  58. package/assets/skills/authored/tech-writing/composable/BUNDLE.md +220 -0
  59. package/assets/skills/authored/tech-writing/composable/INDEX.md +12 -0
  60. package/assets/skills/authored/tech-writing/composable/VERSION +1 -0
  61. package/assets/skills/authored/tech-writing/composable/mini/01-audience-analysis.md +26 -0
  62. package/assets/skills/authored/tech-writing/composable/mini/02-document-types.md +27 -0
  63. package/assets/skills/authored/tech-writing/composable/mini/03-readme-quickstart-changelog.md +22 -0
  64. package/assets/skills/authored/tech-writing/composable/mini/04-information-architecture.md +21 -0
  65. package/assets/skills/authored/tech-writing/composable/mini/05-style-clarity.md +29 -0
  66. package/assets/skills/authored/tech-writing/composable/mini/06-breaking-changes-migrations.md +33 -0
  67. package/assets/skills/authored/tech-writing/composable/mini/07-troubleshooting-security.md +30 -0
  68. package/assets/skills/authored/tech-writing/composable/mini/08-faq-voice-tone.md +32 -0
  69. package/assets/skills/converted/claude-api/composable/BUNDLE.md +14996 -0
  70. package/assets/skills/converted/claude-api/composable/INDEX.md +98 -0
  71. package/assets/skills/converted/claude-api/composable/VERSION +1 -0
  72. package/assets/skills/converted/claude-api/composable/mini/00-core.md +235 -0
  73. package/assets/skills/converted/claude-api/composable/mini/01-model-api-quick-reference.md +258 -0
  74. package/assets/skills/converted/claude-api/composable/mini/02-common-pitfalls.md +42 -0
  75. package/assets/skills/converted/claude-api/composable/mini/10-models.md +135 -0
  76. package/assets/skills/converted/claude-api/composable/mini/11-platform-availability.md +96 -0
  77. package/assets/skills/converted/claude-api/composable/mini/12-claude-platform-on-aws.md +59 -0
  78. package/assets/skills/converted/claude-api/composable/mini/13-live-sources.md +143 -0
  79. package/assets/skills/converted/claude-api/composable/mini/14-error-codes.md +256 -0
  80. package/assets/skills/converted/claude-api/composable/mini/15-prompt-caching.md +223 -0
  81. package/assets/skills/converted/claude-api/composable/mini/16-token-counting.md +56 -0
  82. package/assets/skills/converted/claude-api/composable/mini/17-tool-use-concepts.md +444 -0
  83. package/assets/skills/converted/claude-api/composable/mini/18-agent-design.md +101 -0
  84. package/assets/skills/converted/claude-api/composable/mini/19-anthropic-cli.md +246 -0
  85. package/assets/skills/converted/claude-api/composable/mini/20-model-migration.md +1301 -0
  86. package/assets/skills/converted/claude-api/composable/mini/30-managed-agents-overview.md +71 -0
  87. package/assets/skills/converted/claude-api/composable/mini/31-managed-agents-core.md +278 -0
  88. package/assets/skills/converted/claude-api/composable/mini/32-managed-agents-environments.md +219 -0
  89. package/assets/skills/converted/claude-api/composable/mini/33-managed-agents-tools.md +366 -0
  90. package/assets/skills/converted/claude-api/composable/mini/34-managed-agents-events.md +252 -0
  91. package/assets/skills/converted/claude-api/composable/mini/35-managed-agents-outcomes.md +106 -0
  92. package/assets/skills/converted/claude-api/composable/mini/36-managed-agents-multiagent.md +101 -0
  93. package/assets/skills/converted/claude-api/composable/mini/37-managed-agents-webhooks.md +123 -0
  94. package/assets/skills/converted/claude-api/composable/mini/38-managed-agents-memory.md +197 -0
  95. package/assets/skills/converted/claude-api/composable/mini/39-managed-agents-scheduled-deployments.md +146 -0
  96. package/assets/skills/converted/claude-api/composable/mini/40-managed-agents-client-patterns.md +211 -0
  97. package/assets/skills/converted/claude-api/composable/mini/41-managed-agents-onboarding.md +82 -0
  98. package/assets/skills/converted/claude-api/composable/mini/42-managed-agents-api-reference.md +441 -0
  99. package/assets/skills/converted/claude-api/composable/mini/43-managed-agents-self-hosted-sandboxes.md +174 -0
  100. package/assets/skills/converted/claude-api/composable/mini/50-python-readme.md +564 -0
  101. package/assets/skills/converted/claude-api/composable/mini/51-python-tool-use.md +590 -0
  102. package/assets/skills/converted/claude-api/composable/mini/52-python-streaming-batches-files.md +549 -0
  103. package/assets/skills/converted/claude-api/composable/mini/53-python-managed-agents.md +335 -0
  104. package/assets/skills/converted/claude-api/composable/mini/55-typescript-readme.md +404 -0
  105. package/assets/skills/converted/claude-api/composable/mini/56-typescript-tool-use.md +548 -0
  106. package/assets/skills/converted/claude-api/composable/mini/57-typescript-streaming-batches-files.md +384 -0
  107. package/assets/skills/converted/claude-api/composable/mini/58-typescript-managed-agents.md +358 -0
  108. package/assets/skills/converted/claude-api/composable/mini/60-csharp-readme.md +361 -0
  109. package/assets/skills/converted/claude-api/composable/mini/61-csharp-tool-use.md +163 -0
  110. package/assets/skills/converted/claude-api/composable/mini/62-csharp-streaming-batches-files.md +64 -0
  111. package/assets/skills/converted/claude-api/composable/mini/65-go-readme.md +185 -0
  112. package/assets/skills/converted/claude-api/composable/mini/66-go-tool-use.md +219 -0
  113. package/assets/skills/converted/claude-api/composable/mini/67-go-streaming-files.md +63 -0
  114. package/assets/skills/converted/claude-api/composable/mini/68-go-managed-agents.md +564 -0
  115. package/assets/skills/converted/claude-api/composable/mini/70-java-readme.md +237 -0
  116. package/assets/skills/converted/claude-api/composable/mini/71-java-tool-use.md +227 -0
  117. package/assets/skills/converted/claude-api/composable/mini/72-java-streaming-files.md +49 -0
  118. package/assets/skills/converted/claude-api/composable/mini/73-java-managed-agents.md +443 -0
  119. package/assets/skills/converted/claude-api/composable/mini/75-php-readme.md +173 -0
  120. package/assets/skills/converted/claude-api/composable/mini/76-php-tool-use.md +252 -0
  121. package/assets/skills/converted/claude-api/composable/mini/77-php-streaming-batches-files.md +53 -0
  122. package/assets/skills/converted/claude-api/composable/mini/78-php-managed-agents.md +443 -0
  123. package/assets/skills/converted/claude-api/composable/mini/80-ruby-readme.md +133 -0
  124. package/assets/skills/converted/claude-api/composable/mini/81-ruby-tool-use-streaming.md +56 -0
  125. package/assets/skills/converted/claude-api/composable/mini/82-ruby-managed-agents.md +394 -0
  126. package/assets/skills/converted/claude-api/composable/mini/85-curl-examples.md +255 -0
  127. package/assets/skills/converted/claude-api/composable/mini/86-curl-managed-agents.md +340 -0
  128. package/assets/skills/converted/claude-api/composable/presets/csharp.md +1151 -0
  129. package/assets/skills/converted/claude-api/composable/presets/curl.md +1154 -0
  130. package/assets/skills/converted/claude-api/composable/presets/go.md +1598 -0
  131. package/assets/skills/converted/claude-api/composable/presets/java.md +1523 -0
  132. package/assets/skills/converted/claude-api/composable/presets/php.md +1488 -0
  133. package/assets/skills/converted/claude-api/composable/presets/python.md +2605 -0
  134. package/assets/skills/converted/claude-api/composable/presets/ruby.md +1146 -0
  135. package/assets/skills/converted/claude-api/composable/presets/shared.md +6478 -0
  136. package/assets/skills/converted/claude-api/composable/presets/typescript.md +2261 -0
  137. package/assets/skills/converted/docx/composable/BUNDLE.md +617 -0
  138. package/assets/skills/converted/docx/composable/INDEX.md +12 -0
  139. package/assets/skills/converted/docx/composable/VERSION +1 -0
  140. package/assets/skills/converted/docx/composable/mini/00-core.md +26 -0
  141. package/assets/skills/converted/docx/composable/mini/01-reading-converting.md +36 -0
  142. package/assets/skills/converted/docx/composable/mini/02-creating-setup-layout.md +85 -0
  143. package/assets/skills/converted/docx/composable/mini/03-creating-elements.md +257 -0
  144. package/assets/skills/converted/docx/composable/mini/04-editing-existing.md +57 -0
  145. package/assets/skills/converted/docx/composable/mini/05-xml-reference.md +128 -0
  146. package/assets/skills/converted/internal-comms/composable/BUNDLE.md +220 -0
  147. package/assets/skills/converted/internal-comms/composable/INDEX.md +11 -0
  148. package/assets/skills/converted/internal-comms/composable/VERSION +1 -0
  149. package/assets/skills/converted/internal-comms/composable/mini/00-core.md +30 -0
  150. package/assets/skills/converted/internal-comms/composable/mini/01-3p-updates.md +49 -0
  151. package/assets/skills/converted/internal-comms/composable/mini/02-company-newsletter.md +67 -0
  152. package/assets/skills/converted/internal-comms/composable/mini/03-faq-answers.md +32 -0
  153. package/assets/skills/converted/internal-comms/composable/mini/04-general-comms.md +18 -0
  154. package/assets/skills/converted/mcp-builder/composable/BUNDLE.md +2460 -0
  155. package/assets/skills/converted/mcp-builder/composable/INDEX.md +23 -0
  156. package/assets/skills/converted/mcp-builder/composable/VERSION +1 -0
  157. package/assets/skills/converted/mcp-builder/composable/mini/00-core.md +43 -0
  158. package/assets/skills/converted/mcp-builder/composable/mini/01-workflow-research-planning.md +54 -0
  159. package/assets/skills/converted/mcp-builder/composable/mini/02-implementation-process.md +78 -0
  160. package/assets/skills/converted/mcp-builder/composable/mini/03-naming-conventions.md +33 -0
  161. package/assets/skills/converted/mcp-builder/composable/mini/04-response-formats.md +21 -0
  162. package/assets/skills/converted/mcp-builder/composable/mini/05-pagination.md +24 -0
  163. package/assets/skills/converted/mcp-builder/composable/mini/06-transport.md +47 -0
  164. package/assets/skills/converted/mcp-builder/composable/mini/07-annotations.md +20 -0
  165. package/assets/skills/converted/mcp-builder/composable/mini/08-security.md +35 -0
  166. package/assets/skills/converted/mcp-builder/composable/mini/09-error-handling.md +32 -0
  167. package/assets/skills/converted/mcp-builder/composable/mini/10-testing-and-documentation.md +21 -0
  168. package/assets/skills/converted/mcp-builder/composable/mini/11-python-implementation.md +432 -0
  169. package/assets/skills/converted/mcp-builder/composable/mini/12-python-advanced-and-checklist.md +233 -0
  170. package/assets/skills/converted/mcp-builder/composable/mini/13-node-implementation.md +717 -0
  171. package/assets/skills/converted/mcp-builder/composable/mini/14-node-advanced-and-checklist.md +200 -0
  172. package/assets/skills/converted/mcp-builder/composable/mini/15-evaluation-design.md +200 -0
  173. package/assets/skills/converted/mcp-builder/composable/mini/16-evaluation-running.md +198 -0
  174. package/assets/skills/converted/mcp-builder/composable/presets/node-server.md +1381 -0
  175. package/assets/skills/converted/mcp-builder/composable/presets/python-server.md +1129 -0
  176. package/assets/skills/converted/pdf/composable/BUNDLE.md +1284 -0
  177. package/assets/skills/converted/pdf/composable/INDEX.md +14 -0
  178. package/assets/skills/converted/pdf/composable/VERSION +1 -0
  179. package/assets/skills/converted/pdf/composable/mini/00-core.md +46 -0
  180. package/assets/skills/converted/pdf/composable/mini/01-creation.md +176 -0
  181. package/assets/skills/converted/pdf/composable/mini/02-extraction.md +178 -0
  182. package/assets/skills/converted/pdf/composable/mini/03-merge-split-manipulate.md +240 -0
  183. package/assets/skills/converted/pdf/composable/mini/04-images-ocr.md +168 -0
  184. package/assets/skills/converted/pdf/composable/mini/05-encryption.md +51 -0
  185. package/assets/skills/converted/pdf/composable/mini/06-forms.md +300 -0
  186. package/assets/skills/converted/pdf/composable/mini/07-libraries-reference.md +89 -0
  187. package/assets/skills/converted/pptx/composable/BUNDLE.md +911 -0
  188. package/assets/skills/converted/pptx/composable/INDEX.md +12 -0
  189. package/assets/skills/converted/pptx/composable/VERSION +1 -0
  190. package/assets/skills/converted/pptx/composable/mini/00-core.md +37 -0
  191. package/assets/skills/converted/pptx/composable/mini/01-reading.md +37 -0
  192. package/assets/skills/converted/pptx/composable/mini/02-creating-from-scratch.md +422 -0
  193. package/assets/skills/converted/pptx/composable/mini/03-editing-templates.md +207 -0
  194. package/assets/skills/converted/pptx/composable/mini/04-design.md +89 -0
  195. package/assets/skills/converted/pptx/composable/mini/05-qa-and-rendering.md +91 -0
  196. package/assets/skills/converted/pptx/composable/presets/creating.md +659 -0
  197. package/assets/skills/converted/pptx/composable/presets/editing.md +485 -0
  198. package/assets/skills/converted/skill-creator/composable/BUNDLE.md +1681 -0
  199. package/assets/skills/converted/skill-creator/composable/INDEX.md +21 -0
  200. package/assets/skills/converted/skill-creator/composable/VERSION +1 -0
  201. package/assets/skills/converted/skill-creator/composable/mini/00-core.md +59 -0
  202. package/assets/skills/converted/skill-creator/composable/mini/01-creating-a-skill.md +27 -0
  203. package/assets/skills/converted/skill-creator/composable/mini/02-skill-writing-guide.md +71 -0
  204. package/assets/skills/converted/skill-creator/composable/mini/03-test-cases.md +21 -0
  205. package/assets/skills/converted/skill-creator/composable/mini/04-running-and-evaluating.md +128 -0
  206. package/assets/skills/converted/skill-creator/composable/mini/05-improving-the-skill.md +30 -0
  207. package/assets/skills/converted/skill-creator/composable/mini/06-blind-comparison.md +5 -0
  208. package/assets/skills/converted/skill-creator/composable/mini/07-description-optimization.md +74 -0
  209. package/assets/skills/converted/skill-creator/composable/mini/08-packaging.md +11 -0
  210. package/assets/skills/converted/skill-creator/composable/mini/09-environment-specific.md +38 -0
  211. package/assets/skills/converted/skill-creator/composable/mini/10-scripts-and-references.md +34 -0
  212. package/assets/skills/converted/skill-creator/composable/mini/11-json-schemas.md +414 -0
  213. package/assets/skills/converted/skill-creator/composable/mini/12-agent-grader.md +225 -0
  214. package/assets/skills/converted/skill-creator/composable/mini/13-agent-comparator.md +204 -0
  215. package/assets/skills/converted/skill-creator/composable/mini/14-agent-analyzer.md +276 -0
  216. package/assets/skills/converted/skill-creator/composable/presets/authoring.md +198 -0
  217. package/assets/skills/converted/skill-creator/composable/presets/evaluating.md +1334 -0
  218. package/assets/skills/converted/skill-creator/composable/presets/optimizing.md +160 -0
  219. package/assets/skills/converted/skill-creator/composable/presets.json +5 -0
  220. package/assets/skills/meta/ccs-skill-creator/composable/BUNDLE.md +465 -0
  221. package/assets/skills/meta/ccs-skill-creator/composable/INDEX.md +8 -0
  222. package/assets/skills/meta/ccs-skill-creator/composable/VERSION +1 -0
  223. package/assets/skills/meta/ccs-skill-creator/composable/mini/00-core.md +46 -0
  224. package/assets/skills/meta/ccs-skill-creator/composable/mini/01-create-new-skill.md +167 -0
  225. package/assets/skills/meta/ccs-skill-creator/composable/mini/02-convert-existing-skill.md +120 -0
  226. package/assets/skills/meta/ccs-skill-creator/composable/mini/03-review-and-maintain.md +112 -0
  227. package/assets/skills/sources/anthropic/PROVENANCE.md +3 -0
  228. package/assets/skills/sources/anthropic/claude-api/LICENSE.txt +202 -0
  229. package/assets/skills/sources/anthropic/docx/LICENSE.txt +30 -0
  230. package/assets/skills/sources/anthropic/internal-comms/LICENSE.txt +202 -0
  231. package/assets/skills/sources/anthropic/mcp-builder/LICENSE.txt +202 -0
  232. package/assets/skills/sources/anthropic/pdf/LICENSE.txt +30 -0
  233. package/assets/skills/sources/anthropic/pptx/LICENSE.txt +30 -0
  234. package/assets/skills/sources/anthropic/skill-creator/LICENSE.txt +202 -0
  235. package/assets/skills/sources/financial-analyst/PROVENANCE.md +1 -0
  236. package/assets/tools/hive.py +728 -0
  237. package/dist/cli.js +7494 -0
  238. package/package.json +40 -0
@@ -0,0 +1,106 @@
1
+ # Managed Agents — Outcomes
2
+
3
+ An **outcome** elevates a session from *conversation* to *work*: you state what "done" looks like, and the harness runs an iterate → grade → revise loop until the artifact meets the rubric, hits `max_iterations`, or is interrupted. A separate **grader** (independent context window) scores each iteration against your rubric and feeds per-criterion gaps back to the agent.
4
+
5
+ The SDK sets the `managed-agents-2026-04-01` beta header automatically on all `client.beta.sessions.*` calls; no additional header is required for outcomes.
6
+
7
+ ---
8
+
9
+ ## The `user.define_outcome` event
10
+
11
+ Outcomes are not a field on `sessions.create()`. You create a normal session, then send a `user.define_outcome` event. The agent starts working on receipt — **do not also send a `user.message`** to kick it off.
12
+
13
+ ```python
14
+ session = client.beta.sessions.create(
15
+ agent=AGENT_ID,
16
+ environment_id=ENVIRONMENT_ID,
17
+ title="Financial analysis on Costco",
18
+ )
19
+
20
+ client.beta.sessions.events.send(
21
+ session_id=session.id,
22
+ events=[
23
+ {
24
+ "type": "user.define_outcome",
25
+ "description": "Build a DCF model for Costco in .xlsx",
26
+ "rubric": {"type": "text", "content": RUBRIC_MD},
27
+ # or: "rubric": {"type": "file", "file_id": rubric.id}
28
+ "max_iterations": 5, # optional; default 3, max 20
29
+ }
30
+ ],
31
+ )
32
+ ```
33
+
34
+ | Field | Type | Notes |
35
+ |---|---|---|
36
+ | `type` | `"user.define_outcome"` | |
37
+ | `description` | string | The task. This is what the agent works toward — no separate `user.message` needed. |
38
+ | `rubric` | `{type: "text", content}` \| `{type: "file", file_id}` | **Required.** Markdown with explicit, independently gradeable criteria. Upload once via `client.beta.files.upload(...)` (beta `files-api-2025-04-14`) to reuse across sessions. |
39
+ | `max_iterations` | int | Optional. Default **3**, max **20**. |
40
+
41
+ The event is echoed back on the stream with a server-assigned `outcome_id` and `processed_at`.
42
+
43
+ > **Writing rubrics.** Use explicit, gradeable criteria ("CSV has a numeric `price` column"), not vibes ("data looks good") — the grader scores each criterion independently, so vague criteria produce noisy loops. If you don't have a rubric, have Claude analyze a known-good artifact and turn that analysis into one.
44
+
45
+ ---
46
+
47
+ ## Outcome-specific events
48
+
49
+ These appear on the standard event stream (`sessions.events.stream` / `.list`) alongside the usual `agent.*` / `session.*` events.
50
+
51
+ | Event | Payload highlights | Meaning |
52
+ |---|---|---|
53
+ | `span.outcome_evaluation_start` | `outcome_id`, `iteration` (0-indexed) | Grader began scoring iteration *N*. |
54
+ | `span.outcome_evaluation_ongoing` | `outcome_id` | Heartbeat while the grader runs. Grader reasoning is opaque — you see *that* it's working, not *what* it's thinking. |
55
+ | `span.outcome_evaluation_end` | `outcome_evaluation_start_id`, `outcome_id`, `iteration`, `result`, `explanation`, `usage` | Grader finished one iteration. `result` drives what happens next (table below). |
56
+
57
+ ### `span.outcome_evaluation_end.result`
58
+
59
+ | `result` | Next |
60
+ |---|---|
61
+ | `satisfied` | Session → `idle`. Terminal for this outcome. |
62
+ | `needs_revision` | Agent starts another iteration. |
63
+ | `max_iterations_reached` | No further grader cycles. Agent may run one final revision, then session → `idle`. |
64
+ | `failed` | Session → `idle`. Rubric fundamentally doesn't match the task (e.g. description and rubric contradict). |
65
+ | `interrupted` | Only emitted if `_start` had already fired before a `user.interrupt` arrived. |
66
+
67
+ ```json
68
+ {
69
+ "type": "span.outcome_evaluation_end",
70
+ "id": "sevt_01jkl...",
71
+ "outcome_evaluation_start_id": "sevt_01def...",
72
+ "outcome_id": "outc_01a...",
73
+ "result": "satisfied",
74
+ "explanation": "All 12 criteria met: revenue projections use 5 years of historical data, ...",
75
+ "iteration": 0,
76
+ "usage": { "input_tokens": 2400, "output_tokens": 350, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 1800 },
77
+ "processed_at": "2026-03-25T14:03:00Z"
78
+ }
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Checking status & retrieving deliverables
84
+
85
+ **Status** — either watch the stream for `span.outcome_evaluation_end`, or poll the session and read `outcome_evaluations`:
86
+
87
+ ```python
88
+ session = client.beta.sessions.retrieve(session.id)
89
+ for ev in session.outcome_evaluations:
90
+ print(f"{ev.outcome_id}: {ev.result}") # outc_01a...: satisfied
91
+ ```
92
+
93
+ **Deliverables** — the agent writes to `/mnt/session/outputs/`. Once idle, fetch via the Files API with `scope_id=session.id`. This is the same session-outputs mechanism documented in `shared/managed-agents-environments.md` → Session outputs (including the dual-beta-header requirement on `files.list`).
94
+
95
+ ---
96
+
97
+ ## Interaction rules & pitfalls
98
+
99
+ - **One outcome at a time.** Chain by sending the next `user.define_outcome` only after the previous one's terminal `span.outcome_evaluation_end` (`satisfied` / `max_iterations_reached` / `failed` / `interrupted`). The session retains history across chained outcomes.
100
+ - **Steering is allowed but optional.** You *may* send `user.message` events mid-outcome to nudge direction, but the agent already knows to keep working until terminal — don't send "keep going" prompts.
101
+ - **`user.interrupt` pauses the current outcome** — it marks `result: "interrupted"` and leaves the session `idle`, ready for a new outcome or conversational turn.
102
+ - **After terminal, the session is reusable** — continue conversationally or define a new outcome.
103
+ - **Outcome ≠ session-create field.** Don't put `outcome`, `rubric`, or `description` on `sessions.create()` — outcomes are always sent as a `user.define_outcome` event.
104
+ - **Idle-break gate is unchanged.** In your drain loop, keep using `event.type === 'session.status_idle' && event.stop_reason?.type !== 'requires_action'` — do **not** gate on `span.outcome_evaluation_end` alone (on `needs_revision` the session keeps running). See `shared/managed-agents-client-patterns.md` Pattern 5.
105
+
106
+ For the raw HTTP shapes and per-language SDK bindings beyond Python, WebFetch `https://platform.claude.com/docs/en/managed-agents/define-outcomes.md` (see `shared/live-sources.md`).
@@ -0,0 +1,101 @@
1
+ # Managed Agents — Multiagent Sessions
2
+
3
+ A coordinator agent can delegate to other agents within one session. All agents **share the container and filesystem**; each runs in its own **thread** — a context-isolated event stream with its own conversation history, model, system prompt, tools, MCP servers, and skills (from that agent's own config). Threads are persistent: the coordinator can send a follow-up to a subagent it called earlier and that subagent retains its prior turns.
4
+
5
+ The SDK sets the `managed-agents-2026-04-01` beta header automatically on all `client.beta.{agents,sessions}.*` calls; no additional header is required for multiagent.
6
+
7
+ ---
8
+
9
+ ## Declare the roster on the coordinator
10
+
11
+ `multiagent` is a **top-level field** on `agents.create()` / `agents.update()` — **not** a `tools[]` entry. `agents` lists 1–20 roster entries. Nothing changes on `sessions.create()` — the roster is resolved from the coordinator's config.
12
+
13
+ ```python
14
+ orchestrator = client.beta.agents.create(
15
+ name="Engineering Lead",
16
+ model="claude-opus-4-8",
17
+ system="You coordinate engineering work. Delegate code review to the reviewer and test writing to the test agent.",
18
+ tools=[{"type": "agent_toolset_20260401"}],
19
+ multiagent={
20
+ "type": "coordinator",
21
+ "agents": [
22
+ reviewer.id, # bare string — latest version
23
+ {"type": "agent", "id": test_writer.id, "version": 4}, # pinned version
24
+ {"type": "self"}, # the coordinator itself
25
+ ],
26
+ },
27
+ )
28
+
29
+ session = client.beta.sessions.create(agent=orchestrator.id, environment_id=env.id)
30
+ ```
31
+
32
+ | Roster entry | Shape | Notes |
33
+ |---|---|---|
34
+ | String shorthand | `"agent_abc123"` | References the latest version of a stored agent. |
35
+ | Agent reference | `{type: "agent", id, version?}` | Omit `version` to pin the latest at coordinator save time. |
36
+ | Self | `{type: "self"}` | The coordinator can spawn copies of itself. |
37
+
38
+ If the session was created with `agent_with_overrides` (see `shared/managed-agents-core.md` → Override agent configuration for a session), those overrides apply to the **coordinator and its `self` copies**. Roster agents referenced by ID always use their own as-created configuration — overrides do not propagate to them.
39
+
40
+ Up to **20 unique agents** in the roster; the coordinator may spawn **multiple copies** of each. **One level of delegation only** — depth > 1 is ignored.
41
+
42
+ ---
43
+
44
+ ## Threads
45
+
46
+ The session-level event stream is the **primary thread** — it shows the coordinator's trace plus a condensed view of subagent activity (thread status transitions and cross-thread messages, not every subagent tool call). Drill into a specific subagent via the per-thread endpoints:
47
+
48
+ | Operation | HTTP | SDK (`client.beta.sessions.threads.*`) |
49
+ |---|---|---|
50
+ | List threads | `GET /v1/sessions/{sid}/threads` | `.list(session_id)` |
51
+ | Retrieve one | `GET /v1/sessions/{sid}/threads/{tid}` | `.retrieve(thread_id, session_id=...)` |
52
+ | Archive | `POST /v1/sessions/{sid}/threads/{tid}/archive` | `.archive(thread_id, session_id=...)` |
53
+ | List thread events | `GET /v1/sessions/{sid}/threads/{tid}/events` | `.events.list(thread_id, session_id=...)` |
54
+ | Stream thread events | `GET /v1/sessions/{sid}/threads/{tid}/stream` | `.events.stream(thread_id, session_id=...)` |
55
+
56
+ Each `SessionThread` carries `id`, `status` (`running` | `idle` | `rescheduling` | `terminated`), `agent` (a resolved snapshot of the agent config — `id`, `name`, `model`, `system`, `tools`, `skills`, `mcp_servers`, `version`), `parent_thread_id` (null for the primary thread, which is included in the list), `archived_at`, and optional `stats`/`usage`. **Session status aggregates thread statuses** — if any thread is `running`, `session.status` is `running`. Max **25 concurrent threads**. When draining a per-thread stream, break on `session.thread_status_idle` (and check its `stop_reason` as you would for the session-level idle).
57
+
58
+ ---
59
+
60
+ ## Multiagent events (on the session stream)
61
+
62
+ | Event | Payload highlights | Meaning |
63
+ |---|---|---|
64
+ | `session.thread_created` | `session_thread_id`, `agent_name` | A new thread was created. |
65
+ | `session.thread_status_running` | `session_thread_id`, `agent_name` | Thread started activity. |
66
+ | `session.thread_status_idle` | `session_thread_id`, `agent_name`, **`stop_reason`** | Thread is awaiting input. Inspect `stop_reason` (same shape as `session.status_idle.stop_reason`). |
67
+ | `session.thread_status_rescheduled` | `session_thread_id`, `agent_name` | Thread is rescheduling after a retryable error. |
68
+ | `session.thread_status_terminated` | `session_thread_id`, `agent_name` | Thread was archived or hit a terminal error. |
69
+ | `agent.thread_message_sent` | `to_session_thread_id`, `to_agent_name`, `content` | Coordinator sent a follow-up to another thread. |
70
+ | `agent.thread_message_received` | `from_session_thread_id`, `from_agent_name`, `content` | An agent delivered its result to the coordinator. |
71
+
72
+ ---
73
+
74
+ ## Tool permissions and custom tools from subagent threads
75
+
76
+ When a subagent needs your client (an `always_ask` confirmation, or a custom tool result), the request is **cross-posted to the primary thread** with `session_thread_id` identifying the originating thread — so you only need to watch the session stream. Reply with `user.tool_confirmation` (carrying `tool_use_id`) or `user.custom_tool_result` (carrying `custom_tool_use_id`), and **echo the `session_thread_id` from the originating event** (the SDK param type and docstring expect it). The server also routes by the tool-use ID, so the echo is belt-and-suspenders rather than load-bearing — but include it.
77
+
78
+ ```python
79
+ for event_id in stop.event_ids:
80
+ pending = events_by_id[event_id]
81
+ confirmation = {
82
+ "type": "user.tool_confirmation",
83
+ "tool_use_id": event_id,
84
+ "result": "allow",
85
+ }
86
+ if pending.session_thread_id is not None:
87
+ confirmation["session_thread_id"] = pending.session_thread_id
88
+ client.beta.sessions.events.send(session.id, events=[confirmation])
89
+ ```
90
+
91
+ The same pattern applies to `user.custom_tool_result`.
92
+
93
+ ---
94
+
95
+ ## Pitfalls
96
+
97
+ - **Don't put the roster on `sessions.create()` or in `tools[]`.** `multiagent` is a top-level agent field; update the coordinator, then start a session that references it.
98
+ - **Don't assume shared context.** Threads share the filesystem but not conversation history or tools. If the coordinator needs a subagent to act on something, it must say so in the delegated message (or write it to disk).
99
+ - **Depth > 1 is ignored.** A subagent's own `multiagent` roster (if any) doesn't cascade — only the session's coordinator delegates.
100
+
101
+ For per-language bindings beyond Python, WebFetch `https://platform.claude.com/docs/en/managed-agents/multi-agent.md` (see `shared/live-sources.md`).
@@ -0,0 +1,123 @@
1
+ # Managed Agents — Webhooks
2
+
3
+ Anthropic can POST to your HTTPS endpoint when a Managed Agents resource changes state — an alternative to holding an SSE stream or polling. Payloads are **thin** (event type + resource IDs only); on receipt, fetch the resource for current state. Every delivery is HMAC-signed.
4
+
5
+ > **Direction matters.** This page covers *Anthropic → you* notifications about session/vault state. It does **not** cover *third-party → you* webhooks that *trigger* a session (e.g. a GitHub push handler that calls `sessions.create()`) — that's ordinary application code on your side with no Anthropic-specific wire format.
6
+
7
+ ---
8
+
9
+ ## Register an endpoint (Console only)
10
+
11
+ Console → **Manage → Webhooks**. There is no programmatic endpoint-management API yet. Secret rotation is supported from the same page.
12
+
13
+ | Field | Constraint |
14
+ |---|---|
15
+ | URL | HTTPS on port 443, publicly resolvable hostname |
16
+ | Event types | Subscribe per `data.type` — you only receive subscribed types (plus test events) |
17
+ | Signing secret | `whsec_`-prefixed, 32 bytes, **shown once at creation** — store it |
18
+
19
+ ---
20
+
21
+ ## Verify the signature
22
+
23
+ Every delivery is HMAC-signed. **Use the SDK's `client.beta.webhooks.unwrap()`** — it verifies the signature, rejects payloads more than ~5 minutes old, and returns the parsed event. It reads the `whsec_` secret from `ANTHROPIC_WEBHOOK_SIGNING_KEY`.
24
+
25
+ ```python
26
+ import anthropic
27
+ from flask import Flask, request
28
+
29
+ client = anthropic.Anthropic() # reads ANTHROPIC_WEBHOOK_SIGNING_KEY from env
30
+ app = Flask(__name__)
31
+
32
+
33
+ @app.route("/webhook", methods=["POST"])
34
+ def webhook():
35
+ try:
36
+ event = client.beta.webhooks.unwrap(
37
+ request.get_data(as_text=True),
38
+ headers=dict(request.headers),
39
+ )
40
+ except Exception:
41
+ return "invalid signature", 400
42
+
43
+ if event.id in seen_event_ids: # dedupe retries — id is per-event, not per-delivery
44
+ return "", 204
45
+ seen_event_ids.add(event.id)
46
+
47
+ match event.data.type:
48
+ case "session.status_idled":
49
+ session = client.beta.sessions.retrieve(event.data.id)
50
+ notify_user(session)
51
+ case "vault_credential.refresh_failed":
52
+ alert_oncall(event.data.id)
53
+
54
+ return "", 204
55
+ ```
56
+
57
+ Pass the **raw request body** to `unwrap()` — frameworks that re-serialize JSON (Express `.json()`, Flask `.get_json()`) change the bytes and break the MAC. For other languages, look up the `beta.webhooks.unwrap` binding in the SDK repo (`shared/live-sources.md`); don't hand-roll verification.
58
+
59
+ ---
60
+
61
+ ## Payload envelope
62
+
63
+ ```json
64
+ {
65
+ "type": "event",
66
+ "id": "event_01ABC...",
67
+ "created_at": "2026-03-18T14:05:22Z",
68
+ "data": {
69
+ "type": "session.status_idled",
70
+ "id": "session_01XYZ...",
71
+ "organization_id": "8a3d2f1e-...",
72
+ "workspace_id": "c7b0e4d9-..."
73
+ }
74
+ }
75
+ ```
76
+
77
+ Switch on `data.type`, fetch the resource by `data.id`, return any **2xx** to acknowledge. `created_at` is when the *state transition* happened, not when the webhook fired.
78
+
79
+ ---
80
+
81
+ ## Supported `data.type` values
82
+
83
+ | `data.type` | Fires when |
84
+ |---|---|
85
+ | `session.status_scheduled` | Session created and ready to accept events |
86
+ | `session.status_run_started` | Agent execution kicked off (every transition to `running`) |
87
+ | `session.status_idled` | Agent awaiting input (tool approval, custom tool result, or next message) |
88
+ | `session.status_terminated` | Session hit a terminal error |
89
+ | `session.thread_created` | Multiagent: coordinator opened a new subagent thread |
90
+ | `session.thread_idled` | Multiagent: a subagent thread is waiting for input |
91
+ | `session.outcome_evaluation_ended` | Outcome grader finished one iteration |
92
+ | `vault.archived` | Vault was archived |
93
+ | `vault.created` | Vault was created |
94
+ | `vault.deleted` | Vault was deleted |
95
+ | `vault_credential.archived` | Vault credential was archived |
96
+ | `vault_credential.created` | Vault credential was created |
97
+ | `vault_credential.deleted` | Vault credential was deleted |
98
+ | `vault_credential.refresh_failed` | MCP OAuth vault credential failed to refresh |
99
+ | `agent.created` | Agent created |
100
+ | `agent.updated` | A new agent version was published. Updates that do not create a new version do **not** fire this. |
101
+ | `agent.archived` | Agent archived |
102
+ | `agent.deleted` | Agent permanently deleted — no object left to fetch; treat the event itself as final |
103
+ | `deployment.created` | Scheduled deployment created |
104
+ | `deployment.updated` | Deployment properties changed (e.g. schedule edited) |
105
+ | `deployment.paused` | Deployment paused — by request, or automatically when a scheduled run fails with a **non-recoverable** error (archived agent, missing environment). Recoverable failures, including rate limits, do **not** auto-pause. |
106
+ | `deployment.unpaused` | Deployment unpaused; schedule resumes |
107
+ | `deployment.archived` | Deployment archived — directly, or as a result of agent archival/deletion |
108
+ | `deployment.deleted` | Deployment permanently deleted — no object left to fetch; treat the event itself as final |
109
+ | `deployment_run.started` | A **scheduled** run started. Manual runs do **not** emit `deployment_run.*` events. |
110
+ | `deployment_run.succeeded` | Scheduled run created its session. Same `data.id` (the run ID) as the run's `.started` event — fetch the deployment run for its `session_id`, then subscribe to the session events to follow the work. |
111
+ | `deployment_run.failed` | Scheduled run did not create a session. Same `data.id` as the run's `.started` event — fetch the deployment run for `error.type` / `error.message`. |
112
+
113
+ > These are **webhook** `data.type` values — a separate namespace from SSE event types (`session.status_idle`, `span.outcome_evaluation_end`, etc. in `shared/managed-agents-events.md`). Don't reuse SSE constants in webhook handlers.
114
+
115
+ ---
116
+
117
+ ## Delivery behavior & pitfalls
118
+
119
+ - **No ordering guarantee.** `session.status_idled` may arrive before `session.outcome_evaluation_ended` even if the evaluation finished first. Sort by envelope `created_at` if order matters.
120
+ - **Retries carry the same `event.id`.** At least one retry on non-2xx. Dedupe on `event.id`.
121
+ - **3xx is failure.** Redirects are not followed — update the URL in Console if your endpoint moves.
122
+ - **Auto-disable** after ~20 consecutive failed deliveries, or immediately if the hostname resolves to a private IP or returns a redirect. Re-enable manually in Console.
123
+ - **Thin payload is intentional.** Don't expect `stop_reason`, `outcome_evaluations`, credential secrets, etc. on the webhook body — fetch the resource.
@@ -0,0 +1,197 @@
1
+ # Managed Agents — Memory Stores
2
+
3
+ > **Public beta.** Memory stores ship under the `managed-agents-2026-04-01` beta header; the SDK sets it automatically on all `client.beta.memory_stores.*` calls. If `client.beta.memory_stores` is missing, upgrade to the latest SDK release.
4
+
5
+ Sessions are ephemeral by default — when one ends, anything the agent learned is gone. A **memory store** is a workspace-scoped collection of small text documents that persists across sessions. When a store is attached to a session (via `resources[]`), it is mounted into the container as a filesystem directory; the agent reads and writes it with the ordinary file tools, and a system-prompt note tells it the mount is there.
6
+
7
+ Every mutation to a memory produces an immutable **memory version** (`memver_...`), giving you an audit trail and point-in-time rollback/redact.
8
+
9
+ ## Object model
10
+
11
+ | Object | ID prefix | Scope | Notes |
12
+ | --- | --- | --- | --- |
13
+ | Memory store | `memstore_...` | Workspace | Attach to sessions via `resources[]` |
14
+ | Memory | `mem_...` | Store | One text file, addressed by `path` (≤ 100KB each — prefer many small files) |
15
+ | Memory version | `memver_...` | Memory | Immutable snapshot per mutation; `operation` ∈ `created` / `modified` / `deleted` |
16
+
17
+ ## Create a store
18
+
19
+ `description` is passed to the agent so it knows what the store contains — write it for the model, not for humans.
20
+
21
+ ```python
22
+ store = client.beta.memory_stores.create(
23
+ name="User Preferences",
24
+ description="Per-user preferences and project context.",
25
+ )
26
+ print(store.id) # memstore_01Hx...
27
+ ```
28
+
29
+ Other SDKs: TypeScript `client.beta.memoryStores.create({...})`; Go `client.Beta.MemoryStores.New(ctx, ...)`. See `shared/managed-agents-api-reference.md` → SDK Method Reference for the full per-language table.
30
+
31
+ Stores support `retrieve` / `update` / `list` (with `include_archived`, `created_at_{gte,lte}` filters) / `delete` / **`archive`**. Archive makes the store read-only — existing session attachments continue, new sessions cannot reference it; no unarchive.
32
+
33
+ ### Seed with content (optional)
34
+
35
+ Pre-load reference material before any session runs. `memories.create` creates a memory at the given `path`; if a memory already exists there the call returns `409` (`memory_path_conflict_error`, with the `conflicting_memory_id`). The store ID is the first positional argument.
36
+
37
+ ```python
38
+ client.beta.memory_stores.memories.create(
39
+ store.id,
40
+ path="/formatting_standards.md",
41
+ content="All reports use GAAP formatting. Dates are ISO-8601...",
42
+ )
43
+ ```
44
+
45
+ ## Attach to a session
46
+
47
+ Memory stores go in the session's `resources[]` array alongside `file` and `github_repository` resources (see `shared/managed-agents-environments.md` → Resources). Memory stores attach at **session create time only** — `sessions.resources.add()` does not accept `memory_store`.
48
+
49
+ ```python
50
+ session = client.beta.sessions.create(
51
+ agent=agent.id,
52
+ environment_id=environment.id,
53
+ resources=[
54
+ {
55
+ "type": "memory_store",
56
+ "memory_store_id": store.id,
57
+ "access": "read_write", # or "read_only"; default is "read_write"
58
+ "instructions": "User preferences and project context. Check before starting any task.",
59
+ }
60
+ ],
61
+ )
62
+ ```
63
+
64
+ | Field | Required | Notes |
65
+ | --- | --- | --- |
66
+ | `type` | ✅ | `"memory_store"` |
67
+ | `memory_store_id` | ✅ | `memstore_...` |
68
+ | `access` | — | `"read_write"` (default) or `"read_only"` — enforced at the filesystem level on the mount |
69
+ | `instructions` | — | Session-specific guidance for this store, in addition to the store's `name`/`description`. ≤ 4,096 chars. |
70
+
71
+ **Max 8 memory stores per session.** Attach multiple when different slices of memory have different owners or lifecycles — e.g. one read-only shared-reference store plus one read-write per-user store, or one store per end-user/team/project sharing a single agent config.
72
+
73
+ ### How the agent sees it (FUSE mount)
74
+
75
+ Each attached store is mounted in the session container at `/mnt/memory/<store-name>/`. The agent interacts with it using the standard file tools (`bash`, `read`, `write`, `edit`, `glob`, `grep`) — there are no dedicated memory tools. `access: "read_only"` makes the mount read-only at the filesystem level; `"read_write"` allows the agent to create, edit, and delete files under it. A short description of each mount (name, path, `instructions`, access) is automatically injected into the system prompt so the agent knows the store exists without you having to mention it.
76
+
77
+ Writes the agent makes under the mount are persisted back to the store and produce memory versions just like host-side `memories.update` calls.
78
+
79
+ ## Manage memories directly (host-side)
80
+
81
+ Use these for review workflows, correcting bad memories, or seeding stores out-of-band.
82
+
83
+ ### List
84
+
85
+ Returns `Memory | MemoryPrefix` entries — a `MemoryPrefix` (`type: "memory_prefix"`, just a `path`) is a directory-like node when listing hierarchically. Use `path_prefix` to scope (include a trailing slash: `"/notes/"` matches `/notes/a.md` but not `/notes_backup/old.md`) and `depth` to bound the tree walk. `order_by` / `order` sort the result. Pass `view="full"` to include `content` in each item; the default `"basic"` returns metadata only.
86
+
87
+ ```python
88
+ for m in client.beta.memory_stores.memories.list(store.id, path_prefix="/"):
89
+ if m.type == "memory":
90
+ print(f"{m.path} ({m.content_size_bytes} bytes, sha={m.content_sha256[:8]})")
91
+ else: # "memory_prefix"
92
+ print(f"{m.path}/")
93
+ ```
94
+
95
+ ### Read
96
+
97
+ ```python
98
+ mem = client.beta.memory_stores.memories.retrieve(memory_id, memory_store_id=store.id)
99
+ print(mem.content)
100
+ ```
101
+
102
+ `retrieve` defaults to `view="full"` (content included); `view` matters mainly on list endpoints.
103
+
104
+ ### Create vs. update
105
+
106
+ | Operation | Addressed by | Semantics |
107
+ | --- | --- | --- |
108
+ | `memories.create(store_id, path=..., content=...)` | **Path** | Create at `path`. `409` (`memory_path_conflict_error`, includes `conflicting_memory_id`) if the path is already occupied. |
109
+ | `memories.update(mem_id, memory_store_id=..., path=..., content=...)` | **`mem_...` ID** | Mutate existing memory. Change `content`, `path` (rename), or both. Renaming onto an occupied path returns the same `409 memory_path_conflict_error`. |
110
+
111
+ ```python
112
+ mem = client.beta.memory_stores.memories.create(
113
+ store.id,
114
+ path="/preferences/formatting.md",
115
+ content="Always use tabs, not spaces.",
116
+ )
117
+
118
+ client.beta.memory_stores.memories.update(
119
+ mem.id,
120
+ memory_store_id=store.id,
121
+ path="/archive/2026_q1_formatting.md", # rename
122
+ )
123
+ ```
124
+
125
+ ### Optimistic concurrency (precondition on `update`)
126
+
127
+ `memories.update` accepts a `precondition` so you can read → modify → write back without clobbering a concurrent writer. The only supported type is `content_sha256`. On mismatch the API returns `409` (`memory_precondition_failed_error`) — re-read and retry against fresh state.
128
+
129
+ ```python
130
+ client.beta.memory_stores.memories.update(
131
+ mem.id,
132
+ memory_store_id=store.id,
133
+ content="CORRECTED: Always use 2-space indentation.",
134
+ precondition={"type": "content_sha256", "content_sha256": mem.content_sha256},
135
+ )
136
+ ```
137
+
138
+ ### Delete
139
+
140
+ ```python
141
+ client.beta.memory_stores.memories.delete(mem.id, memory_store_id=store.id)
142
+ ```
143
+
144
+ Pass `expected_content_sha256` for a conditional delete.
145
+
146
+ ## Audit and rollback — memory versions
147
+
148
+ Every mutation creates an immutable `memver_...` snapshot. Versions accumulate for the lifetime of the parent memory; `memories.retrieve` always returns the current head, the version endpoints give you history.
149
+
150
+ | Operation that triggers it | `operation` field on the version |
151
+ | --- | --- |
152
+ | `memories.create` at a new path | `"created"` |
153
+ | `memories.update` changing `content`, `path`, or both (or an agent-side write to the mount) | `"modified"` |
154
+ | `memories.delete` | `"deleted"` |
155
+
156
+ Each version also records `created_by` — an actor object with `type` ∈ `session_actor` / `api_actor` / `user_actor` — and, after redaction, `redacted_at` + `redacted_by`.
157
+
158
+ ### List versions
159
+
160
+ Newest-first, paginated. Filter by `memory_id`, `operation`, `session_id`, `api_key_id`, or `created_at_gte` / `created_at_lte`. Pass `view="full"` to include `content`; default is metadata-only.
161
+
162
+ ```python
163
+ for v in client.beta.memory_stores.memory_versions.list(store.id, memory_id=mem.id):
164
+ print(f"{v.id}: {v.operation}")
165
+ ```
166
+
167
+ ### Retrieve a version
168
+
169
+ ```python
170
+ version = client.beta.memory_stores.memory_versions.retrieve(
171
+ version_id, memory_store_id=store.id
172
+ )
173
+ print(version.content)
174
+ ```
175
+
176
+ ### Redact a version
177
+
178
+ Scrubs content from a historical version while preserving the audit trail (actor + timestamps). Clears `content`, `content_sha256`, `content_size_bytes`, and `path`; everything else stays. Use for leaked secrets, PII, or user-deletion requests.
179
+
180
+ ```python
181
+ client.beta.memory_stores.memory_versions.redact(version_id, memory_store_id=store.id)
182
+ ```
183
+
184
+ ## Endpoint reference
185
+
186
+ See `shared/managed-agents-api-reference.md` → Memory Stores / Memories / Memory Versions for the full HTTP method/path tables. Raw HTTP base path:
187
+
188
+ ```
189
+ POST /v1/memory_stores
190
+ POST /v1/memory_stores/{memory_store_id}/archive
191
+ GET /v1/memory_stores/{memory_store_id}/memories
192
+ PATCH /v1/memory_stores/{memory_store_id}/memories/{memory_id}
193
+ GET /v1/memory_stores/{memory_store_id}/memory_versions
194
+ POST /v1/memory_stores/{memory_store_id}/memory_versions/{version_id}/redact
195
+ ```
196
+
197
+ For cURL examples and the CLI (`ant beta:memory-stores ...`), WebFetch the Memory URL in `shared/live-sources.md` → Managed Agents.