feat: Literature-aware librarian & archivist agents#389
Open
Baeora wants to merge 16 commits intogreyhaven-ai:mainfrom
Open
feat: Literature-aware librarian & archivist agents#389Baeora wants to merge 16 commits intogreyhaven-ai:mainfrom
Baeora wants to merge 16 commits intogreyhaven-ai:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve DAG timing ambiguity, add parser format specs, define PromptBundle extension strategy, specify pipeline integration path, add Agent SDK tool registration, fix stage numbering, add ingestion error handling, defer multi-pass to follow-up. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add prefix-based role routing for dynamic librarian names, specify AgentOutputs field additions, clarify per_role_tools is a new mechanism, note controller override interaction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
17 tasks across 9 chunks covering contracts, ingestion, agent runners, consult_library tool, DAG/routing/prompts, storage/gate/pipeline, CLI, docs, and integration tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix chunking tests (pad inputs past small-file threshold), use tuples for RoleSpec.depends_on, add claude_skills_path to ArtifactStore tests, fix stage file path, add librarian_enabled guard. Add 4 missing tasks: LLM ingestion call, orchestrator wiring, prompt injection, knowledge export extension. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire prefix fallback into existing route() method internals instead of separate methods. Wire ingest_book() into add-book CLI command with graceful fallback when no provider configured. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…uration settings Chunk 1 of librarian/archivist implementation: LibrarianFlag, LibrarianOutput, ArchivistDecision, ArchivistOutput dataclasses; library fields on AgentOutputs; AppSettings with library_root, library_books, librarian/archivist model/provider settings, and ingestion_model. Also fix Windows compatibility for resource module. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Chunk 2: slugify, chunk_markdown (heading-based splitting with atomic block preservation for tables/code/math/blockquotes/lists), register_book, validate_ingestion, remove_book, list_books. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… and test style fixes Chunk 3: LibrarianRunner (parser + run/consult), ArchivistRunner (parser + run/noop + spot_pull_sections + has_violations). Chunk 4: LibraryToolHandler with rate limiting, routing, and consultation logging. Test style: all library tests updated to match codebase conventions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Task 8: prefix-based routing for librarian_*/archivist in RoleRouter. Task 9: build_mts_dag() now accepts active_books for dynamic librarian nodes. Task 10: LibraryPromptBundle and build_library_context_block in templates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Task 11: library persistence methods on ArtifactStore (notes, decisions, logs). Task 12: evaluate_archivist_gate stage for pipeline hard_gate/soft_flag/skip. Task 13: consult_library added to Agent SDK ROLE_TOOL_CONFIG for main roles. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Task 14: CLI commands for library management via autoctx. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Agent roles, generation loop stages, knowledge system, CLI commands, and configuration variables documented. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ort extension Task 17: end-to-end integration test for full library flow. Task 18: ingest_book() LLM call to produce reference.md. Task 19: orchestrator wiring tests for library configuration. Task 20: inject_library_context for agent prompt augmentation. Task 21: active_library_books field on SkillPackage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Note: I started adapting this for my own use case and then realized it requires an API key to actually use / test so I am going to rebuild it in a way that lets me use my max plan instead; you might find use from my additions though (although you'll need to test and finish if you do find it interesting)
TLDR It adds "Librarian" agents which have literature SME and then an "Archivist" which will settle disputes between literature that spans over the years / is eventually refuted etc.
Here is Claude's summary:
Summary
Adds two new agent roles to the generation loop — librarian and archivist — that ground strategy evolution in ingested literature. Users can ingest markdown books into a persistent library. Each active book
gets a dedicated librarian agent that reviews strategies against the book's principles, flags violations, and is available to other agents via a consult_library tool. When a librarian escalates a violation,
the archivist spot-pulls original passages from the chunked source material and renders a verdict: dismissed, soft_flag, or hard_gate. Hard gates force a retry before tournament matches proceed.
This is a complete component-level implementation with 85 new tests. The runtime wiring to invoke librarians during a live generation loop (orchestrator _init_library() and the --books flag on the run
command) is not yet connected — the individual components are built, tested, and integrated at the DAG/routing/pipeline level, but the final orchestrator plumbing is left for a follow-up.
What's included
Ingestion pipeline (knowledge/ingestion.py)
Agent runners
Pipeline integration
Prompt system
Storage & persistence
CLI commands
Data contracts & configuration
Documentation
What's NOT included (follow-up work)
These are the final wiring steps that connect the tested components to the running generation loop.