Compare commits

..
1 Commits
Author SHA1 Message Date
jpmschweitzerandClaude Opus 4.5 4efa717796 fix: improve Steward delegation instructions for Librarian
Build and Push / build (release) Successful in 10s
- Update Librarian capability description to highlight CREATE/UPDATE/SEARCH
- Add specific Steward guidelines for wiki creation, updates, and research
- Add dynamic time injection to user prompts for temporal awareness
- Expand domains to include 'create', 'write', 'update'
- Update test to match new capability description

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 21:55:17 +01:00
4 changed files with 48 additions and 15 deletions
+7 -2
View File
@@ -21,8 +21,10 @@ LIBRARIAN_CAPABILITY = HouseholdCapability(
role="The Librarian",
category="research",
description=(
"Research assistant providing knowledge search, wiki access, "
"semantic search, and knowledge graph exploration via library-desk API"
"Research and wiki management: can CREATE wiki pages about topics "
"(with automatic HybridRAG research), UPDATE existing pages, "
"SEARCH wiki/knowledge graph/web, and synthesize information. "
"Use for: 'create a page about X', 'update wiki', 'find info on X'"
),
domains=[
"research",
@@ -32,6 +34,9 @@ LIBRARIAN_CAPABILITY = HouseholdCapability(
"documents",
"search",
"synthesis",
"create",
"write",
"update",
],
cost="medium", # Multiple API calls to library-desk
requires_network=True, # Needs library-desk API access
+12 -8
View File
@@ -48,7 +48,7 @@ AVAILABLE HOUSEHOLD CAPABILITIES:
{capabilities_text}
YOUR TASK:
Analyze the user's query and recommend which capabilities are needed.
Analyze the user's query and recommend which capabilities are needed, with specific delegation instructions.
{history_text}
USER QUERY: {query}
@@ -57,18 +57,22 @@ GUIDELINES:
- Be conservative - only recommend truly necessary capabilities
- Simple greetings/chat → no capabilities needed (conversational response only)
- Math/calculations → tatlock_core
- Web searches → tatlock_core
- Quick web searches → tatlock_core
- Time/date queries → tatlock_core
- Wiki creation ("create a page about X", "add X to wiki") → librarian with smart_create
- Wiki updates ("update the page", "add to dossier") → librarian with update
- Research queries ("find info", "what do we know about", "search for") → librarian with hybrid_search
- In-depth research, knowledge synthesis, document lookup → librarian with hybrid_search
- If conversation history is relevant, note which previous turns matter
- Assess complexity: simple (1 tool), moderate (2-3 tools), complex (multiple steps)
- If capabilities are missing, mention what would be needed
RESPOND WITH 2-3 SENTENCES:
1. Which capabilities (if any) are needed and why
2. Complexity assessment (simple/moderate/complex)
3. Any conversation context or missing capabilities
RESPOND WITH 2-4 SENTENCES:
1. Capability needed: name the capability and the specific action (e.g., "librarian to create a wiki page about CI/CD using smart_create")
2. Reason: brief explanation of why this capability handles the request
3. Complexity assessment (simple/moderate/complex)
4. Any relevant conversation context
Use capability names in your response (e.g., "tatlock_core for calculations").
Be specific about what Tatlock should delegate - include the action verb (create, update, search, etc.).
Plain text only - no JSON, no special formatting."""
+23 -2
View File
@@ -4,6 +4,7 @@ Request preprocessing pipeline.
Analyzes requests via the Steward and creates scoped toolsets for Tatlock.
"""
from dataclasses import dataclass
from datetime import datetime
from typing import Any, Optional
from src.agents.steward import analyze_request, format_steward_note
@@ -14,6 +15,23 @@ from src.core.logging_config import get_logger
logger = get_logger(__name__)
def _inject_temporal_context(request: str) -> str:
"""
Append current time context to user request.
Provides Tatlock with temporal awareness for time-sensitive queries.
Args:
request: Original user request
Returns:
Request with appended time context
"""
now = datetime.now()
time_str = now.strftime("%Y-%m-%d %H:%M")
return f"{request}\n\n[Current time: {time_str}]"
@dataclass
class EnrichedRequest:
"""
@@ -65,6 +83,9 @@ async def preprocess_request(
>>> print(len(enriched.scoped_tools))
5 # All tatlock_core tools
"""
# Inject temporal context for time-aware processing
enriched_request = _inject_temporal_context(user_request)
logger.info(
"preprocessing_request",
request_preview=user_request[:100],
@@ -74,7 +95,7 @@ async def preprocess_request(
# Call Steward with full conversation history
recommendation = await analyze_request(
user_request,
enriched_request,
conversation_history=conversation_history,
conversation_id=conversation_id,
)
@@ -97,7 +118,7 @@ async def preprocess_request(
)
return EnrichedRequest(
original_request=user_request,
original_request=enriched_request,
steward_note=steward_note,
scoped_tools=scoped_tools,
recommendation=recommendation,
+6 -3
View File
@@ -113,9 +113,12 @@ class TestLibrarianRegistration:
class TestCapabilityDescription:
"""Tests for capability description."""
def test_description_mentions_library_desk(self):
"""Test description mentions library-desk API."""
assert "library-desk" in LIBRARIAN_CAPABILITY.description.lower()
def test_description_mentions_wiki_capabilities(self):
"""Test description mentions wiki read/write capabilities."""
desc = LIBRARIAN_CAPABILITY.description.lower()
assert "create" in desc
assert "update" in desc
assert "search" in desc
def test_description_mentions_search(self):
"""Test description mentions search capability."""