Skip to content

← Back to YouLab

Custom Letta tools that agents can call during conversations.

YouLab provides two agent tools:

ToolPurposeLocation
query_honchoQuery Honcho for student insightssrc/youlab_server/tools/dialectic.py
edit_memory_blockUpdate memory blockssrc/youlab_server/tools/memory.py

These tools enable agents to:

  • Access theory-of-mind insights mid-conversation
  • Update their own memory based on learned information

Query Honcho dialectic for insights about the current student.

Location: src/youlab_server/tools/dialectic.py

Agents call this tool with a natural language question:

query_honcho(
question="What learning style works best for this student?",
session_scope="all",
)
ParameterTypeDefaultDescription
questionstringRequiredNatural language question about the student
session_scopestring"all"Which sessions to include

Session Scopes:

ScopeDescription
allAll conversation history
recentLast few sessions
currentCurrent conversation only

Returns Honcho’s insight as a string, or an error message if unavailable.

Include in agent persona to enable usage:

You have access to the query_honcho tool. Use it to:
- Understand student learning patterns
- Recall past conversation context
- Identify communication preferences
Example: query_honcho("How engaged is this student with the current topic?")

The tools require client context to be set before use:

from youlab_server.tools.dialectic import set_honcho_client, set_user_context
from youlab_server.tools.memory import set_letta_client
# During service initialization
set_honcho_client(honcho_client)
set_letta_client(letta_client)
# Before each conversation
set_user_context(agent_id="agent-abc", user_id="user123")

Propose an update to a user’s memory block.

Location: src/youlab_server/tools/memory.py

Important: This tool creates a pending diff that requires user approval. Changes are NOT applied immediately.

Agents call this tool to propose changes to user memory:

edit_memory_block(
block="student",
field="strengths",
content="Strong analytical thinking",
strategy="append",
reasoning="Observed during problem-solving discussion",
)
ParameterTypeDefaultDescription
blockstringRequiredBlock label (e.g., "student", "journey")
fieldstringRequiredField to update
contentstringRequiredContent to add/replace
strategystring"append"Merge strategy
reasoningstring""Explanation of why this change is proposed

Merge Strategies:

StrategyBehavior
appendAdd to existing (default, safe)
replaceOverwrite existing
llm_diffIntelligently merge

Confirmation that the proposal was created:

Proposed change to student.strengths (ID: abc12345).
The user will review and approve/reject this suggestion.
  1. Agent calls edit_memory_block with reasoning
  2. System creates PendingDiff in user storage
  3. User sees pending change in UI
  4. User approves → Change applied, git commit created
  5. User rejects → Change discarded
  6. New proposals for same block supersede older ones

Include in agent persona:

You have access to the edit_memory_block tool. Use it to:
- Propose updates to what you've learned about the student
- Suggest adding new strengths or insights
- Recommend updating the learning journey
IMPORTANT:
- Changes require user approval - explain your reasoning clearly
- The reasoning field helps users understand WHY you're suggesting this change
- Be specific and evidence-based in your proposals
Example: edit_memory_block(
block="student",
field="background",
content="Senior year, applying to CS programs",
strategy="replace",
reasoning="Student mentioned they are in their final year and focused on CS applications"
)

Tools are registered with Letta agents during creation:

from youlab_server.tools.dialectic import query_honcho
from youlab_server.tools.memory import edit_memory_block
# Tools are added to agent via Letta SDK
agent = client.create_agent(
...
tools=[query_honcho, edit_memory_block],
)

AspectAgent ToolsBackground Agents
TriggerDuring conversationScheduled/manual
ActorAgent decidesSystem decides
ScopeCurrent sessionBatch across users
AuditLetta message historyArchival memory
Use caseReal-time insightsPeriodic enrichment

When to use tools: Agent needs information or wants to record something during a conversation.

When to use background agents: Periodic batch processing of student data across all users.