1
0

feat: Timmy system introspection, delegation, and session logging (#74)

* test: remove hardcoded sleeps, add pytest-timeout

- Replace fixed time.sleep() calls with intelligent polling or WebDriverWait
- Add pytest-timeout dependency and --timeout=30 to prevent hangs
- Fixes test flakiness and improves test suite speed

* feat: add Aider AI tool to Forge's toolkit

- Add Aider tool that calls local Ollama (qwen2.5:14b) for AI coding assist
- Register tool in Forge's code toolkit
- Add functional tests for the Aider tool

* config: add opencode.json with local Ollama provider for sovereign AI

* feat: Timmy fixes and improvements

## Bug Fixes
- Fix read_file path resolution: add ~ expansion, proper relative path handling
- Add repo_root to config.py with auto-detection from .git location
- Fix hardcoded llama3.2 - now dynamic from settings.ollama_model

## Timmy's Requests
- Add communication protocol to AGENTS.md (read context first, explain changes)
- Create DECISIONS.md for architectural decision documentation
- Add reasoning guidance to system prompts (step-by-step, state uncertainty)
- Update tests to reflect correct model name (llama3.1:8b-instruct)

## Testing
- All 177 dashboard tests pass
- All 32 prompt/tool tests pass

* feat: Timmy system introspection, delegation, and session logging

## System Introspection (Sovereign Self-Knowledge)
- Add get_system_info() tool - Timmy can now query his runtime environment
- Add check_ollama_health() - verify Ollama status
- Add get_memory_status() - check memory tier status
- True introspection vs hardcoded prompts

## Path Resolution Fix
- Fix all toolkits to use settings.repo_root consistently
- Now uses Path(settings.repo_root) instead of Path.cwd()

## Inter-Agent Delegation
- Add delegate_task() tool - Timmy can dispatch to Seer, Forge, Echo, etc.
- Add list_swarm_agents() - query available agents

## Session Logging
- Add SessionLogger for comprehensive interaction logging
- Records messages, tool calls, errors, decisions
- Writes to /logs/session_{date}.jsonl

## Tests
- Add tests for introspection tools
- Add tests for delegation tools
- Add tests for session logging
- Add tests for path resolution
- All 18 new tests pass
- All 177 dashboard tests pass

---------

Co-authored-by: Alexander Payne <apayne@MM.local>
This commit is contained in:
Alexander Whitestone
2026-02-27 00:11:53 -05:00
committed by GitHub
parent 5e60a6453b
commit a975a845c5
8 changed files with 745 additions and 8 deletions

View File

@@ -0,0 +1,96 @@
"""Inter-agent delegation tools for Timmy.
Allows Timmy to dispatch tasks to other swarm agents (Seer, Forge, Echo, etc.)
"""
import logging
from typing import Any
logger = logging.getLogger(__name__)
def delegate_task(
agent_name: str, task_description: str, priority: str = "normal"
) -> dict[str, Any]:
"""Dispatch a task to another swarm agent.
Args:
agent_name: Name of the agent to delegate to (seer, forge, echo, helm, quill)
task_description: What you want the agent to do
priority: Task priority - "low", "normal", "high"
Returns:
Dict with task_id, status, and message
"""
from swarm.coordinator import coordinator
# Validate agent name
valid_agents = ["seer", "forge", "echo", "helm", "quill", "mace"]
agent_name = agent_name.lower().strip()
if agent_name not in valid_agents:
return {
"success": False,
"error": f"Unknown agent: {agent_name}. Valid agents: {', '.join(valid_agents)}",
"task_id": None,
}
# Validate priority
valid_priorities = ["low", "normal", "high"]
if priority not in valid_priorities:
priority = "normal"
try:
# Submit task to coordinator
task = coordinator.post_task(
description=task_description,
assigned_agent=agent_name,
priority=priority,
)
return {
"success": True,
"task_id": task.task_id,
"agent": agent_name,
"status": "submitted",
"message": f"Task submitted to {agent_name}: {task_description[:100]}...",
}
except Exception as e:
logger.error("Failed to delegate task to %s: %s", agent_name, e)
return {
"success": False,
"error": str(e),
"task_id": None,
}
def list_swarm_agents() -> dict[str, Any]:
"""List all available swarm agents and their status.
Returns:
Dict with agent list and status
"""
from swarm.coordinator import coordinator
try:
agents = coordinator.list_swarm_agents()
return {
"success": True,
"agents": [
{
"name": a.name,
"status": a.status,
"capabilities": a.capabilities,
}
for a in agents
],
}
except Exception as e:
return {
"success": False,
"error": str(e),
"agents": [],
}