fix: improve Steward delegation instructions for Librarian
Build and Push / build (release) Successful in 10s
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>
This commit is contained in:
@@ -21,8 +21,10 @@ LIBRARIAN_CAPABILITY = HouseholdCapability(
|
|||||||
role="The Librarian",
|
role="The Librarian",
|
||||||
category="research",
|
category="research",
|
||||||
description=(
|
description=(
|
||||||
"Research assistant providing knowledge search, wiki access, "
|
"Research and wiki management: can CREATE wiki pages about topics "
|
||||||
"semantic search, and knowledge graph exploration via library-desk API"
|
"(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=[
|
domains=[
|
||||||
"research",
|
"research",
|
||||||
@@ -32,6 +34,9 @@ LIBRARIAN_CAPABILITY = HouseholdCapability(
|
|||||||
"documents",
|
"documents",
|
||||||
"search",
|
"search",
|
||||||
"synthesis",
|
"synthesis",
|
||||||
|
"create",
|
||||||
|
"write",
|
||||||
|
"update",
|
||||||
],
|
],
|
||||||
cost="medium", # Multiple API calls to library-desk
|
cost="medium", # Multiple API calls to library-desk
|
||||||
requires_network=True, # Needs library-desk API access
|
requires_network=True, # Needs library-desk API access
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ AVAILABLE HOUSEHOLD CAPABILITIES:
|
|||||||
{capabilities_text}
|
{capabilities_text}
|
||||||
|
|
||||||
YOUR TASK:
|
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}
|
{history_text}
|
||||||
|
|
||||||
USER QUERY: {query}
|
USER QUERY: {query}
|
||||||
@@ -57,18 +57,22 @@ GUIDELINES:
|
|||||||
- Be conservative - only recommend truly necessary capabilities
|
- Be conservative - only recommend truly necessary capabilities
|
||||||
- Simple greetings/chat → no capabilities needed (conversational response only)
|
- Simple greetings/chat → no capabilities needed (conversational response only)
|
||||||
- Math/calculations → tatlock_core
|
- Math/calculations → tatlock_core
|
||||||
- Web searches → tatlock_core
|
- Quick web searches → tatlock_core
|
||||||
- Time/date queries → 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
|
- If conversation history is relevant, note which previous turns matter
|
||||||
- Assess complexity: simple (1 tool), moderate (2-3 tools), complex (multiple steps)
|
- 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:
|
RESPOND WITH 2-4 SENTENCES:
|
||||||
1. Which capabilities (if any) are needed and why
|
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. Complexity assessment (simple/moderate/complex)
|
2. Reason: brief explanation of why this capability handles the request
|
||||||
3. Any conversation context or missing capabilities
|
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."""
|
Plain text only - no JSON, no special formatting."""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Request preprocessing pipeline.
|
|||||||
Analyzes requests via the Steward and creates scoped toolsets for Tatlock.
|
Analyzes requests via the Steward and creates scoped toolsets for Tatlock.
|
||||||
"""
|
"""
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from datetime import datetime
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from src.agents.steward import analyze_request, format_steward_note
|
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__)
|
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
|
@dataclass
|
||||||
class EnrichedRequest:
|
class EnrichedRequest:
|
||||||
"""
|
"""
|
||||||
@@ -65,6 +83,9 @@ async def preprocess_request(
|
|||||||
>>> print(len(enriched.scoped_tools))
|
>>> print(len(enriched.scoped_tools))
|
||||||
5 # All tatlock_core tools
|
5 # All tatlock_core tools
|
||||||
"""
|
"""
|
||||||
|
# Inject temporal context for time-aware processing
|
||||||
|
enriched_request = _inject_temporal_context(user_request)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"preprocessing_request",
|
"preprocessing_request",
|
||||||
request_preview=user_request[:100],
|
request_preview=user_request[:100],
|
||||||
@@ -74,7 +95,7 @@ async def preprocess_request(
|
|||||||
|
|
||||||
# Call Steward with full conversation history
|
# Call Steward with full conversation history
|
||||||
recommendation = await analyze_request(
|
recommendation = await analyze_request(
|
||||||
user_request,
|
enriched_request,
|
||||||
conversation_history=conversation_history,
|
conversation_history=conversation_history,
|
||||||
conversation_id=conversation_id,
|
conversation_id=conversation_id,
|
||||||
)
|
)
|
||||||
@@ -97,7 +118,7 @@ async def preprocess_request(
|
|||||||
)
|
)
|
||||||
|
|
||||||
return EnrichedRequest(
|
return EnrichedRequest(
|
||||||
original_request=user_request,
|
original_request=enriched_request,
|
||||||
steward_note=steward_note,
|
steward_note=steward_note,
|
||||||
scoped_tools=scoped_tools,
|
scoped_tools=scoped_tools,
|
||||||
recommendation=recommendation,
|
recommendation=recommendation,
|
||||||
|
|||||||
@@ -113,9 +113,12 @@ class TestLibrarianRegistration:
|
|||||||
class TestCapabilityDescription:
|
class TestCapabilityDescription:
|
||||||
"""Tests for capability description."""
|
"""Tests for capability description."""
|
||||||
|
|
||||||
def test_description_mentions_library_desk(self):
|
def test_description_mentions_wiki_capabilities(self):
|
||||||
"""Test description mentions library-desk API."""
|
"""Test description mentions wiki read/write capabilities."""
|
||||||
assert "library-desk" in LIBRARIAN_CAPABILITY.description.lower()
|
desc = LIBRARIAN_CAPABILITY.description.lower()
|
||||||
|
assert "create" in desc
|
||||||
|
assert "update" in desc
|
||||||
|
assert "search" in desc
|
||||||
|
|
||||||
def test_description_mentions_search(self):
|
def test_description_mentions_search(self):
|
||||||
"""Test description mentions search capability."""
|
"""Test description mentions search capability."""
|
||||||
|
|||||||
Reference in New Issue
Block a user