Add three patterns from graduated agent shapes#111
Merged
Conversation
Graduate three substantive entries from docs/agent/non-obvious- shapes.md into full patterns under docs/patterns/, each with a runnable snippet and "when this is right / when it isn't" guidance: - state-migration-on-resume: schema_version conventions, the Callable[[Any], Any] migrate signature, JSON-backed checkpointer requirement, chained migrations and the CheckpointStateMigrationMissing failure mode. - caller-supplied-trace-identifiers: invoke(metadata=...) and set_invocation_metadata propagation through OTel attributes and Langfuse trace.metadata, with the boundary validation rules. - observer-state-reconciliation: per-invocation dict keyed on (namespace, branch_name, attempt_index, fan_out_index) for custom observers that need to thread state between paired events. Update the patterns index + mkdocs nav, remove the three graduated entries from non-obvious-shapes (the patterns catalog handles discoverability), regenerate the bundled AGENTS.md and the programmatic patterns API (openarmature.patterns now lists 7 entries instead of 4), and bump the test_patterns_api expectation.
There was a problem hiding this comment.
Pull request overview
Graduates three “non-obvious shapes” into first-class Pattern docs (and wires them into the docs site and the programmatic openarmature.patterns catalog), while removing the graduated entries from docs/agent/non-obvious-shapes.md.
Changes:
- Add three new pattern docs (state migration on resume, caller-supplied trace identifiers, observer started→completed reconciliation) under
docs/patterns/and mirrored intosrc/openarmature/_patterns/. - Update the docs navigation, patterns index, and generated
AGENTS.mdto include the new patterns and remove the graduated “non-obvious shapes” entries. - Update the patterns API unit test to expect the expanded 7-pattern list.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_patterns_api.py | Updates expected openarmature.patterns.list() slugs to include the three new patterns. |
| src/openarmature/AGENTS.md | Regenerates bundled docs to include the three new patterns and removes the graduated sections. |
| src/openarmature/_patterns/state-migration-on-resume.md | Adds packaged pattern markdown for programmatic access via openarmature.patterns.get(). |
| src/openarmature/_patterns/caller-supplied-trace-identifiers.md | Adds packaged pattern markdown for programmatic access via openarmature.patterns.get(). |
| src/openarmature/_patterns/observer-state-reconciliation.md | Adds packaged pattern markdown for programmatic access via openarmature.patterns.get(). |
| mkdocs.yml | Adds the three new patterns to the MkDocs nav. |
| docs/patterns/state-migration-on-resume.md | Adds new site pattern doc for checkpoint state migration. |
| docs/patterns/caller-supplied-trace-identifiers.md | Adds new site pattern doc for invocation metadata propagation. |
| docs/patterns/observer-state-reconciliation.md | Adds new site pattern doc for observer started→completed reconciliation. |
| docs/patterns/index.md | Adds the three new patterns to the patterns catalog index page. |
| docs/agent/non-obvious-shapes.md | Removes the three entries that were graduated into full pattern docs. |
| CHANGELOG.md | Notes the addition of three pattern docs and the patterns API growth from 4→7. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Two CoPilot findings on PR #111: 1. caller-supplied-trace-identifiers referenced a non-existent public constant ``RESERVED_LANGFUSE_METADATA_KEYS``. The actual symbol is ``_RESERVED_KEY_NAMES`` (module-private). Replace the false-symbol claim with a description of where validation runs (the boundary in ``observability.metadata``) and point at the spec's observability §3.4 for the canonical reserved-key list. 2. state-migration-on-resume's resume snippet used ``starting_state=None``, but ``CompiledGraph.invoke()`` takes positional ``initial_state: StateT`` (required, no such kwarg). Update the comment to pass ``PipelineState()`` positionally; the engine overwrites it from the loaded checkpoint record. Regenerate AGENTS.md and ``_patterns/`` so the two regenerated mirrors carry the same fixes.
This was referenced Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First of five docs-polish items. Graduates three substantive entries from
docs/agent/non-obvious-shapes.mdinto full pattern docs underdocs/patterns/, each following the existing pattern doc structure (Problem → Approach → Snippet → When this is right → When it isn't → Cross-references):state-migration-on-resume:schema_versionconventions, theCallable[[Any], Any]migrate signature, the JSON-backed checkpointer requirement, chained migrations, and the fail-loudCheckpointStateMigrationMissingfailure mode.caller-supplied-trace-identifiers:invoke(metadata=...)andset_invocation_metadatapropagation through OTel attributes and Langfusetrace.metadata, with the boundary validation rules (reserved-key namespaces, OTel-compatible scalar types).observer-state-reconciliation: per-invocation dict keyed on(namespace, branch_name, attempt_index, fan_out_index)for custom observers that need to thread state between paired events; uses aNamedTuplefor the timing record so the shape is self-documenting.Three graduated entries removed from
non-obvious-shapes.md(the patterns catalog handles discoverability). BundledAGENTS.mdand the programmatic patterns API (openarmature.patterns) regenerated; catalog grows from 4 to 7 entries.Notable while writing: the original
with_state_migrationrecipe in non-obvious-shapes had the wrong migrate callable signature (claimed three-arg; actual is single-argCallable[[Any], Any]). Pattern A ships the corrected shape plus theserialization=\"json\"checkpointer requirement that makes the migration path actually work.Test plan
uv run pytest -q(1080 pass, no regressions)uv run pyright src testscleantests/unit/test_patterns_api.pybumped to expect the 7-entry sorted listmkdocs serveand confirm the three new patterns render correctly under the Patterns navOut of scope